﻿var windowStatusHeight = 50;
var isIEsp2 = (window.navigator.userAgent.indexOf("SV1") != -1 && window.navigator.userAgent.indexOf("MSIE") != -1 ); 
var isExplorer = (typeof(document.all)=='undefined')?false:true
var SupportedBrowsers = new Array(new Array('MSIE','5.5','Explorer'),new Array('Netscape','7.1','Netscape'), new Array('Safari','125.1','Safari'), new Array('Firefox','1.0','Firefox'));
var frameWork = self

var x = 0;
var y = 0;
var scrollX = 0;
var scrollY = 0;
var DivWidth = 0;
var DivHeight = 0;
var MarginWidth = 0;
var MarginHeight = 0;

function InitDiv( )
{
	frameWork.document.onmousemove = mouseMove2;
}

function mouseMove2(e)
{
	if(typeof(frameWork)=='undefined')return
	if (frameWork.document.all) //Is Explorer
	{
		scrollX = frameWork.document.body.scrollLeft;
	  	scrollY = frameWork.document.body.scrollTop;
	  	x = frameWork.event.x + scrollX; 
	  	y = frameWork.event.y + scrollY;  
	}
	else
	{
	  	x = e.pageX; 
	  	y = e.pageY;  
	}    
}

function WriteHTML(DivName, html)
{
	getObj(DivName).innerHTML =html;
}

function ShowDiv(DivName)
{
	HideDiv(DivName)

	DivHeight = frameWork.document.getElementById('myTable').scrollHeight;
	WinWidth = frameWork.document.body.clientWidth;
	WinHeight = frameWork.document.body.clientHeight;
	
	if (( x + frameWork.document.getElementById('myTable').scrollWidth ) > WinWidth) 
		x -= (frameWork.document.getElementById('myTable').scrollWidth + MarginWidth);
	else 
		x += MarginWidth;
 
	if (( y - scrollY + DivHeight) > WinHeight)
		{
		 if (y - scrollY < DivHeight) 
			y = scrollY + WinHeight-DivHeight;
		 else 
			y -= (DivHeight + MarginHeight);
		} 
	else 
		y += MarginHeight;

	getObj(DivName).style.top = y + 'px';
	getObj(DivName).style.left = x + 'px';
	getObj(DivName).style.visibility = "visible"
}

function HideDiv(DivName)
{
	getObj(DivName).style.visibility = "hidden"	
}

function getObj( ObjName, tmpFrameWork )
{
	var framwWrk = (typeof(tmpFrameWork)=='undefined' || tmpFrameWork==null)?frameWork:tmpFrameWork
	return framwWrk.document.getElementById(ObjName)
}

function getObjA( ObjName, tmpFrameWork )
{
	var framwWrk = (typeof(tmpFrameWork)=='undefined' || tmpFrameWork==null)?frameWork:tmpFrameWork
	var returnTable=new Array();
		
	if (isExplorer)
	{
		if(framwWrk.document.getElementsByName(ObjName).length == 1)
			returnTable[0] = framwWrk.document.all[ObjName];
		else
			returnTable = framwWrk.document.all[ObjName];
	}
	else
	{
		returnTable=framwWrk.document.getElementsByName(ObjName);
	}
	return returnTable;	
}

function changeImage(imgName, imgSrc)
{
 if (frameWork.document.images)
  frameWork.document.images[imgName].src = imgSrc.src;
}

function changeImageDiv(imgName, imgSrc, divID)
{
 frameWork.document.images[imgName].src = imgSrc.src;
}

function ConfirmAlert(msgAlert)
{
	alert(msgAlert)
}

function CheckString(strParam, strChars)
{
	for(i=0;i<strParam.length;i++)
	{
		if (strChars.indexOf(strParam.substring(i,i+1))==-1)
			{
			return false;
			}
	}
	return true;
}

function CheckUserName(strParam)
{
	var strChars;
	strChars = 'abcdefghijklmnopqrstuvwxyz';
	strChars += strChars.toUpperCase() ;
	strChars += '1234567890';
	strChars += '_@.-';

	return ( CheckString(strParam, strChars) );
}

