var tmr;

function OpenWindow(StrLink)
{
	window.open(StrLink,"_blank","resizable=yes,height=375,width=567,scrollbars,toolbar=yes");			
} 
	
function CloseWindow()
{
	window.close()
} 
	
function ClientBidCountDown()
{
	var timeRemainingString = "";
	var time1 = new Date(document.ClientBidding.CurrentTime.value);
	
	if (time1 == "NaN")
		document.ClientBidding.CurrentTime.text = "";
	else
	{
		var mysec =time1.getSeconds();
		time1.setSeconds(mysec + 1);
		var year=time1.getYear();
		if (year < 1000)
			year+=1900;
		var day=time1.getDay();
		var month=time1.getMonth();//+1
		var daym=time1.getDate();
		if (daym<10)
			daym="0"+daym;
		var hours=time1.getHours();
		var minutes=time1.getMinutes();
		var seconds=time1.getSeconds();
		//if (hours==0)
		//	hours=12;
		if (minutes<=9)
			minutes="0"+minutes;
		if (seconds<=9)
			seconds="0"+seconds;
		var dn=""
		var x = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug","Sep","Oct","Nov","Dec");
		var timenow=daym+" "+x[month]+" "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
		document.ClientBidding.CurrentTime.value = timenow;
	}

	var timeEnd = new Date(document.ClientBidding.BidEndTime.value);
	var timeStart = new Date(document.ClientBidding.BidStartTime.value);
	
	var time = Math.floor((timeEnd.getTime() - time1.getTime()) / 1000.0) ;
	
	if (time < 0)
	{
		timeRemainingString = "Bid Closed";
	}
	else if (time < 60)
	{
		timeRemainingString = "Less than a Minute";
	}
	else if (time > 0)
	{
		days    = Math.floor( time/86400);
		hours   = Math.floor( time /3600) % 24;
		minutes = Math.floor( time  / 60) % 60;

		seconds = (time%60);

		if (minutes < 10) minutes = "0" + minutes;
		if (seconds < 10) seconds = "0" + seconds;

		var daytext = days + " Day" + ((days!=1)?"s":"") +  ", ";

		timeRemainingString = daytext + hours + ":" + minutes + ":" + seconds;
	}
	document.ClientBidding.lblTimeLeft.value = timeRemainingString;
}

function ClientBidgoforit(){
	setInterval("ClientBidCountDown()",1000);
}

function ConsultantBidCountDown()
{
	var timeRemainingString = "";
	var time1 = new Date(document.ConsultantBidding.CurrentTime.value);
	
	if (time1 == "NaN")
		document.ConsultantBidding.CurrentTime.text = "";
	else
	{
		var mysec =time1.getSeconds();
		time1.setSeconds(mysec + 1);
		var year=time1.getYear();
		if (year < 1000)
			year+=1900;
		var day=time1.getDay();
		var month=time1.getMonth();//+1
		var daym=time1.getDate();
		if (daym<10)
			daym="0"+daym;
		var hours=time1.getHours();
		var minutes=time1.getMinutes();
		var seconds=time1.getSeconds();
		//if (hours==0)
		//	hours=12;
		if (minutes<=9)
			minutes="0"+minutes;
		if (seconds<=9)
			seconds="0"+seconds;
		var dn=""
		var x = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug","Sep","Oct","Nov","Dec");
		var timenow=daym+" "+x[month]+" "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
		document.ConsultantBidding.CurrentTime.value = timenow;
	}

	var timeEnd = new Date(document.ConsultantBidding.BidEndTime.value);
	var timeStart = new Date(document.ConsultantBidding.BidStartTime.value);
	var time = Math.floor((timeEnd.getTime() - time1.getTime()) / 1000.0) ;
		
	if (time < 0)
	{
		timeRemainingString = "Bid Closed";
	}
	else if (time < 60)
	{
		timeRemainingString = "Less than a Minute";
	}
	else if (time > 0)
	{
		days    = Math.floor( time/86400);
		hours   = Math.floor( time /3600) % 24;
		minutes = Math.floor( time  / 60) % 60;

		seconds = (time%60);

		if (minutes < 10) minutes = "0" + minutes;
		if (seconds < 10) seconds = "0" + seconds;

		var daytext = days + " Day" + ((days!=1)?"s":"") +  ", ";

		timeRemainingString = daytext + hours + ":" + minutes + ":" + seconds;
	}
	document.ConsultantBidding.lblTimeLeft.value = timeRemainingString;
}

