﻿//*************************************************************************************
//* © Copyright 1997, 1998, 1999, 2000, 2001, 2002 Peopleclick, Inc.
//* All rights reserved.
//* Last Updated on 5/30/02 By Kevin Blake
//*************************************************************************************

// Global Variables
var gsClientFolderName = "Client_Dana";
var gsClientSiteCode = "EXTERNAL";
var gsClientSiteFolderName = "External_Pages";

document.cookie = 'TestCookie' + escape('nothing')

var iClickCtr=0;

document.onclick = processClicks;

function processClicks()
{
//if (((window.event.srcElement.tagName=='IMG') || (window.event.srcElement.tagName=='A'))&&(window.event.srcElement.parentElement.tagName=='A'))
if (((window.event.srcElement.tagName=='IMG') && (window.event.srcElement.parentElement.tagName=='A')) || (window.event.srcElement.tagName=='A'))
	{
 		if (iClickCtr>0)
 		{
  			window.event.returnValue=false;
 		}
		
 		iClickCtr+=1;
	}
}

function disableSubmit()
{
	document.getElementById("EEOSubmit").style.display="none"
	document.getElementById("Disable").style.display=""
}

function enableSubmit()
{
	document.getElementById("EEOSubmit").style.display=""
	document.getElementById("Disable").style.display="none"
}

function OpenHelpWindow(URL, sWindowName) 
{
	var sParameters;
	sParameters = 'menubar=0,scrollbars=1,resizable=0,width=600,height=600';
	window.open (URL, sWindowName, sParameters);
	iClickCtr=0;
}

function OpenUploadWindow(URL, sWindowName) 
{
	var CookieStatus;
	var scWindow = null;
	var vwindow;
	var sParameters;
	
	CookieStatus = CheckCookie(2);
	if (CookieStatus)
	{
		sParameters = 'menubar=0,scrollbars=1,resizable=0,width=525,height=355';
		window.open (URL, sWindowName, sParameters);
	}
	iClickCtr=0;
}

function CheckCookie(AddToCart)
{
 /* check for a cookie */
  if (document.cookie == "") 
  {
  	if ((AddToCart == 1) || (AddToCart == undefined))
	{
	    /* if a cookie is not found - alert user */
	    alert("In order to utilize the Job Cart functionality you will need to enable Cookie support in your Browser. Click on the Helpful Hints button above to view instructions on how to enable Cookies for the browser.");
	}
	else
	{
		if (AddToCart == 2)
		{
			alert("In order to upload your Cover Letter and Resume/CV, you will need to enable Cookie support in your Browser. Click on the Helpful Hints button above to view instructions on how to enable Cookies for the browser.");
		}
		else
		{
			/* if a cookie is not found - alert user */
			alert("In order to apply for this position you will need to enable Cookie support in your Browser. Click on the Helpful Hints button above to view instructions on how to enable Cookies for the browser.");
		}
	}
   return false;
  } else 
  {
  	//Add Job to Cookie
	return true;
  }
  iClickCtr=0;
}

function CheckCookie_JobDetails()
{
 /* check for a cookie */
  if (document.cookie == "") 
  {
    /* if a cookie is not found - alert user */
    alert("In order to apply for this job you will need to enable Cookie support in your Browser. Click on the Helpful Hints button above to view instructions on how to enable Cookies for the browser.");
   //document.JobSearchForm.CookieExists.value ="false"  
   return false;
  } else 
  {
  	//Add Job to Cookie
	return true;
  }
  iClickCtr=0;
}

