function selectCreditsTab(divid,totaldivs,memebr_id,industry_id,EditOptions)
{


    //  document.getElementById("div_1").setAttribute("class","tabmenu_selected");
    //alert("");
    //        for(j=1;j<=totaldivs;j++)
    //        {
    //            try{
    //               // alert("");
    //               document.getElementById("div_"+j).setAttribute("class","tabmenu_selected");
    //              //  alert(document.getElementById("div_"+j).classname);
    //            }catch(e){
    //
    //                //alert(e)
    //            }
    //
    //        }
    for(i=1;i<=totaldivs;i++)
    {
        if(i==divid)
        {
            // alert(i+"--"+divid)
            try{
            //    document.getElementById("div_"+i).classname="tabmenu";
            }catch(e){}
            var url="creditinformationByMemberIndustryId.php?MID="+memebr_id+"&IID="+industry_id+"&EditOptions="+EditOptions;

            sendRequest("text",url,"Div_Display");
            // alert(document.getElementById("div_"+i).innerHTML);
            // alert(document.getElementById("Div_Display").style.display);
            document.getElementById("Div_Display").innerHTML=sendRequest("text",url,"Div_Display");
            try{
                document.getElementById("div_"+i).setAttribute("class","tabmenu_selected");
            }catch(e){}
        //  alert(document.getElementById("div_"+i).classname);
        }
        else
        {
            try{
                // alert("");
                document.getElementById("div_"+i).setAttribute("class","tabmenu");
            //  document.getElementById("div_"+i).classname="tabmenu";
            //  alert(document.getElementById("div_"+i).classname);
            }catch(e){}
        }
    }

    clearCredsDetailsinfo();

}


