﻿// JScript File
 //////////////////
  /////////////
 function setchecktozero() {
var doc = document.forms[0];
var msg = "Are you sure you want to Reset ?";
if (confirm(msg)) {
return true ;
doc.submit();
} else {
		return false;
	} }
 /////////////
  function JobsEdit(form)
  {
  if(form.txtjobId.value == "")
	{
		alert("Please Enter Jobid");
		form.txtjobId.focus();
		return false;
	}

if(form.txtjobtitle.value == "")
	{
		alert("Please Enter Job Title");
		form.txtjobtitle.focus();
		return false;
	}
	else
	
		{
			return true;
		}
}
/////////////////
  function AllowEmployerVisaStatus() {
var doc = document.forms[0];
var msg = "Are you sure you Allow Employer to View Visa Status?";
if (confirm(msg)) {
return true ;
doc.submit();
} else {
		return false;
	} }
 /////////////
 function RejectCvs() {
var doc = document.forms[0];
var msg = "Are you sure you want to Reject Cvs ?";
if (confirm(msg)) {
return true ;
doc.submit();
} else {
		return false;
	} }
 /////////////
 /////////////
 function RejectallCvs() {
var doc = document.forms[0];
var msg = "Are you sure you want to Reject all filtered Cvs ?";
if (confirm(msg)) {
return true ;
doc.submit();
} else {
		return false;
	} }
 /////////////
function checkAll(o) {
for (var i = 0; i < document.Form1.elements.length; i++) {
if (document.Form1.elements[i].type == "checkbox") {
document.Form1.elements[i].checked = o.checked;
}}}
 ///////////////////////
// var defaultText = "Enter your text here";
    function WaterMark(form)
    {
        if(txt.value.length == 0 && evt.type == "blur")
        {
            txt.style.color = "gray";
            txt.value = defaultText;
        }
        if(txt.value == "Hellooooooooo" && evt.type == "focus")
        {
            txt.style.color = "black";
            txt.value="";
        }
    }
        function adminempinfo(form)
{
	if(form.txtabb.value == "")
	{
		alert("Please Enter Company Abbreviation");
		form.txtabb.focus();
		return false;
	}
	else
	{
		return true;
	}	
}
  function contactDetails(form)
{
	if(form.txtperson.value == "")
	{
		alert("Please Enter Name");
		form.txtperson.focus();
		return false;
	}
		if(form.txtdesignation.value == "")
	{
		alert("Please Enter Designation");
		form.txtdesignation.focus();
		return false;
	}
	if(form.txtcontactno.value == "")
	{
		alert("Please Enter Designation");
		form.txtcontactno.focus();
		return false;
	}
	
	else
	{
		return true;
	}	
}
 ////////////////////////
 function personalinfo(form)
{
	if(form.txtname.value == "")
	{
		alert("Please Enter Your Name");
		form.txtname.focus();
		return false;
	}
	if(form.txtdob.value.indexOf("/") == -1 || form.txtdob.value.indexOf("/") == -1 || form.txtdob.value.length < 5)
	{
		alert("Please enter a valid Date Of Birth");
		form.txtdob.focus();
		return false;
	}
	if(form.txtemail.value == "")
	{
		alert("Please enter your email Address");
		form.txtemail.focus();
		return false;
	}
	if(form.txtemail.value.indexOf("@") == -1 || form.txtemail.value.indexOf(".") == -1 || form.txtemail.value.length < 5)
	{
		alert("Please enter a valid Email Address");
		form.txtemail.focus();
		form.txtemail.select();
		return false;
	}
	
	else
	{
		return true;
	}	
}
// function ProcessKeypress() { 
//   if (event.keyCode == 13 ) 
//      { 
//            document.getElementById("btnemp").click(); 
//            event.cancelBubble = true; 
//            return false;
//      }