function CheckPassword(strParam)
{
	var strChars;
	strChars = 'abcdefghijklmnopqrstuvwxyz';
	strChars += strChars.toUpperCase() ;
	strChars += '1234567890';
	strChars += '_@.-';

	return ( CheckString(strParam, strChars) );
}

function CheckEmail(item)
{
	var strChars;
	strChars = 'abcdefghijklmnopqrstuvwxyz-';
	strChars += strChars.toUpperCase() ;
	strChars += '1234567890';
	strChars += '_@.-';
	var returnValue = CheckString(item, strChars);

	if (
	    (item.length == 0)
		 ||	(item.indexOf('@') < 1) 
		 || (item.indexOf(',') != -1)
		 || (item.indexOf(' ') != -1)
		 || (item.indexOf("'") != -1)
		 || (item.length - item.lastIndexOf('.') < 2) 
		 || (item.length - item.lastIndexOf('.') > 5)
		 || (item.lastIndexOf('.') - item.indexOf('@') < 2)
		) returnValue = false;
	return returnValue;
}	

function CheckFloat( item )
{
 var returnValue = true;
 var firstCommaPos = -1;
 numbers = "0123456789.,";
 for (var i = 0 ; i < item.length; i++)
 {
  c = item.substring(i , i+1);
  if ( numbers.indexOf( c ) < 0 ) returnValue = false;
	if ( c == ',' )
		if ( firstCommaPos <0 )
			firstCommaPos = i;
		else
			returnValue = false;
 }
 return returnValue;
}

function CheckPhone(item)
{
 var returnValue = true;
 numbers = "0123456789-";
 for (var i = 0 ; i < item.length; i++)
 {
  c = item.substring(i , i+1);
  if (numbers.indexOf(c) < 0) returnValue = false;
 }
 return returnValue;
}

function SalaryRange(floatSalary)
{
	if(CheckNumeric(parent.estimatedValue))
		{
			if(parent.estimatedValue * 25/100 < floatSalary && parent.estimatedValue * 250/100 > floatSalary)
				return true;
			else
				return false;
		}
	else
		return true;
}

function CleanCommma()
{
	var c,i;
	c = '';
	for(i=0;i<document.theForm.salary.value.length;i++)
		if(document.theForm.salary.value.substring(i,i+1)!=',')
			c+= document.theForm.salary.value.substring(i,i+1)
				
	document.theForm.salary.value = c;
}

function CheckNumeric(item)
{
 var returnValue = true;
 numbers = "0123456789";
 for (var i = 0 ; i < item.length; i++)
 {
  c = item.substring(i , i+1);
  if (numbers.indexOf(c) < 0) returnValue = false;
 }
 return returnValue;
}

function ChangePassword()
{
 window.open("change_password.html","ChangePassword","toolbars=0,manubar=0,scrollbars=1,directories=0,location=0,resizable=1,width=450,height=250,left=30,top=70");
}

function writeParam( name )
{
	while( parent.frames[0].document.forms.length == 0 );
	document.write( eval( 'parent.frames[0].document.forms[0].' + name + '.value' ) );
}

function Unsubscribe()
	{
	window.open("c.asp?action=employee.Unsubscribe.init" ,"Unsubscribe","toolbars=0,manubar=0,scrollbars=0,directories=0,location=0,resizable=0,width=240,height=130,left=30,top=70");	
	}
function CancelApplySubscription(){	window.open("c.asp?action=employee.Unsubscribe.CancelApplySubscription" ,"CancelSubscription","toolbars=0,manubar=0,scrollbars=0,directories=0,location=0,resizable=0,width=240,height=130,left=30,top=70");	}
function goToPage( page, target, alertForModifications ,HaveSkills)
{
	checkIfRematch( page )
	/*if(page.substring(9,23)=='jobPreferences' && HaveSkills==0) 
		{
		alert('Please note! In order for us to match you with positions, you need to fill out the "My Profile" tab.\n Preferences alone are not sufficient to provide you with our unique position matching services.')
		return;
		}*/
	
	if( typeof( alertForModifications ) != 'undefined' )
		if( alertForModifications )
		{
			if (!confirm( 'Save button was not clicked. Would you like to exit without saving?' ))
				return;
			else
				pageTouched = false;
		}

	if(parent.name=='redmatchWindow') target = 'window.name'

	document.forms['hiddenForm'].action = "c.asp?action=" + page + "";
	if( target != "" ) eval( "document.forms['hiddenForm'].target = " + target + ";" );
	document.forms['hiddenForm'].submit();
}

