// Manoj Kr Maurya
// Date : 4th Dec 2002
/**
 * Return Trimed String
 * @author		Manoj Kr Maurya
 * @since       EZR Ver3.2
 */
var ezWindowList=new Array();
function ezTrim(szWhat)
{
	return(szWhat.replace(/^\s*|\s*$/g, ""));
}
/* Return Boolean TRUE or FALSE for a valid email id*/

function ezIsEmailAddress(string)
{
	var addressPattern =/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    return addressPattern.test(ezTrim(string));
}
/* Return Boolean TRUE or FALSE for a valid Leap Year*/
function ezLeapYear(intYear)
{
   if (intYear % 100 == 0)
   {
 	if (intYear % 400 == 0)
	{ 
	   return true;
	}
	}
	else
	{
	   if ((intYear % 4) == 0)
	   {
		return true;
	   }
   }
    return false;
}
/* Return Boolean TRUE or FALSE for a valid Date(mm dd yyyy)*/
function ezIsValidDate(month,day,year)
{
	if (isNaN(year) || isNaN(day) || isNaN(month))
	{
		return false;
	}
	var Vmonth = new Array(12);
	Vmonth[1]=31;Vmonth[2]=ezLeapYear(year)? 29 : 28
	Vmonth[3]=31;Vmonth[4]=30;Vmonth[5]=31;	Vmonth[6]=30;
	Vmonth[7]=31;Vmonth[8]=31;Vmonth[9]=30;Vmonth[10]=31;
	Vmonth[11]=30;Vmonth[12]=31
	if(Vmonth[month]>=day)
	{
		return true;
	}
	else
		return false;
}
function dateDiff(df,dl)
		{
			var dd1=new Date(df)
			var dd2=new Date(dl)
			var Vmonth = new Array(12)
			
			Vmonth[3]=31;Vmonth[4]=30;Vmonth[5]=31;	Vmonth[6]=30;
			Vmonth[7]=31;Vmonth[8]=31;Vmonth[9]=30;Vmonth[10]=31;
			Vmonth[11]=30;Vmonth[12]=31
			d1=dd1.getDate();d2=dd2.getDate();
			m1=dd1.getMonth();m2=dd2.getMonth();
			y1=dd1.getFullYear();y2=dd2.getFullYear();
			Vmonth[1]=31;Vmonth[2]=ezLeapYear(y1)? 29 : 28
			if(d1<d2)
			{
				d1=d1+Vmonth[m1];
				m1--;
			}
			if(m1<m2)
			{
				m1=(m1+12)
				y1--;
			}
			d=d1-d2
			m=m1-m2
			y=y1-y2
			
			return y
		}
		
		
/* Return Boolean TRUE or FALSE for a valid Name ( alpha, space and single quote allows)*/
function ezIsValidNameText(szText)
{
			
	if(ezTrim(szText)=="")
		return false;
	var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '-"
	for(i=0;i<szText.length;i++)
	{
		if(validStr.indexOf(szText.charAt(i))==-1)
		{
			return false;
		}
		
	}
	return true;
}
/* Return Boolean TRUE or FALSE for a valid Password Field only alpha number are allowed*/
function ezValidPass(szText)
{
	if(ezTrim(szText)=="")
		return false;
	var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
	for(i=0;i<szText.length;i++)
	{
		if(validStr.indexOf(szText.charAt(i))==-1)
		{
			return false;
		}
		
	}
	return true;
}
function ezValidZip(szText)
{
	if(ezTrim(szText)=="")
		return false;
	var validStr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890- _"
	for(i=0;i<szText.length;i++)
	{
		if(validStr.indexOf(szText.charAt(i))==-1)
		{
			return false;
		}
		
	}
	return true;
}
			
		
function ezIsValidNumber(szText)
{
	if(ezTrim(szText)=="")
		return false;
	if (isNaN(szText))
		return false
	else
		return true;
}

function ezSelectSelected(obj)
{
	if(obj.selectedIndex!=-1)
		return true;
	else
		return false;
}

function ezSelectSelectValue(obj,strValue)
{
	var i;
	for(i=0;i<obj.length-1;i++)
	{
		if(ezTrim(obj.options[i].value).toUpperCase()==ezTrim(strValue).toUpperCase())
			obj.options[i].selected=true;
			break;
	}
}
function ezSelectSelectText(obj,strText)
{
	var i;
	for(i=0;i<obj.length-1;i++)
	{
		if(ezTrim(obj.options[i].text).toUpperCase()==ezTrim(strValue).toUpperCase())
			obj.options[i].selected=true;
			break;
	}
}