//}
 ///////////////////
  function birthdate(form)
 {
 if(form.txtdob.value == "")
	{
		alert("Please enter your email Address");
		form.txtdob.focus();
		return false;
	}
	if(form.txtdob.value.indexOf("/") == -1 || form.txtdob.value.indexOf("/") == -1 || form.txtdob.value.length < 5)
	{
		alert("Please enter a valid Date Of Birth");
		form.txtdob.focus();
		form.txtdob.select();
		return false;
	}
	else
		{
			return true;
		}
}
 //////////////////////
 function indexemailaddress(form)
 {
 if(form.TextBox3.value == "")
	{
		alert("Please enter your email Address");
		form.TextBox3.focus();
		return false;
	}
	if(form.TextBox3.value.indexOf("@") == -1 || form.TextBox3.value.indexOf(".") == -1 || form.TextBox3.value.length < 5)
	{
		alert("Please enter a valid Email Address");
		form.TextBox3.focus();
		form.TextBox3.select();
		return false;
	}
	else
		{
			return true;
		}
}
 
 ///////////////
  function DeleteSelectedRecords() {
var doc = document.forms[0];
var msg = "Are you sure you want to Delete Selected Records?";
if (confirm(msg)) {
return true ;
doc.submit();
} else {
		return false;
	} }

 
 //////////////////////////
 function confirmDeleteTitle() {
var doc = document.forms[0];
var msg = "Are you sure you want to Delete List?";
if (confirm(msg)) {
return true ;
doc.submit();
} else {
		return false;
	} }

 //////////////////////
 function titleresumelist(form)
{
if(form.txttitle.value == "")
	{
		alert("Please Enter New List Name");
		form.txttitle.focus();
		return false;
	}
	else
		{
			return true;
		}
}
 ////////////////////
 //////////////////
 function invoiceform(form)
{
if(form.txtinvoiceno.value == "")
	{
		alert("Please Enter Invoice No");
		form.txtinvoiceno.focus();
		return false;
	}
	if(form.txttitle.value == "")
	{
		alert("Please Enter Invoice Title");
		form.txttitle.focus();
		return false;
	}
	else
		{
			return true;
		}
}
 //////////////////////
  function masterform(form)
{
if(form.TextBox32.value == "")
	{
		alert("Please enter Follow Up Date");
		form.TextBox32.focus();
		return false;
	}
	if(form.TextBox3.value == "")
	{
		alert("Please Enter Candidate Name");
		form.TextBox3.focus();
		return false;
	}
	else
		{
			return true;
		}
}
///////////////////////////////
function Addemailtextbox(form)
{
	
	if(form.TextBox3.value.indexOf("@") == -1 || form.TextBox3.value.indexOf(".") == -1 || form.TextBox3.value.length < 5)
	{
		alert("Please enter a valid Email Address");
		form.TextBox3.focus();
		form.TextBox3.select();
		return false;
	}

		
	else
		{
		return true;
	}
}
 //////////////////////////////
 function Emailjob()
 
{
	popUp = window.open('email.aspx','em','width=400,height=200,left=100,top=50,menubar=0')
	
	return false;

}
 //////////////////////////////
 function AddEmails()
 
{
	popUp = window.open('AddEmails.aspx','em','width=400,height=200,left=100,top=50,menubar=0')
	
	return false;

}

 
 //////////////////////
 function chkform123(form)
{
if(form.TextBox3.value == "")
	{
		alert("Please enter Candidate name");
		form.TextBox3.focus();
		return false;
	}
	else
		{
			return true;
		}
}
///////////////
function Companydetails(form)
{
if(form.txtvisaname.value == "")
	{
		alert("Please enter On Visa Company Name ");
		form.txtvisaname.focus();
		return false;
	}
	else
		{
			return true;
		}
}



 ///////////
  function checkcompanypermissionname(form)
{
if(form.txtcompanyname2.value == "")
	{
		alert("Please Enter Company Name On Visa From Companies Detail");
		form.txtcompanyname2.focus();
		return false;
	}
	else
		{
			return true;
		}
}
 
 /////////
 function confirmSubmitforvisa() {
var doc = document.forms[0];
var msg = "Are you sure you want to Move this Candidate For Visa Processing?";
if (confirm(msg)) {
doc.submit();
} else {
// do nothing
} }