function escapeXML( szXML )
{
	var szReturn = '';
	var startIndex = 0;
	var endIndex = 0;
	
	while( szXML.indexOf( '&', startIndex ) != -1 )
	{
		endIndex = szXML.indexOf( '&', startIndex ) + 1;
		szReturn += szXML.substring( startIndex, endIndex ).replace( '&', '&amp;' );
		startIndex = endIndex;
	}
	szReturn += szXML.substr( startIndex );
	
	while( szReturn.indexOf( '<' ) != -1 )
		szReturn = szReturn.replace( '<', '&lt;' );
	while( szReturn.indexOf( '>' ) != -1 )
		szReturn = szReturn.replace( '>', '&gt;' );
	while( szReturn.indexOf( '"' ) != -1 )
		szReturn = szReturn.replace( '"', '&quot;' );
	while( szReturn.indexOf( "\'" ) != -1 )
		szReturn = szReturn.replace( "'", "&apos;" );
		
	return szReturn;
}

function ReplaceCharacters( szXML ){
	var szReturn = szXML;

	while( szReturn.indexOf( '&amp;' ) != -1 )
		szReturn = szReturn.replace( "&amp;", "&" );
	while( szReturn.indexOf( '&lt;' ) != -1 )
		szReturn = szReturn.replace( "&lt;", "<" );
	while( szReturn.indexOf( '&gt;' ) != -1 )
		szReturn = szReturn.replace( "&gt;", ">" );

	return szReturn;
}
function goToSatatic(page)
{
	window.open(page,"StaticPage","toolbars=0,manubar=0,scrollbars=1,directories=0,location=0,resizable=1,width=600,height=530,left=30,top=1");
}	

function goToHelp(page)
{
	var strURL = '../userManual/'
	var strProperties = "fullscreen=yes,resizable=1,scrollbars=1,manubar=1,toolbars=1"

	if(page=='ShortHelp')
		{

			strURL = strURL + "?Nav=0"		
			strProperties = "toolbars=0,manubar=0,scrollbars=1,directories=0,location=0,resizable=1,width=800,height=500,left=30,top=1"
		}

	window.open(strURL,"UserManual",strProperties);
}		
function goToContactUs( nr, alertForModifications, lAffiliateID )
{
	var userId = '';
	var AffiliateID = lAffiliateID
	if(typeof( document.hiddenForm ) != 'undefined') {
		if(typeof( document.hiddenForm.userId ) != 'undefined')
			userId = document.hiddenForm.userId.value
		if(typeof( document.hiddenForm.AffiliateID ) != 'undefined')
			AffiliateID = document.hiddenForm.AffiliateID.value
	}		
			
	if( typeof( alertForModifications ) != 'undefined' )
		if( alertForModifications )
		{
			if (!confirm( 'Save button was not clicked. Would you like to exit without saving?' ))
				return;
			else
				pageTouched = false;
		}

	window.open("c.asp?action=employee.contactUs.init&userId=" + userId + "&nr=" + nr + "&AffiliateID=" + AffiliateID,"contactUs","toolbars=0,manubar=0,scrollbars=1,directories=0,location=0,resizable=1,width=600,height=530,left=30,top=1");
}

function recommend( nr, alertForModifications ,AffiliateID)
{
	if( typeof( alertForModifications ) != 'undefined' )
		if( alertForModifications )
		{
			if (!confirm( 'Save button was not clicked. Would you like to exit without saving?' ))
				return;
			else
				pageTouched = false;
		}

	window.open("c.asp?action=employee.recommend.init&AffiliateID=" + AffiliateID + "&nr=" + nr,"recommend","toolbars=0,manubar=0,scrollbars=1,directories=0,location=0,resizable=1,width=600,height=450,left=30,top=70");
}

function goToHome( loc, alertForModifications )
{
	if( typeof( alertForModifications ) != 'undefined' )
		if( alertForModifications )
		{
			if (!confirm( 'Save button was not clicked. Would you like to exit without saving?' ))
				return;
			else
				pageTouched = false;
		}

	host_hompage()
}