function ConsultantBidgoforit(){
	setInterval("ConsultantBidCountDown()",1000);
}

function VendorBidCountDown()
{
	var timeRemainingString = "";
	var time1 = new Date(document.VendorBidding.CurrentTime.value);
	
	if (time1 == "NaN")
		document.VendorBidding.CurrentTime.text = "";
	else
	{
		var mysec =time1.getSeconds();
		time1.setSeconds(mysec + 1);
		var year=time1.getYear();
		if (year < 1000)
			year+=1900;
		var day=time1.getDay();
		var month=time1.getMonth();//+1
		var daym=time1.getDate();
		if (daym<10)
			daym="0"+daym;
		var hours=time1.getHours();
		var minutes=time1.getMinutes();
		var seconds=time1.getSeconds();
		//if (hours==0)
		//	hours=12;
		if (minutes<=9)
			minutes="0"+minutes;
		if (seconds<=9)
			seconds="0"+seconds;
		var dn=""
		var x = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug","Sep","Oct","Nov","Dec");
		var timenow=daym+" "+x[month]+" "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
		document.VendorBidding.CurrentTime.value = timenow;
	}
		
	var timeEnd = new Date(document.VendorBidding.BidEndTime.value);
	var timeStart = new Date(document.VendorBidding.BidStartTime.value);
	var time = Math.floor((timeEnd.getTime() - time1.getTime()) / 1000.0) ;
		
	if (time < 0)
	{
		timeRemainingString = "Bid Closed";
	}
	else if (time < 60)
	{
		timeRemainingString = "Less than a Minute";
	}
	else if (time > 0)
	{
		days    = Math.floor( time/86400);
		hours   = Math.floor( time /3600) % 24;
		minutes = Math.floor( time  / 60) % 60;

		seconds = (time%60);

		if (minutes < 10) minutes = "0" + minutes;
		if (seconds < 10) seconds = "0" + seconds;

		var daytext = days + " Day" + ((days!=1)?"s":"") +  ", ";

		timeRemainingString = daytext + hours + ":" + minutes + ":" + seconds;
	}
	document.VendorBidding.lblTimeLeft.value = timeRemainingString;
}

function VendorBidgoforit(){
	setInterval("VendorBidCountDown()",1000);
}


/*
Code related to showing Current Server time ticking and also time left
in the Test.aspx
*/




/* This function is used by the logo.inc & documentlogo.inc 
	for opening the help page in a new window*/

function OpenNewHelpWindow(StrLink)
{	
//alert("in open func");

	var pagename = "";
	pagename = window.parent.location;	
	//alert(window.location);	
	//alert(pagename);	
	StrLink = StrLink + "?pg=" +pagename;		
	//alert(StrLink);
	window.open(StrLink,"_blank","resizable=yes,height=375,width=567,scrollbars,toolbar=yes");			
} 


/* This function is used to set the focus of the panel on NEW and EDIT */
	function showPanel(objControl,hiddenShowPanel)
		{	
			if (hiddenShowPanel.value == 1)
			{			
				objControl.focus();							
			}
		}
		
		
		