///////////////////////
function emailtofriend(form)
{
	if(form.txtname.value == "")
	{
		alert("Please enter your Name");
		form.txtname.focus();
		return false;
	}
	if(form.txtemail1.value == "")
	{
		alert("Please enter your Friend email Address");
		form.txtemail1.focus();
		return false;
	}
	if(form.txtemail1.value.indexOf("@") == -1 || form.txtemail1.value.indexOf(".") == -1 || form.txtemail1.value.length < 5)
	{
		alert("Please enter a valid Email Address");
		form.txtemail1.focus();
		form.txtemail1.select();
		return false;
	}

		
	else
		{
		return true;
	}
}


//////////////////
function CompanyName1(form)
{

	
if(form.ComboBox1.value == "")
	{
		alert("Please Enter Company Name to Add");
		form.ComboBox1.focus();
		return false;
	}
	
	else
		{
		return true;
	}
}

/////////////

function Addingemail(form)
{

	
if(form.TextBox1.value == "")
	{
		alert("Please Enter Emailaddress to Add");
		form.TextBox1.focus();
		return false;
	}
	
	else
		{
		return true;
	}
}



 function clickButton(e)
 {
 if(navigator.appName.indexOf("Netscape")>(-1)){                  
 if (e.keyCode == 13){                        
 bt.click();                        
 return false;                  
 }            
 }            
 if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){                  
 if (event.keyCode < 48 || event.keyCode > 57){                        
 //bt.click();                        
 alert("Enter Numbers Only");
return false;                  
}                 
if(event.Length>3)                 
{                  
alert("Number Should be between 1 and 999")                 
}           
}      
}
 //////////////////
 function confirmSubmit() {
var doc = document.forms[0];
var msg = "Are you sure you want to submit this data?";
if (confirm(msg)) {
doc.submit();
} else {
// do nothing
} }


	function exl()
{
	popUp = window.open('excel.aspx','em','width=800,height=400,left=100,top=50,menubar=0')
	
	return false;

}



function marketingform(form)
{

	
if(form.txtsubject.value == "")
	{
		alert("Please Choose Subject From Below Grid");
		form.txtsubject.focus();
		return false;
	}
	
	else
		{
		return true;
	}
}

 function Requestpending(form)
{

	
if(form.TextBox1.value == "")
	{
		alert("Please Enter Application Information");
		form.TextBox1.focus();
		return false;
	}
	
	else
		{
		return true;
	}
}
/////////////////



function empinfoval(form)
{

	
if(form.txtemail.value == "")
	{
		alert("Please Enter Email");
		form.txtemail.focus();
		return false;
	}
	if(form.txtcompany.value == "")
	{
		alert("Please Enter Company Name");
		form.txtcompany.focus();
		return false;
	}
	if(form.txtdetail.value == "")
	{
		alert("Please Enter Your Company Information");
		form.txtdetail.focus();
		return false;
	}
	if(form.txtcontactperson.value == "")
	{
		alert("Please Enter Contact Person");
		form.txtcontactperson.focus();
		return false;
	}
	if(form.txtdesignation.value == "")
	{
		alert("Please Enter Designation");
		form.txtdesignation.focus();
		return false;
	}
	if(form.txtcontactno.value == "")
	{
		alert("Please Enter LandLine No");
		form.txtcontactno.focus();
		return false;
	}
	if(form.txtmobileno.value == "")
	{
		alert("Please Enter Mobile No");
		form.txtmobileno.focus();
		return false;
	}
	if(form.txtcity.value == "")
	{
		alert("Please Enter City");
		form.txtcity.focus();
		return false;
	}
	else
		{
		return true;
	}
}