function goToPageSimple( loc, nr, page, alertForModifications )
{
	if( typeof( alertForModifications ) != 'undefined' )
		if( alertForModifications )
		{
			if (!confirm( 'Save button was not clicked. Would you like to exit without saving?'))
				return;
			else
				pageTouched = false;
		}

	eval( loc + '.location.href = "../employee/' + page + '.html?nr=' + nr + '"' );
}

function forgotPassword( nr )
{
	window.open("c.asp?action=employee.forgotPassword.init&nr=" + nr,"forgotPassword","toolbars=0,manubar=0,scrollbars=1,directories=0,location=0,resizable=1,width=600,height=330,left=30,top=70");
}

function randomizeImage( )
{
		document.randomImage.src = drawImage("../images/ban/random" + Math.ceil( Math.random() * 5 ) + ".gif");
}

function yearInRange(yearValue)
{
 var returnValue = true;
 var crtDate = new Date();
	if ( !CheckNumeric( yearValue ) )
	{
		returnValue = false;
	}
	else
	{
		if ( ( ( crtDate.getFullYear( ) - parseInt( yearValue ) ) > 100 ) || ( ( crtDate.getFullYear( ) - parseInt( yearValue ) ) < 15 ) )
			returnValue = false;
	}
 return returnValue;
}

function cutSpaces( inString )
{
	var i = inString.toString().indexOf( ' ' );
	while ( i >= 0 )
		return( cutSpaces( inString.substring( 0, i ) + inString.substring( i + 1 ) ) );
		
	return  inString;
}

function getCommaFormattedNumber( inValue, commaString )
{
	return inValue;
	
	oldValue = inValue;
	inValue = cutSpaces( inValue );
	if ( isNaN( inValue ) )
		return oldValue;
	else
	{
		if ( inValue.toString().length < 3 )
			return inValue;
		else
		{
			var szValue = new String( '' );
			for ( var i = inValue.toString().length - 1; i > 0 ; i-- )
			{
				//alert( typeof (inValue.toString().charAt( i ).toString()) );
				szValue = inValue.toString().charAt( i ).toString().concat( szValue );
				if ( ( inValue.toString().length - i ) % 3 == 0 )
					szValue = commaString + szValue;
			}
			szValue = inValue.toString().charAt( 0 ) + szValue.toString();
			return szValue
		}
	}
}

function help( whichFlash )
{
  window.open( parent.FlashPath + "/flash/" + whichFlash + ".html","help","toolbars=0,manubar=0,scrollbars=1,directories=0,location=0,resizable=1,width=975,height=600,left=30,top=70");
}

function rematch()
{
	if (typeof(doRematch)!='undefined' && doRematch == 1)
		window.open( "c.asp?action=employee.rematch.init&UserId=" + document.hiddenForm.userId.value,"rematchFrame","toolbars=0,manubar=0,scrollbars=0,directories=0,location=0,resizable=0,width=1,height=1,left=0,top=0");	
}

function checkIfRematch( page )
{
	var str = page.toLowerCase()	
	var check_myProfile = str.lastIndexOf( 'myProfile'.toLowerCase() )
	var check_myProfileResume = str.lastIndexOf( 'myProfileResume'.toLowerCase() )
	var check_myCareer = str.lastIndexOf( 'myCareer'.toLowerCase() )
	var check_jobPreferences = str.lastIndexOf( 'jobPreferences'.toLowerCase() )

	if ( ( check_myProfile > -1 || check_jobPreferences > -1 || check_myCareer > -1) &&
				check_myProfileResume == -1	)
		doRematch = 0
}

function cleanNumber( num )
{
	for ( i = num.length -1; i >= 0; i-- )
		if ( num.substring(i , i+1) == ',' && ((num.length-1) - i) < 3 )
		{
			num = num.substring(0 , i);
			i = -1;
		}

	for ( i = 0; i < num.length; i++ )
		num = (num.replace(",","")).replace(".","")
			
	return num
}

function trim(value)
{
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = / +/g;
   temp = temp.replace(obj, " ");
   if (temp == " ") { temp = ""; }
   return temp;
}

function ltrim( szJS ){
	var i;
	var c;
	for( i = 0; i < szJS.length; i ++  ){
		c = szJS.substring( i, i + 1 );
		if( c != ' ' )
			break;
	}
	return szJS.substr( i );
}