function saveData(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readData(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseData(name)
{
	saveData(name,"",-1);
}

function validateResume()
{
	var sMissing;
	var fileUploaded;
	maxlength=100000;
	
	fileUploaded = readData("ResumeUploadedFileNameCookie");
	if (fileUploaded == null )
	{
		if (document.frmCandidate.sCoverLetter.value.length != 0)
		{
			if(document.frmCandidate.sCoverLetter.value.length>=maxlength) 
			{
				sMissing = '- Warning the cover letter you have pasted into the text area exceeds the maximum limit of 100,000 characters.  Please shorten the text or remove the text and use the resume builder.';
			}
		}
		
		if (document.frmCandidate.ResumeText.value.length != 0)
		{
			if (document.frmCandidate.ResumeText.value.length>=maxlength) 
			{
				if(document.frmCandidate.sCoverLetter.value.length>=maxlength)
				{
					sMissing =  sMissing + '\n\n- Warning the resume you have pasted into the text area exceeds the maximum limit of 100,000 characters.  Please shorten the text or remove the text and use the resume builder.';
				}
				else
				{
					sMissing = '-Warning the resume you have pasted into the text area exceeds the maximum limit of 100,000 characters.  Please shorten the text or remove the text and use the resume builder.';
				}
			}
		}
	}

	if ((sMissing == '') || (sMissing == undefined))
	{
		iClickCtr=0;
	   	return true;
	}
	else
	{
		alert(sMissing);
		iClickCtr=0;
	    return false;
	}
}

function textCounter( field, countfield, maxlimit ) {
  if ( field.value.length > maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit);
   alert( 'Character limit of ' + maxlimit + ' has been exceeded.' );
    return false;
  }
  else
  {
    countfield.value = maxlimit - field.value.length;
  }
}

function fnPaste(vEl)
{
   var intMaxLength, intCurrLength, strClip ;
   var intClipLength, intAvailLength ;
   var blnReturn ;

   blnReturn = true ;
   intMaxLength = vEl.getAttribute("maxlength") ;
   intCurrLength = vEl.value.length ;
   strClip = window.clipboardData.getData("Text") ;
   intClipLength = strClip.length ;
   intAvailLength = intMaxLength - intCurrLength ;
   
   if (intAvailLength > 0)
   {
    if (intAvailLength < intClipLength)
    {
     strClip = strClip.substr(0, intAvailLength) ;
     window.clipboardData.setData("Text",strClip) ;
	 alert( 'Character limit of ' + intMaxLength + ' has been exceeded.' );
    }
   }
   else
   {
   alert('test');
    blnReturn = false ;
   }
   return blnReturn ;
}

function EmailThisJob() 
{
	
	var sParameters = 'width=300,height=300';
	sParameters += ',resizable=1,status=0,menubar=0,toolbar=0,location=0,scrollbars=0';
	var URL = "/" + gsClientFolderName + "/bu1/" + gsClientSiteFolderName + "/emailthisjob.asp";
	var sWindowName = 'SendEmail';	
	window.open (URL, sWindowName, sParameters);
	iClickCtr=0;
		
}


function openCart()
{
	var CookieStatus;
	var scWindow = null;
	var vwindow;
	
	CookieStatus = CheckCookie();
	if (CookieStatus)
	{
		vwindow = window.open("/" + gsClientFolderName + "/bu1/" + gsClientSiteFolderName + "/Shopping_Cart/shoppingcart.asp?SearchDirectory=" + gsClientSiteCode,"scWindow","location=no,directories=no,scrollbars=yes,resizable=yes,width=600,height=500,center=yes,help=no");
	}
	iClickCtr=0;
}

function openQuery(SkillType, FieldName) 
{
	//open a new toolbar-less window for the app to run in
	var iAppWidth = 360;
	var iAppHeight = 415;
	var window_left = (screen.width - iAppWidth)/2;
 	var window_top = (screen.height - iAppHeight)/2;
	
	var handle = window.open("QueryBox.asp?FieldName=" + FieldName + "&SkillType=" + SkillType,"Query","width=" + iAppWidth + ",height=" + iAppHeight + ",left=" + window_left + ",top=" + window_top +
		",resizable=no,toolbar=no,menubar=no,status=yes");
	
	return handle;
}

function apply()
{
	var URL = "Newcandidate.asp";
	var iQuestionMark, sQueryDelimiter
	window.opener.location = URL;
	iQuestionMark = window.location.href.indexOf("?");

	if (iQuestionMark >= 0)
	{
		sQueryDelimiter = "&";
	}
	else
	{
		sQueryDelimiter = "?";
	}
	window.location = window.location + sQueryDelimiter + "apply=no";
	
}

function IsNumeric(strString)
//  check for valid numeric strings	
{
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
	
	if (strString.length == 0) return false;
	
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	   {
	   strChar = strString.charAt(i);
	   if (strValidChars.indexOf(strChar) == -1)
	      {
	      blnResult = false;
	      }
	   }
	return blnResult;
}