//////////////////


 function itval(form)
{

	
if(form.txtapplication1.value == "")
	{
		alert("Please Enter Application Information");
		form.txtapplication1.focus();
		return false;
	}	
	else
		{
		return true;
	}
}
/////////////////
 function Certificationval(form)
{

	
if(form.txtfield3.value == "")
	{
		alert("Please Enter Certification Field");
		form.txtfield3.focus();
		return false;
	}
	if(form.ddlstudy3.value == "")
	{
		alert("Please Enter Professional Certification Study");
		form.ddlstudy3.focus();
		return false;
	}
	if(form.txtinstitute3.value == "")
	{
		alert("Please Enter Name Of Institute");
		form.txtinstitute3.focus();
		return false;
	}
	if(form.ddlduration3.value == "Select")
	{
		alert("Please Enter Course Duration");
		form.ddlduration3.focus();
		return false;
	}
	
	else
		{
		return true;
	}
}
///////////////////
  function technicalducationval(form)
{

	
if(form.txtfield2.value == "")
	{
		alert("Please Enter Technical Qualification Field");
		form.txtfield2.focus();
		return false;
	}
	if(form.ddlstudy2.value == "")
	{
		alert("Please Enter Technical Study");
		form.ddlstudy2.focus();
		return false;
	}
	if(form.txtinstitute2.value == "")
	{
		alert("Please Enter Name Of Technical Study Institute");
		form.txtinstitute2.focus();
		return false;
	}
	if(form.ddlduration2.value == "Select")
	{
		alert("Please Enter Technical Course Duration");
		form.ddlduration2.focus();
		return false;
	}
	
	else
		{
		return true;
	}
}
  
 
 
 ///////////////
 
 
 function Basiceducationval(form)
{
	
if(form.txtfield1.value == "")
	{
		alert("Please Enter Field");
		form.txtfield1.focus();
		return false;
	}
	if(form.ddlstudy1.value == "")
	{
		alert("Please Enter Study Level");
		form.ddlstudy1.focus();
		return false;
	}
	
	if(form.txtinstitute1.value == "")
	{
		alert("Please Enter Name Of Institute");
		form.txtinstitute1.focus();
		return false;
	}
	if(form.ddlduration.value == "Select")
	{
		alert("Please Enter Course Duration");
		form.ddlduration.focus();
		return false;
	}
	
	else
		{
		return true;
	}
}


////////////////////////////
 function Experienceval(form)
{
if(form.txtcompany.value == "")
	{
		alert("Please Enter Company Name");
		form.txtcompany.focus();
		return false;
	}
	if(form.txtdesignation.value == "")
	{
		alert("Please Enter Designation");
		form.txtdesignation.focus();
		return false;
	}
	if(form.txtresponsibilities.value == "")
	{
		alert("Please Enter Your Job Responsibilities");
		form.txtresponsibilities.focus();
		return false;
	}
	else
		{
		return true;
	}
}



 function Indexvalemp(form)
{
if(form.TextBox1.value == "")
	{
		alert("Please Enter UserID");
		form.TextBox1.focus();
		return false;
	}
	if(form.TextBox2.value == "")
	{
		alert("Password Couldnot be Blank");
		form.TextBox2.focus();
		return false;
	}
	else
		{
		return true;
	}
}







//////////////////////////
 function Indexvalcan(form)
{
if(form.txtuserid.value == "")
	{
		alert("Please Enter UserID");
		form.txtuserid.focus();
		return false;
	}
	if(form.txtpwd.value == "")
	{
		alert("Password Couldnot be Blank");
		form.txtpwd.focus();
		return false;
	}
	else
		{
		return true;
	}
}

		



//////////////////////////////////
function valSaveTitle(form)
{
	if(form.txtsavetitle.value=="")
	{
		alert("Please Enter Title")
		form.txtsavetitle.focus();
		return false;
	}
else
	{
		return true;
	}
}

////////////////
function valempchangepwd(form)
{
	if(form.old_pwd.value=="")
	{
		alert("Please enter old password")
		form.old_pwd.focus();
		return false;
	}

	if(form.old_pwd.value.charAt(0)==" ")
	{
        alert("Please Do Not Enter Blank Spaces For Password !");
		form.old_pwd.focus();
		return false;
	}

		var string_pass = form.old_pwd.value ;
			if(string_pass.search(/^\w+( \w+)?$/) == -1)
		{
			 alert("Only alphabets (A-Z and a-z), digits (0-9) and _ (underscore) are accepeted for password");
		      form.old_pwd.focus();
            return false;
		}

	if(form.new_pwd.value=="")
	{
		alert("Please enter new password")
		form.new_pwd.focus();
		return false;
	}

	if(form.new_pwd.value.charAt(0)==" ")
	{
        alert("Please Do Not Enter Blank Spaces For Password !");
		form.new_pwd.focus();
		return false;
	}

		var string_pass = form.new_pwd.value ;
			if(string_pass.search(/^\w+( \w+)?$/) == -1)
		{
			 alert("Only alphabets (A-Z and a-z), digits (0-9) and _ (underscore) are accepeted for password");
		      form.new_pwd.focus();
            return false;
		}

	if(form.confirm_pwd.value=="")
	{
		alert("Please enter confirm password")
		form.confirm_pwd.focus();
		return false;
	}
	if((form.new_pwd.value)!=(form.confirm_pwd.value))
	{
		alert("Password mismatched");
		form.confirm_pwd.focus();
		return false;
	}
	else
	{
		return true;
	}
}