function Employer()
{
	window.open('../employee/Employer.htm' , "SalarySurvey","menubar=no,width=500,height=100,top=200,left=200,scrollbars=No,resizable=no, directories=0, status=0, toolbar=0, location=0");
}

function InfoPopup(sSubject, sContent)
{
	window.open('../employee/InfoPopup.asp?Subject=' + sSubject + '&Content=' + sContent, "InfoPopup","menubar=no,width=500,height=400,top=200,left=200,scrollbars=No,resizable=no, directories=0, status=0, toolbar=0, location=0");
}

function getInnerText(el,Index)
{
	if(isExplorer)
		return el.innerText
	else
	{
		try
		{
			return el.childNodes[Index].nodeValue;
		}
		catch(e)
		{
			return '';
		}
	}
}

function getAttributeText(el,att)
{
	return document.getElementById(el).getAttribute(att)
}

function ShrinkPopup(obj)
{
	
	if(typeof(obj)=='undefined')
		obj=document
	
	if(obj.all)
	{
		if (obj.getElementById('tblObj').offsetHeight < obj.body.clientHeight) 
		{
			obj.body.scroll = 'no';
			window.resizeTo(obj.body.clientWidth+12, obj.getElementById('tblObj').offsetHeight+70);
		}
	}
	else
	{
		if (obj.getElementById('tblObj').offsetHeight < window.innerHeight) 
		{
			obj.body.scroll = 'no';
			window.resizeTo(obj.body.clientWidth+12, obj.getElementById('tblObj').offsetHeight+70);
		}
	}
}
function ShrinkPopup1(obj)
{
	
	if(typeof(obj)=='undefined')
		obj=document
	
	if(obj.all)
	{
		if (obj.getElementById('Content').offsetHeight < obj.body.clientHeight) 
		{
			obj.body.scroll = 'no';
			window.resizeTo(obj.body.clientWidth+12, obj.getElementById('Content').offsetHeight+70);
		}
	}
	else
	{
		if (obj.getElementById('Content').offsetHeight < window.innerHeight) 
		{
			obj.body.scroll = 'no';
			window.resizeTo(obj.body.clientWidth+12, obj.getElementById('Content').offsetHeight+70);
		}
	}
}

function ShrinkLogo( imgName, imgHeight )
{
	if(getObj(imgName)!=null && getObj(imgName).height > imgHeight)
		getObj(imgName).height = imgHeight
}
function ShrinkLogoW( imgName, imgWidth )
{
	if(getObj(imgName)!=null && getObj(imgName).width >imgWidth)
		getObj(imgName).width = imgWidth
}

function ShrinkComanyLogo( imgName, imgHeight, imgWidth){
	if (getObj(imgName)==null)
		return;
	if(getObj(imgName).height > imgHeight || getObj(imgName).width > imgWidth) {
		var k = (imgHeight / getObj(imgName).height > imgWidth / getObj(imgName).width) ? imgWidth / getObj(imgName).width : imgHeight / getObj(imgName).height;
		if (imgHeight / getObj(imgName).height > imgWidth / getObj(imgName).width) 
			getObj(imgName).width = getObj(imgName).width * k
		else 
			getObj(imgName).height = getObj(imgName).height * k
	}	
}
function serverURLEncode(szURL)
{
	if(typeof(szURL) == 'object') return szURL
	var tmpURL = ''
	for(var i=0; i< szURL.length; i++)
	{
		if(szURL.substring( i, i+1 ) == '&')
			tmpURL+='%26'
		else if(szURL.substring( i, i+1 ) == '+')
			tmpURL+='%2B'
		else if(szURL.substring( i, i+1 ) == ' ')
			tmpURL+='%20'
		else if(szURL.substring( i, i+1 ) == '%')
			tmpURL+='%25'
		else if(szURL.substring( i, i+1 ) == "'")
			tmpURL+='%27'
		else if(szURL.substring( i, i+1 ) == '"')
			tmpURL+='%22'
		else
			tmpURL+=szURL.substring( i, i+1 )
	}
	
	return tmpURL;
	
}	
function addOption( objSelect, arrayElement )
{
	if( document.all )
	{
		objSelect.options.length ++;
		objSelect.options[ objSelect.options.length -1 ].value = arrayElement[ 0 ];
		objSelect.options[ objSelect.options.length -1 ].text = arrayElement[ 1 ];
		if(typeof(arrayElement[ 2 ]) != 'undefined')
			objSelect.options[ objSelect.options.length -1 ].id = arrayElement[ 2 ];
	}
	else
		objSelect.options[ objSelect.options.length ] = new Option( arrayElement[ 1 ], arrayElement[ 0 ] );

	return true
}