function GetCreditInformation(industryid,position,total_MIs)
{

	 
	
	//document.GetElmentById("credits_info_"+industryid).classname="bottom_tabs_selected";
	
	 
	// document.getElementById("credits_info_"+position).setAttribute("class","bottom_tabs_selected");
	
	
	
	
	
	
	
	
	
    var EditOptions=false;
    var arrayLength=0;
    var content="<table width='100%' border='0' align='center' cellpadding='4' cellspacing='1' class='credit_info_tabs'>";
	
	
	content+='<tr>'+
    '<td  width="40" align="left" valign="middle"'+
	'class="credit_infos credit_info_tabs"> Year</td>'+
    '<td  width="170"   align="left" valign="middle" class="credit_infos credit_info_tabs" style="padding-left:10px;">Role</td>'+
     '<td  width="80"  align="left" valign="middle" class="credit_infos credit_info_tabs" style="padding-left:10px;">Title</td>'+
    '<td  width="80"   align="left" valign="middle" class="credit_infos credit_info_tabs" style="padding-left:10px;">Banner</td>'+
    '<td  width="80"  align="left" valign="middle"  class="credit_infos credit_info_tabs"style="padding-left:10px;">Director</td>'+
    
   
  '</tr>';

	
	
    var Array_CreditsByIndustry=CreditInfomation_array[industryid];
	 
    try{
        arrayLength=Array_CreditsByIndustry.length;
    }catch(e)
    {
        
        arrayLength=0;
    }
 
    
    if(arrayLength>0)
    {
         
        for(j=0;j<arrayLength;j++)
        {
             

            var title="";
            var role_palyed="";
            var production_company="";
            var director="";
            var venue="";
            var start_year="";
            var end_year="";
            var creditsid="";
        

            try{
            
                EditOptions=Array_CreditsByIndustry[j]['EditOptions'];
                title=Array_CreditsByIndustry[j]['title'];
                role_palyed=Array_CreditsByIndustry[j]['role_palyed'];
                production_company=Array_CreditsByIndustry[j]['production_company'];
                director=Array_CreditsByIndustry[j]['director'];
                venue=Array_CreditsByIndustry[j]['venue'];
                start_year=Array_CreditsByIndustry[j]['start_year'];
                end_year=Array_CreditsByIndustry[j]['end_year'];
                creditsid=Array_CreditsByIndustry[j]['creditsid'];
           
            }catch(e)
            {
            //alert(e)
            }

 
            content+="<tr><td class='bottom_sub_txt' 'nowrap:nowrap'>"+start_year;
        
            if(start_year!=end_year)
            {
                content+=" - "+end_year;
            }
            content+="</td> \n";

             

            content+="<td  class='bottom_sub_txt'  >"+wordwrap1(role_palyed)+"</td> \n";
               content+="<td class='bottom_sub_txt' >"+wordwrap1(title)+"</td> \n";
            content+="<td class='bottom_sub_txt'>"+wordwrap1(production_company)+"</td> \n";

            content+="<td class='bottom_sub_txt'>"+wordwrap1(director)+"</td> \n";
           
         

            if(EditOptions=="true")
            {

                content+= "<td class='bottom_sub_txt'  align='center'>\n\
            <a href='creditsinfoDelete.php?creditsid="+creditsid+"' \n\
            onclick='return confirmation()'; ><img  src='../images/icons/delete.png' border='0' \n\
            onmouseout=\"UnTip()\" onmouseover=\"ToolTip('Delete "+title+" Credit Details')\" title='Delete' />\n\
            </a>\n\
             </td> \n";
            
                content+= "<td class='bottom_sub_txt'  align='center'>\n\
            <a href=javascript:GetCrditsINFO('"+creditsid+"') >\n\
            <img src='../images/icons/edit.png' border='0' onmouseout=\"UnTip()\" \n\
            onmouseover=\"ToolTip('Edit "+title+" Credit Details')\" title='edit'  />\n\
            </a>\n\
             </td> \n";
            }
            content+=" </tr>";



        //alert(content);

        
        }//loop
    }
    else
    {

           
        content+= "<tr><td colspan='5' nowrap='nowrap' class='credit_info_tabs' >&nbsp;No Credit Information</td></tr>";
        
    }

 
	 
    //alert(industryid);
    //
	

	
    content+=" </table>";
   
    document.getElementById("Div_Display").innerHTML=content;
    
	for(i=1;i<=total_MIs;i++)
    {
		
		
        if(i==position)
        {//alert(position);
                try{
               // document.getElementById("credits_info_"+i).setAttribute("class","bottom_tabs_selected");
					
			  document.getElementById("credits_info_"+i).className="bottom_tabs_selected";
            }catch(e){
			// document.getElementById("credits_info_"+i).className="bottom_tabs_selected";
			
			}
        
        }
        else
        {
            try{
                document.getElementById("credits_info_"+i).className="bottom_tabs"; 
                // document.getElementById("credits_info_"+i)..className="bottom_tabs";
                 
            
            
            }catch(e){}
        }
    }
}


function GetCrditsINFO(id)
{
    var url="criditsINFOByCreditsID.php?CreditsID="+id;
   // alert(url);
    sendRequestXML("xml",url,"") ;
}