function newImage(arg)
{
	if (document.images) 
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages(arg1, arg2) 
{
	if (document.images) 
	{
		document.getElementById(arg1).src = arg2;
	}
}		

//function to change image of buttons on mouse over and out (Used in page which opens from career link of branded company)
function SetImgPathOverNOut(BtnName,ImgName)  
	  {
	  //alert(document.getElementById("HdnImg_Path").value);
	  var path;
	  if (document.getElementById("HdnImg_Path"))
	  {
	   path=document.getElementById("HdnImg_Path").value;
	  }
	  else
	  {
	   path="/img";
	  }
		 
	  if(document.getElementById(BtnName))
	  {
	  url=path+"/buttons/" + ImgName + ".gif";
	  document.getElementById(BtnName).src=url;
	  }
	 
	  }	

/////////////////////////////////////////////////////////////
//          Function Name: SubmitViaEnter()
//          Author: Vijay
//          Purpose: This function tracks the key press event and sets the control to be clicked
//
//          Parameters:
//          1. evt : The event which is passed by the control
//          2. Cntrl_ID :  The Control id to be clicked
//          
//          Create Date: 19 September 2007
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////

function submitViaEnter(evt,Cntrl_ID)
{
    evt = (evt) ? evt : window.event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
    var strAppendID = Cntrl_ID ;
    
    if (charCode == 13 || charCode == 3) 
    {
         document.getElementById(strAppendID).click(); 
         return false;
    }    
    
}

/////////////////////////////////////////////////////////////
//          Function Name: loadGetSkillXML
//          Author: Mahendra Bhatt
//          Purpose: This function gets all skills
//          Parameters:
//          1. evt: event object
//          
//
//          Create Date: 23 Apr 2008
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////
var reqSkill, resSkill;
function loadGetSkillXML(url) {
    if (window.XMLHttpRequest) {
        reqSkill = new XMLHttpRequest();
        reqSkill.onreadystatechange = processReqSkill;
        reqSkill.open("GET", url, true);
        reqSkill.send(null);
        //branch for IE/Windows ActiveX version
    }
    else if (window.ActiveXObject) {
        //alert("in else");
        isIE = true;
        reqSkill = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqSkill) {
            reqSkill.onreadystatechange = processReqSkill;
            reqSkill.open("GET", url, true);
            reqSkill.send();
        }
    }
}




function processReqSkill(){
    if (reqSkill.readyState == 4){
       if (reqSkill.status == 200){
            resSkill = reqSkill.responseXML.documentElement;
       }
   }
}

var curtd = 0;
var tdCount;
function CallSkillIntellisense(obj,evt){
	var Hdnid ='HdnSkillCode'+obj.id.substring(obj.id.indexOf('TxtSkillName')+'TxtSkillName'.length);
	document.getElementById(Hdnid).value= '';
    clearTimeout(tmr);
    evt = (evt) ? evt : event;
    var hgt=0;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
    var coords = getPosition(obj.id);
    var strHTML = '<table cellspacing="2" cellpadding="2" border="0" style="cursor:pointer;" width="100%" class="td">';
    if(resSkill){
    var tbl = resSkill.getElementsByTagName('Table');
    var strTblHTML = new String();

//    if(obj.value!='' || charCode==38 || charCode==40 || charCode==13){
    if(obj.value!='' || obj.value=='' || charCode==38 || charCode==40 || charCode==13){
        for(i=0;i<tbl.length;i++){
            if(tbl[i].getElementsByTagName('Skill_Description')[0].firstChild.data.toLowerCase() == obj.value.toLowerCase()){
                tdCount = i;
                hgt = hgt + 21;
                document.getElementById(Hdnid).value=tbl[i].getElementsByTagName('Skill_Code')[0].firstChild.data;
                document.getElementById('DivSkillstable').style.display='none';  
                return false;
            }
            else if(tbl[i].getElementsByTagName('Skill_Description')[0].firstChild.data.toLowerCase().indexOf(obj.value.toLowerCase())>=0){
                hgt = hgt + 21;
                tdCount = i;
                strTblHTML += '<tr><td onkeypress="return CheckKey(this,'+"'"+obj.id+"'"+',event);" onkeydown="return SelSkillList(this,event);" onmouseover="changeStyle(this,'+"'"+'tdover'+"'"+
                            ');" onmouseout="changeStyle(this,'+"'"+'td'+"'"+
                            ');" onclick="setValue(this,'+"'"+obj.id+"'"+
                           ','+"'"+tbl[i].getElementsByTagName('Skill_Code')[0].firstChild.data+"'"+
                           ');">'+tbl[i].getElementsByTagName('Skill_Description')[0].firstChild.data + '</td></tr>';
            }            
        }
        strHTML+=strTblHTML+'</table>';
        if(strTblHTML==''){
      document.getElementById('DivSkillstable').style.display='none';  
      //    document.getElementById('DivSkill').style.display='none';  
            return false;
        }
        
 document.getElementById('DivSkillstable').style.display='';
      document.getElementById('DivSkillstable').style.left = coords.left + 'px';
     document.getElementById('DivSkillstable').style.top = coords.top + 18 + 'px';
        
     
        
        if(hgt<=200){
            document.getElementById('DivSkillstable').style.height = hgt+'px';
        }
        else{
            document.getElementById('DivSkillstable').style.height = '200px';
        }
       
        document.getElementById('DivSkillstable').innerHTML = strHTML;
        
        if(charCode==38 || charCode==40){
            if(charCode==40){
                curtd = tdCount -1;
            }
            SelSkillList(obj,evt);
        }
   }
   else{
    document.getElementById('DivSkillstable').style.display='none';
   }
   }
}