function populateSelect( objSelect, varArray, selectedValue )
{
	for( var i=0;i<varArray.length;i++ )
	{
		addOption( objSelect, varArray[ i ] )
		if (typeof(selectedValue)!='undefined' && selectedValue!= '' && selectedValue==varArray[i][0])
			objSelect.options[ objSelect.options.length -1 ].selected = true;
	}

	return true;
}

function addOptionCities( objSelect, arrayElement,fictitiousCity){

		objSelect.options.length += 1;
		objSelect.options[ objSelect.options.length - 1 ].value = arrayElement[0];
		objSelect.options[ objSelect.options.length - 1 ].text = arrayElement[1];
		objSelect.options[ objSelect.options.length - 1 ].fictitiousCity = fictitiousCity;
		return true
}
function populateSelectCities( objSelect, varArray,fictitiousID,fictitiousDesc ){

		objSelect.length = 0;
		
		objSelect.options.length += 1;
		objSelect.options[ objSelect.options.length - 1 ].value = -1;
		objSelect.options[ objSelect.options.length - 1 ].text = '---------------- Select ---------------';		
		
		for( var i=0;i<varArray.length;i++ )
			if (varArray[i][0] == fictitiousID && varArray[i][1] == fictitiousDesc)
			    addOptionCities( objSelect, varArray[ i ],1)
			else
				addOptionCities( objSelect, varArray[ i ],0 )    
		return true;
}


function addAffiliateDefaultCity(iCity,sCity)
{
			if (sCity == '')
				return;

			var selected = null;
			var ii = null;			
			for ( ii = 0 ; ii < cities.length ; ii++ )	
			{
				if( cities[ii][0] == iCity && cities[ii][1] != sCity ) {
					selected = ii 
					break;
				}	
			}
			
			if(selected==null)
				return
			
			cities[cities.length] = new Array(0,'0',0)
			for ( ii = cities.length-1 ; ii > selected ; ii-- ) {
				cities[ii][0] = cities[ii-1][0];
				cities[ii][1] = cities[ii-1][1];
				cities[ii][2] = cities[ii-1][2];
			}
			
			cities[selected][0] = iCity;
			cities[selected][1] = sCity;
			cities[selected][2] = 1;
}

function setAffiliateExternalLocations()
{
	var tmpCities = new Array();
	var IsExists;
	if(AffiliateLocations.length>0)
		{
		for(var i=0; i<AffiliateLocations.length; i++)
			tmpCities[tmpCities.length] = AffiliateLocations[i];

		tmpCities[tmpCities.length] = new Array(-1,'------ Other Locations ---------',1);
		}
		
	for(i=0; i<cities.length; i++)
	{
		IsExists = false;
		for(var j=1; j<AffiliateLocations.length; j++)
			if(cities[i][0] == AffiliateLocations[j][0])
				{
				IsExists = true;				
				break;
				}
		if(!IsExists)
			tmpCities[tmpCities.length] = cities[i];
	}			

	return tmpCities;
}

function formatDateFromDB( varDateLong )
{
	var varDate ;
	var varDateDay;
	var varDateMonth;
	var varDateYear;
	if( varDateLong != '' )
	{
		varDateDay = varDateLong.substring( 8, 10 );
		varDateMonth = varDateLong.substring( 5, 7 );
		varDateYear = varDateLong.substring( 0, 4 );
		varDate = varDateYear + varDateMonth + varDateDay;
	}
	  
	return( toCustomDate(varDate) );
}