///////////////////////////
  function canhistory(file, idname)
{
	popUp = window.open(file +'?admncanid='+ idname,	'popupFile1', 'width=800,height=750,left=200,top=150,resizable=yes');
}
///////////////////////////
  function Openjobdesc(file, idname)
{
	popUp = window.open(file +'?Jobid='+ idname,	'popupFile1', 'width=800,height=750,left=200,top=150,resizable=yes');
}
////////////////////////////
  function OpenWindow2(file, idname)
{
	popUp = window.open(file +'?Jobid='+ idname,	'popupFile1', 'width=600,height=450,left=200,top=250');
}

function confirmDelete() {
var doc = document.forms[0];
var msg = "Are you sure you want to Delete Record?";
if (confirm(msg)) {
return true ;
doc.submit();
} else {
		return false;
	} }



function ForPrint()
{
 document.all.print.style.visibility = 'hidden';
 window.print();
 document.all.print.style.visibility = 'visible';
 form.TextBox1.focus();
}

function hide(){
document.getElementById('tbemp').style.visibility='hidden';
document.getElementById('tbcan').style.visibility='hidden';
}
function show(){
document.getElementById('tbemployerlogin').style.visibility='visible';
}
function hidetbemp(){
document.getElementById('tbemp').style.visibility='hidden';

}
function hidetbcan(){
document.getElementById('tbcan').style.visibility='hidden';

}


 function ding()
    {

    document.getElementById("ddlcity").options.length=0
                    switch(document.getElementById("ddlCountry").value)
                    {
                    case 'Pakistan':
                       document.getElementById("ddlcity").options[0] = new Option("Karachi","Karachi");
                       document.getElementById("ddlcity").options[1] = new Option("Lahore","Lahore");
                       

                      break;
                    case 'India':
                       document.getElementById("ddlcity").options[0] = new Option("Delhi","Delhi");
                       document.getElementById("ddlcity").options[1] = new Option("Mumbai","Mumbai");
                        document.getElementById("ddlcity").options[2] = new Option("Srinagar","Srinagar");
                      break;
//                    default:
//                   document.getElementById("Se///lect1").options[0] = new Option("","");
//                       document.getElementById("Select1").options[1] = new Option("","");
                    }
                   
     }
     
     function toggleVisibility(controlId)
             {        
                 var control = document.getElementById(controlId);   
                  if(control.style.visibility == "visible" || control.style.visibility == "")
                  control.style.visibility = "hidden";            
                  else                 
                  control.style.visibility = "visible"; 
                  
                  }
       
  
    function show(ele) {
         var srcElement = document.getElementById(ele);
         if(srcElement != null) {
	   if(srcElement.style.display == "block") {
     		  srcElement.style.display= 'none';
   	    }
            else {
                   srcElement.style.display='block';
            }
            return false;
       }
  }
  
          function Openactionattachment(file, idname)
{
	popUp = window.open(file  ,	'popupFile1', 'width=750,height=450,left=150,top=250');
}
     
 function OpenWindow(file, idname, postBack,ProjType)
{
	popUp = window.open(file + '?formname=' + document.forms[0].name +  '&ProjType='+ProjType +
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupFile', 
		'width=600,height=500,left=200,top=250');
}
          function Openhistory(file, idname)
{
	popUp = window.open(file +'?Jobid='+ idname,	'popupFile1', 'width=300,height=250,left=100,top=250');
}

  function Cancvview(file, idname)
{
	popUp = window.open(file +'?Jobid='+ idname,	'popupFile1', 'width=900,height=950,left=100,top=30');
}





 function Canregistration(form)
{
if(form.txtuserid.value == "")
	{
		alert("Please Enter ID");
		form.txtuserid.focus();
		return false;
	}
	if(form.txtname.value == "")
	{
		alert("Please Enter Your Name");
		form.txtname.focus();
		return false;
	}
	if(form.txtdob.value.indexOf("/") == -1 || form.txtdob.value.indexOf("/") == -1 || form.txtdob.value.length < 5)
	{
		alert("Please enter a valid Date Of Birth");
		form.txtdob.focus();
		return false;
	}
	if(form.txtemail.value == "")
	{
		alert("Please enter your email Address");
		form.txtemail.focus();
		return false;
	}
	if(form.txtemail.value.indexOf("@") == -1 || form.txtemail.value.indexOf(".") == -1 || form.txtemail.value.length < 5)
	{
		alert("Please enter a valid Email Address");
		form.txtemail.focus();
		form.txtemail.select();
		return false;
	}
	if(form.txtpwd.value == "")
	{
		alert("Please Enter Password");
		form.txtpwd.focus();
		return false;
	}
		if(form.txtconfirm.value == "")
	{
		alert("Please Enter Confirm Password");
		form.txtconfirm.focus();
		return false;
	}
		if((form.txtpwd.value)!=(form.txtconfirm.value))
	{
		alert("Password Mismatched");
		form.txtconfirm.focus();
		return false;
	}
	else
	{
		return true;
	}	
}