/////////////////////////////////////////////////////////////
//          Function Name: setValue
//          Author: Mahendra Bhatt
//          Purpose: This function sets the value of skill code in skill text box
//          Parameters:
//          1. evt: event object
//          
//
//          Create Date: 14 Feb 2008
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////
function setValue(obj, ObjectToSet, Skill_Code){
	var nrg = new RegExp("&amp;","g");
	var strinnerText = obj.innerHTML;
	
    document.getElementById(ObjectToSet).value = strinnerText.replace(nrg,"&"); 
    var Hdnid ='HdnSkillCode'+ObjectToSet.substring(ObjectToSet.indexOf('TxtSkillName')+'TxtSkillName'.length);
    document.getElementById(Hdnid).value=Skill_Code;
    document.getElementById('DivSkillstable').style.display='none';     
    document.getElementById(ObjectToSet).focus();
}

function changeStyle(obj,aclass){
    obj.className = aclass;
}


/////////////////////////////////////////////////////////////
//          Function Name: SelSkillList
//          Author: Mahendra Bhatt
//          Purpose: This function selects the tablecells in skill list as up & down arrow keys are pressed
//          Parameters:
//          1. evt: event object
//          
//
//          Create Date: 14 Feb 2008
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////

function SelSkillList(obj,evt){
    clearTimeout(tmr);
    evt = (evt) ? evt : event;
    var tds = document.getElementById('DivSkillstable').getElementsByTagName('td');
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
    
    if (charCode == 9) 
    {
         obj.click();
         return false;  
    } 
    
    if(obj.type!='text'){
        obj.className = 'td';
        if(charCode==38){
            curtd = curtd - 1;
        }
        else if(charCode==40){
            curtd = curtd + 1;            
        }     
    }
    
    if(curtd<0){
        curtd = tds.length-1;
    }
    else if(curtd>tds.length-1){
        curtd = 0;
    }
    
    obj.blur();
    tds[curtd].className ='tdover';
    tds[curtd].focus();
}

function changeStyle(obj,aclass){
    obj.className = aclass;
}


/////////////////////////////////////////////////////////////
//          Function Name: loadGetConsultantSkillXML
//          Author: Mahendra Bhatt
//          Purpose: This function gets all skills
//          Parameters:
//          1. evt: event object
//          
//
//          Create Date: 23 Apr 2008
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////
var reqS, resS;
function loadGetConsultantSkillXML(compcode,uid) {
    url='/WebService/PeopleplusMMAWebServices.asmx/GetSkillsDetailedResume?CompanyCodeJobPosting=0&'+
        'JobPostingNo=0&JobAppSrNo=0&CompanyCode='+compcode+
        '&ConsultantUserID='+uid+'&ResumeType=False&mode=&keyword=';
    if (window.XMLHttpRequest) {
        reqS = new XMLHttpRequest();
        reqS.onreadystatechange = processReqConsultantSkill;
        reqS.open("GET", url, true);
        reqS.send(null);
        //branch for IE/Windows ActiveX version
    }
    else if (window.ActiveXObject) {
        //alert("in else");
        isIE = true;
        reqS = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqS) {
            reqS.onreadystatechange = processReqConsultantSkill;
            reqS.open("GET", url, true);
            reqS.send();
        }
    }
}


function processReqConsultantSkill(){
    if (reqS.readyState == 4){
       if (reqS.status == 200){
            resS = reqS.responseXML.documentElement;
            var tbl = resS.getElementsByTagName('Table');
            if(tbl.length>0){
                if((parseInt(tbl.length)-3)>0){
                    CreateControls(parseInt(tbl.length)-3);
                }
                for(i=0;i<tbl.length;i++){
                    document.getElementById('TxtSkillName'+i).value = tbl[i].getElementsByTagName('SkillName')[0].firstChild.data;
                    document.getElementById('TxtExpYrs'+i).value = tbl[i].getElementsByTagName('Experience_Years')[0].firstChild.data;
                    document.getElementById('DrpDwnProLevel'+i).value = tbl[i].getElementsByTagName('Proficiency_Level')[0].firstChild.data;
                    document.getElementById('HdnSkillCode'+i).value = tbl[i].getElementsByTagName('Skill_Code')[0].firstChild.data;
                }
            }
       }
   }
}