function toCustomDate( dateAsYYYYMMDD )
{
	if( dateAsYYYYMMDD == '' || dateAsYYYYMMDD == notAvailableString )
		return( notAvailableString );

	var year = dateAsYYYYMMDD.substring( 0, 4 );
	var month = dateAsYYYYMMDD.substring( 4, 6 ) - 1;
	var day = dateAsYYYYMMDD.substring( 6, 8 );

	return ( formatDate( new Date( year , month , day ),window.CalendarPopup_dateFormat ) );
}
function checkItemsLimit(obj,Itemslimit)
{	
	
	if (Itemslimit == '') return false
	ItemsCounter = obj.length;			
	if (obj.length  >= Itemslimit)
	{
		alert('You can only add ' + Itemslimit + ' items.')
		return true
	}
		else
		return false		
}

function checkPopUpItemsLimit(obj,ItemsCounter,Itemslimit)
{	
	if (Itemslimit == '') return false
	if (ItemsCounter + obj.length  > Itemslimit)
	{
		alert('You can only add ' + Itemslimit + ' items.')
		return true
	}
		else
		return false				
}


function CheckOnLineCompany(userId,isSendApply,CompanyTypeId,IsOnlineUser,NotAlert)
{	
	if( (isSendApply == 0 && CompanyTypeId == 4) || (isSendApply == 0 && CompanyTypeId != 4 && IsOnlineUser == 0))
	{		
		if (typeof(NotAlert) != 'undefined' && NotAlert == true) return false
		if (userId == '')
		{			
			if (!confirm('This employer has not set an E-mail or fax number for online applications. Therefore, applications cannot be submitted online. You are welcome, however, to continue and register by entering you anonymous profile and work preference. Having a registered account will entitle you to view all your job matches and to use a variety of attractive career management tools. Hit OK to continue to Registration or CANCEL to return.')) 
			    return false	
			if (typeof(opener) == 'undefined')			
			   goToPage('employee.home.writeHTML&bodyDesign=0&InstructionStyle=1&whichHome=2&BackgroundStyle=0&whereToGoWhenFinishRegistration=employee.myCareer.init',"'_parent'" );	
			else
			{
			   opener.goToPage('employee.home.writeHTML&bodyDesign=0&InstructionStyle=1&whichHome=2&BackgroundStyle=0&whereToGoWhenFinishRegistration=employee.myCareer.init',"'_parent'" );				
			   window.close()
			}
		}	
		else		
			alert('This employer has not set an E-mail or fax number for online applications. Therefore, applications cannot be submitted online. You are welcome, however, to apply using the contact information in the ad.')			 

			return	false
	}
	
	return true

}

function windowRezise( WinWidth, WinHeight,isSetLocation )
{
	WinHeight += (isIEsp2)?windowStatusHeight:0

	var xPos = ( screen.width - WinWidth ) /2
	var yPos = ( screen.height - WinHeight ) / 2

	if(isSetLocation)
		parent.window.moveTo( xPos, yPos )
	parent.window.resizeTo(WinWidth,WinHeight);
}

function ConfirmationBox(Title,msgStr,icon)
{
	try
	{
		makeMsgBox(Title,msgStr,icon,0,0,4096);	
	}
	catch(e)
	{			
		alert(msgStr)
	}
}

function ApplyFromPosDesc(PositionId,AlreadyMatched,winName)
{	 

	if(getObj('Pos' + PositionId).getAttribute('isApplied') == '1')
	{
		alert('You have already applied for this job.')
		return
	}

	 if(AlreadyMatched == 1)
		{
			alert('You have already applied for this job.')
			return
		}
			try
			{	
				document.hiddenForm.Managerial.value =document.theForm.Managerial.value
				document.hiddenForm.City.value = document.theForm.City.value
				document.hiddenForm.Field.value =document.theForm.Field.value
				document.hiddenForm.keyword.value = document.theForm.keyword.value
			}
			catch(e)	
			{
			}
	
			if(document.theForm.NoBackground.value==1)
			{			
				document.hiddenForm.compPosId.value = PositionId
				goToPage( 'employee.communicate.init&isApply=1&isExternalApply=1&positionId=' + PositionId, "'_parent'" );
						
			}
			else
			{							
				document.hiddenForm.compPosId.value = PositionId				
				var page='employee.communicate.init&isApply=1&positionId=' + PositionId
				checkIfRematch( page )
				document.forms['hiddenForm'].action = "c.asp?action=" + page + "";
				document.hiddenForm.target=winName
				document.forms['hiddenForm'].submit();
			}
}