function Employerregistration(form)
{
if(form.txtemail.value == "")
	{
		alert("Please enter your email Address");
		form.txtemail.focus();
		return false;
	}
	if(form.txtemail.value.indexOf("@") == -1 || form.txtemail.value.indexOf(".") == -1 || form.txtemail.value.length < 5)
	{
		alert("Please enter a valid Email Address");
		form.txtemail.focus();
		form.txtemail.select();
		return false;
	}
if(form.txtuserid.value == "")
	{
		alert("Please Enter User ID");
		form.txtuserid.focus();
		return false;
	}
		if(form.txtpwd.value == "")
	{
		alert("Please Enter Password");
		form.txtpwd.focus();
		return false;
	}
		if(form.txtconfirm.value == "")
	{
		alert("Please Enter Confirm Password");
		form.txtconfirm.focus();
		return false;
	}
	if((form.txtpwd.value)!=(form.txtconfirm.value))
	{
		alert("Password mismatched");
		form.txtconfirm.focus();
		return false;
	}
	else
	{
		return true;
	}	
	
	
	if(form.txtcompany.value == "")
	{
		alert("Please Enter Your Name");
		form.txtcompany.focus();
		return false;
	}
	
	

		if(form.txtcompany.value == "")
	{
		alert("Please Enter Your Company Name");
		form.txtcompany.focus();
		return false;
	}	
}