var reqZ, resY;
function loadGetConsultantSkillXMLFORJPOST(compcode,uid) {
    url='/WebService/PeopleplusMMAWebServices.asmx/GetResourceSkill?CompanyCodeJobPosting='+compcode+
        '&JobPostingNo='+uid;
    if (window.XMLHttpRequest) {
        reqZ = new XMLHttpRequest();
        reqZ.onreadystatechange = processReqConsultantSkillJPOST;
        reqZ.open("GET", url, true);
        reqZ.send(null);
        //branch for IE/Windows ActiveX version
    }
    else if (window.ActiveXObject) {
        //alert("in else");
        isIE = true;
        reqZ = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqZ) {
            reqZ.onreadystatechange = processReqConsultantSkillJPOST;
            reqZ.open("GET", url, true);
            reqZ.send();
        }
    }
}





function processReqConsultantSkillJPOST(){
    if (reqZ.readyState == 4){
       if (reqZ.status == 200){
            resY = reqZ.responseXML.documentElement;
            var tbl = resY.getElementsByTagName('Table');
            if(tbl.length>0){
                if((parseInt(tbl.length)-3)>0){
                    CreateControls(parseInt(tbl.length)-3);
                }
                for(i=0;i<tbl.length;i++){
                    document.getElementById('TxtSkillName'+i).value = tbl[i].getElementsByTagName('SkillName')[0].firstChild.data;
                    document.getElementById('TxtExpYrs'+i).value = tbl[i].getElementsByTagName('Experience_Years')[0].firstChild.data;
                    document.getElementById('DrpDwnProLevel'+i).value = tbl[i].getElementsByTagName('Proficiency_Level')[0].firstChild.data;
                    document.getElementById('HdnSkillCode'+i).value = tbl[i].getElementsByTagName('Skill_code')[0].firstChild.data;
                }
            }
       }
   }
}




// Fuction used to populate dropwdown on the ONCHANGE Attributes of another DropDown  
      
var reqDrp;
var objDrp,ValueField,TextField;
function PopulateDrpDwn(obj,obj1,Function,Parameter1,Column1,Column2)
{
	objDrp=document.getElementById(obj1);               //DropDown Which you want to populate
	ValueField=Column1;                // Column Name of ds which you want as value of DropDown
	TextField=Column2;                 // Column Name of ds which you want as text of DropDown
	var Code;
	var count;
	
	Code=document.getElementById(obj.id).value;   // code to find selected value of DropDown i.e. from which we want to populate another dropdown
	 
    
    loadXMLDocJS('/PeopleplusMMAWeb/' + 
    'WebService/PeopleplusMMAWebServices.asmx/'+ Function +'?'+ Parameter1 + '=' + Code )
}
       
function loadXMLDocJS(url) 
{
    //branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) 
    {
     reqDrp = new XMLHttpRequest();
     reqDrp.onreadystatechange = processReqChangeJs;
     reqDrp.open("GET", url, true);
     reqDrp.send(null);
    //branch for IE/Windows ActiveX version
    } 
     else if (window.ActiveXObject) 
    {
	  isIE = true;
      reqDrp = new ActiveXObject("Microsoft.XMLHTTP");
      if (reqDrp) 
      {
        reqDrp.onreadystatechange = processReqChangeJS;
        reqDrp.open("GET", url, true);
        reqDrp.send();
      }
   }
}
    