function ezIsRadioChecked(obj)
{
	var i;
	var tot=0;
	if(obj.length)
	{
		for(i=0;i<obj.length;i++)	
			tot=tot+obj[i].checked?1:0;
	
	}
	else
	{
		tot=tot+(obj.checked?1:0);
	}
	if(tot)
		return true;
	else
		return false;
}
function ezIsRadioChecked2(obj)
{
	var i;
	var tot=0;
	var rValue="";
	if(obj.length)
	{
		for(i=0;i<obj.length;i++)	
		{	
			tot=tot+(obj[i].checked?1:0);
			if(obj[i].checked)
			{
				rValue=obj[i].value;
				return rValue;
			}
		}
	}
	else
	{
		tot=tot+(obj.checked?1:0);
		rValue=(obj.checked)?obj.value:"";
	}
	return rValue;
}


/*
 Windows Management Function:
 Like Opening Child Window and Cloasing them when move to another page..
 
*/
function ezOpenWindow(url, target, width, height, resizable, scrollbars, topPos, leftPos)
{
    if (topPos  == null)
    {
        if (screen.availHeight != null)
        {
            topPos = ( (screen.availHeight-height-15) < 0) ? 15 : (screen.availHeight-height-15)/2
        }
        else
        {
            topPos = 15
        }
    }
    if (leftPos  == null)
    {
        if (screen.availWidth != null)
        {
            leftPos = ( (screen.availWidth-width-15) < 0) ? 0 : (screen.availWidth-width-15)/2
        }
        else
        {
            leftPos = 15
        }
    }
    var style = "";
    if (width != null)
        style += "width=" + width + ",";
    if (height != null)
        style += "height=" + height + ",";
    if (resizable != null)
        style += "resizable=" + resizable + ",";
    if (scrollbars != null)
        style += "scrollbars=" + scrollbars + ",";
    if (topPos != null)
        style += "top=" + topPos + ",";
    if (leftPos != null)
        style += "left=" + leftPos + ",";
    popup = window.open(url, target, style + "menubar=no,toolbar=no,directories=no,location=no,status=no");
    if (popup && popup.focus)
    {
        popup.focus();
    }
    ezWindowList[ezWindowList.length] = popup;
    return (popup);
}

function ezOpenWindowWithoutFocus(url, target, width, height, resizable, scrollbars, topPos, leftPos)
{
    if (topPos  == null)
    {
        if (screen.availHeight != null)
        {
            topPos = ( (screen.availHeight-height-15) < 0) ? 15 : (screen.availHeight-height-15)/2
        }
        else
        {
            topPos = 15
        }
    }
    if (leftPos  == null)
    {
        if (screen.availWidth != null)
        {
            leftPos = ( (screen.availWidth-width-15) < 0) ? 0 : (screen.availWidth-width-15)/2
        }
        else
        {
            leftPos = 15
        }
    }
    var style = "";
    if (width != null)
        style += "width=" + width + ",";
    if (height != null)
        style += "height=" + height + ",";
    if (resizable != null)
        style += "resizable=" + resizable + ",";
    if (scrollbars != null)
        style += "scrollbars=" + scrollbars + ",";
    if (topPos != null)
        style += "top=" + topPos + ",";
    if (leftPos != null)
        style += "left=" + leftPos + ",";
    popup = window.open(url, target, style + "menubar=no,toolbar=no,directories=no,location=no,status=no");

    ezWindowList[ezWindowList.length] = popup;
    return (popup);
}
function ezIsChildrenWindowsOpened()
{
    var i = 0;

    while (i < ezWindowList.length &&
          (ezWindowList[i] == null || ezWindowList[i].closed))
    {
        i++;
    }

    if (i != ezWindowList.length)
    {
        return true;
    }

    return false;
}

function ezCloseChildWindow()
{
    for (var i=0; i < ezWindowList.length; i++)
    {
        if (!ezWindowList[i].closed)
        {
            ezWindowList[i].close();
        }
    }
}
function ezCloseWindowReloadOpener()
{
    top.opener.reloadForm();
    top.close();
}

function ezPreviewResume(Resumeid)
{
	ezOpenWindow("../ezr_candidate/ResumePreview.asp?resumeid="+Resumeid,null,700,500,1,1)
}