//////////////////////////////////////////////////
/////COMBO BOX

	function txbkd()
	{
		var p = window.event.srcElement.cbx.lst;
		
		if (window.event.keyCode == 9)
		{
			phide(p);
			return true;
		}
		
		if (window.event.keyCode == 13)
		{
			if (p.selectedItem != null)
			{
				p.cbx.txb.value = p.selectedItem.innerText;
				//itemDeselect(p.selectedItem);
				phide(p);
				window.event.returnValue = false;
				window.event.srcElement.select();
				
				__combobox_invokepostback(p.cbx);
					
				return false;
			}
		}
		
		if (window.event.keyCode == 40 || window.event.keyCode == 38)
		{
				if (p.selectedItem != null && p.style.visibility == 'visible')
				{
					var index = p.selectedIndex;
					itemDeselect(p.selectedItem);
					var dir = window.event.keyCode == 40 ? 1 : -1;
					if (index + dir >= 0 && index + dir < p.childNodes.length )
					{
						itemSelect(p.childNodes[index + dir]);
					}
				}
				else
				{
					p.style.visibility = 'visible';
					if (0 < p.childNodes.length)
					{
						itemSelect(p.childNodes[0]);
					}
				}
		}
		else if (window.event.keyCode == 27)
		{
			phide(p);
		}
	}
	
	function itemFocus()
	{
	}
	
	function getSelectedItem(comboBox)
	{
		var cbx = _cbx(comboBox);
		var li = cbx.lst.childNodes;
		for (var i = 0; i < li.length; i++)
			if (li[i].isSelected) return li[i];
	}
	
	function txbku()
	{
		var ev = window.event;
		var e = window.event.srcElement;
		var c = e.cbx;
		var p = c.lst;
		var txt = e.value;
		if (ev.keyCode != 38 && ev.keyCode != 40 && e.keyCode != 37 && ev.keyCode != 39 && ev.keyCode != 9 && ev.keyCode != 13)
		{
			itemDeselect(p.selectedItem);
			if (txt != '' && e.cbx.autocomplete)
			{
				var j = 0;
				if (c.cases)
				{
					for (var i = 0; i < p.items.length; i++) if (p.items[i].indexOf(txt) == 0) j++;
				}
				else
				{
					for (var i = 0; i < p.items.length; i++) if (p.items[i].toLowerCase().indexOf(txt.toLowerCase()) == 0) j++;
				}
				
				var selectedList = new Array(j);
				
				j = 0;
				if (c.cases)
				{
					for (var i = 0; i < p.items.length; i++)
						if (p.items[i].indexOf(txt) == 0)
							selectedList[j++] = p.items[i];
				}
				else
				{
					for (var i = 0; i < p.items.length; i++)
						if (p.items[i].toLowerCase().indexOf(txt.toLowerCase()) == 0)
							selectedList[j++] = p.items[i];
				}
				
				var fireList = (j != 0 ? selectedList : null);
				
				popItems(e.cbx, fireList);
				
				// set the textbox value & selection
				if (((ev.keyCode >= 48 && ev.keyCode <= 57) || (ev.keyCode >= 65 && ev.keyCode <= 90)) && j != 0)
				{
					for (var i = 0; i < p.items.length; i++)
					{
						if ((!c.cases && ((p.items[i].toLowerCase().indexOf(txt.toLowerCase()) == 0))) || (p.items[i].indexOf(txt) == 0))
						{
							e.value = p.items[i];
							var tr = e.createTextRange();
							tr.moveStart('character', txt.length);
							tr.select();
							break;
						}
					}
				}
			}
			else
			{
				popItems(e.cbx, null);
			}
		}
	}
	
	function txblur()
	{
		var e = window.event.srcElement;
		var p = e.cbx.lst;
		var b = e.cbx.btn;
		if (!p.ison && !b.ison)
		{
			phide(p);
			//p.style.visibility = 'hidden';
		}//itemDeselect(p.selectedItem);
		//itemsDeselect(p);
	}
	
	function pmr()
	{
		var d = window.event.srcElement;
		d.ison = true;
	}
	
	function pmt()
	{
		var d = window.event.srcElement;
		d.ison = false;
	}

	function mr()
	{
		itemSelect(window.event.srcElement);
	}
	
	function itemSelect(i)
	{
		if (i != null)
		{
			i.style.backgroundColor = 'buttonshadow';
			i.style.color = 'window';
			
			i.isSelected = true;
			i.parentElement.cbx.lst.ison = true;
			i.parentElement.selectedItem = i;
			i.parentElement.selectedIndex = i.itemIndex;
		}
	}
	
	function itemDeselect(i)
	{
		if (i != null)
		{
			i.style.backgroundColor = 'window';
			i.style.color = 'windowtext';
			
			i.isSelected = false;
			i.parentElement.cbx.lst.ison = false;
			i.parentElement.selectedItem = null;
			i.parentElement.selectedIndex = -1;
		}
	}
	
	function itemsDeselect(p)
	{
		for (var i = 0; i < p.subitems.length; i++)
		{
			itemDeselect(p.childNodes[i]);
		}
	}
	
	function phide(p)
	{
		if (p.style.visibility == 'visible')
			p.style.visibility = 'hidden';
		itemsDeselect(p);
	}
	
	function mt()
	{
		itemDeselect(window.event.srcElement);
	}
	
	function getRealIndex(comboBox)
	{
		var l = comboBox.lst;
		var t = comboBox.txb;
		
		for (i = 0; i < l.items.length; i++)
			if (l.items[i] == t.value)
				return i;
		return -1;
	}
	
	function mc()
	{
		var d = window.event.srcElement;
		var l = d.parentElement;
		var c = l.cbx;
		var t = c.txb;
		
		t.value = d.innerText;
		if (c.autopostback)
		{
			__combobox_postback(c, getRealIndex(c));
		}
		else
		{
			phide(l);
			t.focus();
			t.select();
		}
	}
	
	function _cbx(comboBox)
	{
		return document.getElementById(comboBox);
	}
	
	function clearlst(lst)
	{
		lst.innerHTML = '';
	}
	
	function popItems(comboBox, list, itin)
	{	
		var p = comboBox.lst;
		
		if (itin)
		{
			p.items = list;
		}
		p.subitems = (list == null ? p.items : list);
		
		clearlst(p);
		
		for (var c = 0; c < p.subitems.length; c++)
		{
			var ps = p.style;
			var i = document.createElement('div');
			
			i.id = 'item' + p.childNodes.length;
			
			//if (itin)
				i.itemIndex = c;
			
			i.style.cursor = 'default';
			i.style.whitespace = 'default';
			
			
			i.bgcolor = '#000000';
			i.innerText = p.subitems[c];
			
			i.style.fontFamily =  comboBox.txb.style.fontFamily;
			i.style.fontSize = comboBox.txb.style.fontSize;
			
			i.style.width = isNaN(parseInt(comboBox.txb.style.width, 10)) ? '200px' : comboBox.txb.style.width;
			//i.style.height = '24px';
			
			i.style.verticalAlign = 'middle';
			
			//i.innerHTML = "<table><tr><td valign = 'center'>" + p.subitems[c] + "</td></tr></table>";
			
			i.onmouseover = mr;
			i.onmouseout = mt;
			i.onclick = mc;
			
			p.appendChild(i);
		}
	}
	
	function pstyle(p)
	{
		var ps = p.style;
		ps.position = 'absolute';
		ps.width = p.cbx.style.width;
		var iHeight = p.cbx.offsetHeight - 5;
		ps.height = (p.maxDropDownItems * iHeight) + 2 + 'px';
		
		ps.top = p.cbx.style.position != 'absolute' ? getElementPosition(p.cbx).top + p.cbx.offsetHeight + 2 : p.cbx.offsetHeight + 1;//+ 'px';
	
		ps.border = '1px solid #000000';
		ps.backgroundColor = '#ffffff';
	}

	function getElementPosition(el)
	{
		var c = el, l = 0, t = 0;
		for (; c.offsetParent.offsetParent; c = c.offsetParent)
		{
			l += c.offsetLeft;
			t += c.offsetTop;
		}
		return {left: l, top: t};
	}
	
	function flip()
	{
		var e = window.event.srcElement;
		var t = e.cbx.txb;
		var p = e.cbx.lst;
		var ps = p.style;
		
		if (ps.visibility == 'hidden')
		{
			ps.visibility = 'visible';
			t.focus();
		}
		else
		{
			phide(p);
		}
	}
	
	function __combobox_invokepostback(comboBox)
	{
		if (comboBox.autopostback)
			__combobox_postback(comboBox, getRealIndex(comboBox));
	}
	
	function initCombo(comboBox, _items, apb, autocomplete, cases, maxDropDownItems)
	{
		var e = document.getElementById(comboBox);
		e.lst = e.childNodes[0];
		e.txb = e.childNodes[1].rows[0].cells[0].childNodes[0];
		e.btn = e.childNodes[1].rows[0].cells[1];
		e.btn.cbx = e.lst.cbx = e.txb.cbx = e;
		e.lst.maxDropDownItems = maxDropDownItems;
		
		if (e.autocomplete = autocomplete)
			e.cases = cases;
		
		e.autopostback = apb;
		
		pstyle(e.lst);
		
		popItems(e, _items, true);
	}
	
	function exl()
{
	popUp = window.open('excel.aspx','em','width=800,height=400,left=100,top=50,menubar=0')
	
	return false;

}
