//------Email-Id Validation------------//
function isValidEmail(emailid)
{		
var email=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	return email.test(emailid);
}

// for check all check boxes
function changeSalaryOption(objM, name)
{
	if(name.length==0)
		var obj=document.getElementById("salary_range");
	else
	   var obj=document.getElementById(name);
	objM=document.getElementById(objM);
	FillSalaryOption(objM,obj,"------Select All ------","");
}


function FillSalaryOption(objM,obj,ms1,ms2)
{
	var id=1;
	for(var i=obj.length;i>=0;i--)
	{
		obj.options[i]=null;
	}

	for(var is=1;is<objM.length;is++)
	{
	var ob=objM.options[is];
		if(ob.selected==true)
		{
		for(var i=0;i<js_SalaryOptionArr.length;i++)
			{
			var rePlaceVar=null;
				if(js_SalaryOptionArr[i][0]==ob.value)
				{
			//alert(js_SalaryOptionArr[i][2]);
			rePlaceVar = js_SalaryOptionArr[i][2];
     		rePlaceVar=	rePlaceVar.replace(/&pound;/gi, "\u00A3 ");
		    //alert(rePlaceVar);
			
			obj.options[id]=new Option(rePlaceVar , js_SalaryOptionArr[i][1])
			
			if(js_SalaryOptionArr[i][3]=="selected")
					{
						obj.options[id].selected=true;
					}
					id++;
				}
			}
		}
	}	
	
	if(id>0)
	{
		obj.options[0]=new Option(ms1,ms1);
		obj.style.height="80px";
	}
	else
	{
		obj.options[0]=new Option(ms2,ms2);
		obj.style.height="20px";
	}
}

//var name;
function changeRegion(objM, name)
{
	if(name.length==0)
		var obj=document.getElementById("location_county_id");
	else
	   var obj=document.getElementById(name);
	objM=document.getElementById(objM);
	FillCounty(objM,obj,"------Select All ------","");
}


function changeCareer_Sector(objM, name, sec_id)
{	
	if (sec_id == "")
	{
		sec_id = "sector_position_id";
	}
	if(name.length==0)
		var obj=document.getElementById(sec_id);
	else
	 var obj=document.getElementById(name); 
	/*if(obj==null)
	{
		obj=document.getElementsByName("sector_position_id");
	}*/
	var objM=document.getElementById(objM);
	/*if(objM==null)
	{
		objM=document.getElementsByName(objM);
	}*/
	FillPosition(objM,obj,"------Select All ------","");
}

function FillCounty(objM,obj,ms1,ms2)
{
	var id=0;
	for(var i=obj.length;i>=0;i--)
	{
		obj.options[i]=null;
	}

for(var is=1;is<objM.length;is++)
{
var ob=objM.options[is];
if(ob.selected==true)
{
for(var i=0;i<js_CountyArr.length;i++)
	{
	if(js_CountyArr[i][0]==ob.value)
	{
	if(id==0){
	obj.options[id]=new Option("All","all");
	id++;
	}
			obj.options[id]=new Option(js_CountyArr[i][2],js_CountyArr[i][1])
			if(js_CountyArr[i][3]=="selected")
			{
				obj.options[id].selected=true;
			}
			id++;
		}
	}
}
}	
	
	if(id>0)
	{
		obj.options[0]=new Option(ms1,ms2);
		obj.style.height="100pt";
	}
	else
	{
		obj.options[0]=new Option(ms1,ms2);
		obj.style.height="20px";
	}
}

/** for career sector*****************************/
function FillPosition(objM,obj,ms1,ms2)
{	
	var id=0;
	if(obj.length>0)
	{
		for(var i=obj.length;i>=0;i--)
		{
			obj.options[i]=null;
		}
	}

	for(var is=1;is<objM.length;is++)
	{
		var ob=objM.options[is];
	
		
if(ob.selected==true)
	{
		for(var i=0;i<js_SectorPositionArr.length;i++)
		{
			if(js_SectorPositionArr[i][0]==ob.value)
			{
if(id==0){
obj.options[id]=new Option("All","all");
id++;		
}
	obj.options[id]=new Option(js_SectorPositionArr[i][2],js_SectorPositionArr[i][1]);
		
			if(js_SectorPositionArr[i][3]=="selected"){
					obj.options[id].selected=true;
				}
				id++;
			}
		}
	}
	}	

if(id > 0){
	obj.options[0]=new Option(ms1,ms2);
	obj.style.height="100pt";
}
else{
	obj.options[0]=new Option(ms1,ms2);
	obj.style.height="20px";
}
}

// function  for open a pop window 
var pop='';
function openwin(nm,width,height)
 {
	var name=nm;
	if (pop && !pop.closed) 
		pop.location.href=name;
	else
	{
	pop=eval("window.open('"+name+"','NewWIN','chrome[4],toolbar=no,left=5,top=5,width="+width+",height="+height+",directories=no,menubar=no,SCROLLBARS=yes,left=2,right=2')");
	}
	if (!pop.opener)
	 popUpWin.opener = self;
	if(window.focus) 
		 pop.focus();
}


function openwin1(nm,width,height) {
	var name=nm;
	if (pop && !pop.closed) {
		pop.close();
	}
	pop=eval("window.open('"+name+"','NewWIN1','chrome[4],toolbar=no,width="+width+",height="+height+",left=500,top=200,screenX=200,screenY=100,directories=no,menubar=no,SCROLLBARS=yes,left=2,right=2')");
	if (!pop.opener) popUpWin.opener = self;
}


function openwin2(nm,width,height) {
	var name=nm;
	if (pop && !pop.closed) {
		pop.close();
	}
	
    pop=eval("window.open('"+name+"','newName','chrome[4],directories=no,menubar=no,left=510,top=560,width='+width+',height='+height+',toolbar=0,resizable=0,SCROLLBARS=yes')");
	 if (!pop.opener) popUpWin.opener = child;
}


//  function for check all check box
function checkAll(checked,frm)
{	
	var item1=null;
	item1=frm.items.value;		
	
	if(!(item1))
	{
		for(var i=0;i<frm.items.length;i++)
		  {  
				var e = frm.items[i];
				if(e.type == "checkbox") e.checked = checked;
		  }
	}
	else
	{
		frm.items.checked=checked;
	}	    
}


//  check whether one or more check boxes are checked or not
function check_checkbox(frm)
{
	
	var check=false;
	item1= frm.items.value;		
	if(!(item1))
	{
		for(var i=0;i<frm.items.length;i++)
		  {  
				var e = frm.items[i];
				if(e.type == "checkbox")
				{
						 if(e.checked == true)
						 {
							check=true;
							break;
						 }						
				}	
		  }
	}
	else if(frm.items.checked==true)
		check=true;
		   
	  return check;
}


function check_only_one(frm_name,index,index1,index2)
{
if(index==index1)	
	{	
		 if(frm_name["salary_rate_option"][index2].checked==true)
			frm_name["salary_rate_option"][index2].checked=false;	
	}
else if(index==index2)
	{
		if(frm_name["salary_rate_option"][index1].checked==true)
			frm_name["salary_rate_option"][index1].checked=false;
	}	
			
}