function ezPreviewResumeAppl()
{
	ezOpenWindow("../ezr_candidate/PresentApplicationPreview.asp",null,700,500,1,1)
}

function ezEmailResume(Resumeid)
{
	ezOpenWindow("../ezr_candidate/EmailResumes.asp?resumeid="+Resumeid,null,600,430,1,1)
}
function ezEmailJob(jobid,compcode,op)
{
	
	ezOpenWindow("../ezr_candidate/EmailJob.asp?op="+op+"&compcode="+compcode+"&Jobid="+jobid,null,600,430,1,1)
}
function ezPreviewJob(jobid)
{
	
	//url, target, width, height, resizable, scrollbars, topPos, leftPos)
	ezOpenWindow("../ezr_candidate/jobinfoscreen.asp?jobid="+jobid,"ezJob",600,450,1,1)
}
function ezPreviewJob2(jobid,compcode)
{
	//url, target, width, height, resizable, scrollbars, topPos, leftPos)
	ezOpenWindow("../ezr_candidate/jobinfoscreen.asp?compcode="+compcode+"&jobid="+jobid,"ezJob",600,400,1,1)
}
try{
	window.attachEvent("onload",doOnLoad)
}catch(e)
{
	
	window.document.addEventListener('load', doOnLoad, false);
	
}
//window.onload=doOnLoad
function doOnLoad()
{
	//alert("here")
	//winTracker();
	objList=document.getElementsByTagName("A")
	for(i=0;i<objList.length;i++)
	{
		objList[i].onmouseover=doOver
	}
	objList=document.getElementsByTagName("a")
	for(i=0;i<objList.length;i++)
	{
		objList[i].onmouseover=doOver
		objList[i].onmouseout=doOut
	}
	//objList=document.getElementsByTagName("area")
	//alert(objList.length)
	//for(i=0;i<objList.length;i++)
	//{
	//	objList[i].onmouseover=doMenuOver
	//	objList[i].onmouseout=doMenuOut
	//}
	
}
function doOut()
{
	window.status=""
	return true;
}
function doMenuOver()
{
	//window.status="hello"
	//event.cancelBubble=false;
	//return false;
	
}
function doMenuOut()
{
	//window.status=""
	//return true;
	
}
function doOver()
{
	
	/*
	var w=this.innerHTML;
	if(w.indexOf("logout")>1)
	{
		window.status='Log Out'
		return true;
	}
	else
	{
		window.status=this.innerHTML
		return true;
	}
	*/
}
function confirmLogout()
{
	if(confirm("Are you sure?"))
	{
		location.href="../ezr_login/cLogout.asp"
	}
	else
		return;
}


// For Job type selection
//--------------------------------------------------------------------
// CBAny - Un-checks All the checkboxs in the given list
// CBName - Name of the checkbox; AnyPosition - Position of the Any checkbox;
function CBAny(CBName, AnyPosition)
{		
	var CBName = document.getElementsByName(CBName)		
	if (CBName[AnyPosition].checked)
	{
		len=CBName.length;
		if(len==null)
			CBName.checked=false;
		else
		{
			for(i=0;i<len;i++)
				CBName[i].checked=false;
		}	
		CBName[AnyPosition].checked = true;
	}
}
//--------------------------------------------------------------------

// CBAnyOne - Un-checks 'Any' checkbox in the given list
// CBTotal - Number of 'CBName' checkboxs
function CBAnyOne(CBName, AnyPosition, CBTotal)
{		
	var CBName = document.getElementsByName(CBName)
	CBName[AnyPosition].checked = false;
	
	var CBCheckedCount = 0;
	for(i=0;i<=CBTotal;i++)
	{
		if (CBName[i].checked)
			CBCheckedCount++;
	}
	
	// If all other check boxs are checked, the 'Any' is checked, unchecking others
	if (CBCheckedCount == CBTotal)
	{
		for(i=0;i<=CBCheckedCount;i++)
			CBName[i].checked=false;
		CBName[AnyPosition].checked = true;		
	}	
	
}
//--------------------------------------------------------------------

function ezSetCookie(name,value,expires,domain,path,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function ezGetCookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function ezDeleteCookie(name, path, domain){
	if(Get_Cookie(name)){
		document.cookie = name+ "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain: "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

expires = new Date();
expires.setTime(expires.getTime() + (365 * 24 * 60 * 60 * 1000));
 