function FinalProcess(HTTPResponceXMLOb)
{

    try{
       

        clearCredsDetailsinfo();
    
        //alert(HTTPResponceXMLOb.getElementsByTagName('ROOT')[1].firstChild.nodeValue);

        var Title="";
        var role_played="";
        var production_company="";
        var director="";
        var venue="";
        var start_year="";
        var end_year="";
        var CreditsInfoID="";
        var industry_id="";

        //alert(HTTPResponceXMLOb.getElementsByTagName('ROOT')[1].firstChild.nodeValue);
       // alert(HTTPResponceXMLOb.getElementsByTagName('ROOT')[2].firstChild.nodeValue); 
       // alert(HTTPResponceXMLOb.getElementsByTagName('ROOT')[3].firstChild.nodeValue); 
        //alert(HTTPResponceXMLOb.getElementsByTagName('ROOT')[4].firstChild.nodeValue); 
        try{
            Title=HTTPResponceXMLOb.getElementsByTagName('ROOT')[1].firstChild.nodeValue;
        }catch(e){}
        
        try{
           CreditsInfoID =HTTPResponceXMLOb.getElementsByTagName('ROOT')[2].firstChild.nodeValue;
        }catch(e){}
        try{
            role_played=HTTPResponceXMLOb.getElementsByTagName('ROOT')[3].firstChild.nodeValue;
        }catch(e){}
        try{
            production_company=HTTPResponceXMLOb.getElementsByTagName('ROOT')[4].firstChild.nodeValue;
        }catch(e){}
        try{
            director=HTTPResponceXMLOb.getElementsByTagName('ROOT')[5].firstChild.nodeValue;
        }catch(e){}
        try{
            venue=HTTPResponceXMLOb.getElementsByTagName('ROOT')[6].firstChild.nodeValue;
        }catch(e){}
        try{
            start_year=HTTPResponceXMLOb.getElementsByTagName('ROOT')[7].firstChild.nodeValue;
        }catch(e){}
        try{
            end_year=HTTPResponceXMLOb.getElementsByTagName('ROOT')[8].firstChild.nodeValue;
        }catch(e){}


        try{
            industry_id=HTTPResponceXMLOb.getElementsByTagName('ROOT')[9].firstChild.nodeValue;
        }catch(e){}
        
        
   
   
        // document.getElementById("yearstart").options[0].selected="seelcted";
        SetSelectValue("yearstart",start_year);
        //document.getElementById("yearend").options[0].selected="seelcted";
        SetSelectValue("yearend",end_year);

         
        SetSelectValue("type",industry_id);

         //  alert('ddddddddddd--------'+CreditsInfoID);

        
        document.getElementById("role").value=role_played;
       // alert("role is"+document.getElementById("role").value);
        document.getElementById("production").value=production_company;
         // alert("role is"+document.getElementById("production").value);        
        document.getElementById("director").value=director;
        //   alert("role is"+document.getElementById("director").value);        
        
         document.getElementById("Title").value=Title;
          //alert("Title is"+document.getElementById("Title").value);    
        document.getElementById("CreditsInfoID").value=CreditsInfoID;
     //   alert("-----"+document.getElementById("CreditsInfoID").value);
        //  alert("--Title---"+document.getElementById("Title").value);   
       // document.getElementById("BtnSave").value="Save Credits Details";



    }catch(e){}
}


function SetSelectValue(id,value)
{

    try{
        //  alert(value);
        var ob=document.getElementById(id);
        var ToalCount=ob.options.length;
        //alert(ToalCount)
        for(i=0;i<=ToalCount;i++)
        {
            // alert(ob.options[i]);
            if(ob.options[i].value==value)
            {
                // alert(i);
                /// ob.options[i].seleced="selected";
                ob.selectedIndex=i;
            }

        }
    }catch(e){}
}

function clearCredsDetailsinfo()
{
    try{
        document.getElementById("yearstart").options[0].selected="selected";
        document.getElementById("yearend").options[0].selected="selected";

        document.getElementById("type").options[0].selected="selected";
        document.getElementById("role").value="";
        document.getElementById("production").value="";
        document.getElementById("Title").value="";
        document.getElementById("director").value="";
        document.getElementById("venue").value="";
        document.getElementById("CreditsInfoID").value="";
        //document.getElementById("BtnSave").value="Enter New Credits Details";
    
    }catch(e){}
}

 function wordwrap1(string)
 {
  
     var resultstring="";
   var resultstring1="";

var mySplitResult = string.split(" ");

for(i = 0; i < mySplitResult.length; i++){
    if(mySplitResult[i].length>16)
    {
    
        resultstring=mySplitResult[i].wordWrap(16, "\n", true)
    }else{
      resultstring=mySplitResult[i];
    }
      
      resultstring1=resultstring1+" "+resultstring;
    
}
  return  resultstring1;

 }
String.prototype.wordWrap = function(m, b, c){
    var i, j, s, r = this.split("");
    if(m > 0) for(i in r){
        for(s = r[i], r[i] = ""; s.length > m;
            j = c ? m : (j = s.substr(0, m).match(/\S*$/)).input.length - j[0].length
            || m,
            r[i] += s.substr(0, j) + ((s = s.substr(j)).length ? b : "")
        );
        
        r[i] += s;
    }
    return r.join("");
};