function processReqChangeJS() 
{
    var resDrp,count,totalCld,i;
    var Value,Text;
    if (reqDrp.readyState == 4) 
    {
        if (reqDrp.status == 200) 
        {
            resDrp  = reqDrp.responseXML.documentElement;
			totalCld=resDrp.getElementsByTagName(ValueField).length   //gives length of child nodes
		    Count=document.getElementById(objDrp.id).length;
	        //alert(Count);
	        // Code to remove old records from State DropDown
	        if (Count > 0)
	        {
	            for(i=0;i< Count ;i++)
	             {
	               document.getElementById(objDrp.id).remove(0);
	               document.getElementById(objDrp.id).remove(1);
	             }
	         }
		    
	        // Code to Insert records from State DropDown
		    for(i=0;i < totalCld ;i++)
		    {		
		        var StrCode,StrText;
		        StrCode=resDrp.getElementsByTagName(ValueField)[i].firstChild.data;
		        StrText=resDrp.getElementsByTagName(TextField)[i].firstChild.data;
		        if(StrCode != null)
			    {
			        var newOption = document.createElement('<option value=StrCode>');
			        document.getElementById(objDrp.id).options.add(newOption);
			        newOption.text = StrText;
			        newOption.value=StrCode;
			    }
	        }
	         
	        if (document.getElementById(objDrp.id).length > 0 )
	        {
	            document.getElementById(objDrp.id).options[0].selected=true;
		    }
		}
	} 
}


/////////////////////////////////////////////////////////////
//          Function Name: getPosition
//          Author: Mahendra Bhatt
//          Purpose: This function gets page coordinates 
//          Parameters:
//          1. evt: event object
//          
//
//          Create Date: 14 Feb 2008
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////
function getPosition(elemID) {
  
    var offsettrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsettrail) {
        offsetLeft += offsettrail.offsetLeft;
        offsetTop += offsettrail.offsetTop;
        offsettrail = offsettrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop };
}

function ClearValues(obj,cnt,evt){
    if(obj.value==''){
     document.getElementById('HdnSkillCode'+cnt).value='';     
    }
    tmr = setTimeout("document.getElementById('DivSkillstable').style.display='none';",5000);
}

/////////////////////////////////////////////////////////////
//          Function Name: CheckKey
//          Author: Mahendra Bhatt
//          Purpose: This function checks whether Return Key is pressed and calls
//                   The Click Event of the Object
//          Parameters:
//          1. evt: event object
//          
//
//          Create Date: 14 Feb 2008
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////

function CheckKey(obj,objparent,evt){
  evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);

    if (charCode == 13 || charCode == 3) 
    {
         obj.click();
         return false;  
    }    
    else{
        var tds = document.getElementById('DivSkillstable').getElementsByTagName('td');
        for(i=0;i<tds.length;i++){
           if(tds[i].innerHTML.toLowerCase().indexOf(String.fromCharCode(charCode))==0){
                
                document.getElementById(objparent).value=String.fromCharCode(charCode);
                document.getElementById(objparent).focus();
                return false;
           }
        }
    }
}


/* This function is developed by Mahendra Bhatt and is used for highlighting the 
keyword in the keyword search pages */
function highlightSearchTerms(searchText,obj)
{
	if (searchText != '')
	{
	 searchArray = searchText.split(" ");
  
	  var bodyText = document.getElementById(obj).innerHTML;
	  for (var i = 0; i < searchArray.length; i++) {
		bodyText = doHighlight(bodyText, searchArray[i]);
		}
  
	document.getElementById(obj).innerHTML = bodyText;
	return true;
	}
}    


function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
  if ((!highlightStartTag) || (!highlightEndTag)) {
    highlightStartTag = "<font style='color:blue; background-color:yellow;'>";
    highlightEndTag = "</font>";
  }

  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}


/////////////////////////////////////////////////////////////
//          Function Name: doKeypress
//          Author: vandana Dixit
//          Purpose: This function, Keep user from entering more than maxLength characters
//          Parameters:
//          1. control
//          
//
//          Create Date: 29 july 2008
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////
function doKeypress(control){

    maxLength = control.attributes["maxLength"].value;
    
    value = control.value;
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }
}

/////////////////////////////////////////////////////////////
//          Function Name: doBeforePaste
//          Author: vandana Dixit
//          Purpose: This function, Cancel default behavior
//          Parameters:
//          1. control
//          
//
//          Create Date: 29 july 2008
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////
function doBeforePaste(control){
    maxLength = control.attributes["maxLength"].value;
     if(maxLength)
     {
          event.returnValue = false;
     }
}

/////////////////////////////////////////////////////////////
//          Function Name: doPaste
//          Author: vandana Dixit
//          Purpose: This function, Cancel default behavior and create a new paste routine
//          Parameters:
//          1. control
//          
//
//          Create Date: 29 july 2008
//          Last Modified Date:
//          Modification History:
//          1.
//          2.
//          3.    
/////////////////////////////////////////////////////////////

function doPaste(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}