function BuildCVHTML(FileServer,NumOfPages,FileName,AffiliateId,CanAffiliateId)
{
	var Path = '';
	var sHTML = '';
	var PreResumePath = FileName.split("_")[0];
	PreResumePath = PreResumePath.substring(PreResumePath.length - 3);
										
	sHTML +='<table width="100%" cellpadding="0" cellspacing="0" border="0">'				
	for (i=0;i<NumOfPages;i++)
	{					
		if (i > 0)											
			Path = "http://" + FileServer + '/Resumes/' + CanAffiliateId + '/' + PreResumePath + '/' + FileName + '/original/' + FileName + '(' + i + ')' + '.gif'													
		else
		    Path = "http://" + FileServer + '/Resumes/' + CanAffiliateId + '/' + PreResumePath + '/' + FileName + '/original/' + FileName + '.gif'													
					   
					    
		sHTML +='<tr>'
		sHTML +='<td><img src="' + Path + '"/></td>'
		sHTML +='</tr>'
	}	
	sHTML +='</table>' 	
	
	return sHTML;	
}

function WriteSourceId(SourceId){		if (typeof(SourceId) != 'undefined' && SourceId !='')	{				setCookie("RM_SourceId",SourceId)	}	}

function setCookie(name, value, expires, path, domain, secure)
{
	/*
		name - name of the cookie
		value - value of the cookie
		[expires] - expiration date of the cookie (defaults to end of current session)
		[path] - path for which the cookie is valid (defaults to path of calling document)
		[domain] - domain for which the cookie is valid (defaults to domain of calling document)
		[secure] - Boolean value indicating if the cookie transmission requires a secure transmission
	*/

	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie(name)
{
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function MoveSelectedItem(SourceObj,DestObj,isMulti)
{
	var i;
	
	if(SourceObj.selectedIndex != -1)
	{
		if(isMulti)
		{
			for(i=0; i < SourceObj.length; i++)
			{
				if(SourceObj.options[i].selected == true)
				{
					DestObj.options.length++
					DestObj.options[DestObj.options.length-1].value = SourceObj.options[i].value
					DestObj.options[DestObj.options.length-1].text = SourceObj.options[i].text
					/**** remove the selected option from the SourceObj list****/
					SourceObj.options[i] = null;
					i = i - 1;
				}
			}
		}
		else
		{
			DestObj.options.length++
			DestObj.options[DestObj.options.length-1].value = SourceObj.options[SourceObj.selectedIndex].value
			DestObj.options[DestObj.options.length-1].text = SourceObj.options[SourceObj.selectedIndex].text
			/**** remove the selected option from the SourceObj list****/
			SourceObj.options[SourceObj.selectedIndex] = null;
		}
		DestObj.options[DestObj.options.length-1].selected = true
	}	
}


function isSupportedBrowser()
{
	//detectBrowser();
	var detectBr = window.navigator.userAgent.toLowerCase();
	var sIndex
	var eIndex
	var version
	
	for(var i=0;i< SupportedBrowsers.length;i++ )
	{
		sIndex = 0
		eIndex = 0
		version = ''
		sIndex = detectBr.indexOf(SupportedBrowsers[i][0].toLowerCase());
		if(sIndex > 0)
		{
			sIndex += SupportedBrowsers[i][0].length + 1;
			eIndex = sIndex
		
			while(eIndex < detectBr.length && (CheckNumeric(detectBr.charAt(eIndex)) || detectBr.charAt(eIndex)== '.'))
				eIndex++; 
			
			version = detectBr.substring(sIndex, eIndex)
			
			if( version >= SupportedBrowsers[i][1])
				return true;
		}	
	}		
	return false;				
}

function modifyDir( objName )
{
	var txt = getInnerText(getObj(objName),0);
	try
	{
	var letter = '';
	var basicChar = 0;
	var extenChar = 0;
	for(var i=0;i<txt.length;i++)
	{
		letter = new String(txt.substr(i,1));
		
		if (letter.charCodeAt(0) < 256)
			basicChar = basicChar + 1;
		else
			extenChar = extenChar + 1;
	}
	
	if (basicChar > extenChar)
		getObj(objName).dir = 'LTR';
	else
		getObj(objName).dir = 'ltr';
	}
	catch(e)
    	{
       		return
    	}	
}



