var _inc_requestSubmitted = false;

function ResetLoginForm() {
	document.getElementById("txtEmail").value=""
	document.getElementById("txtPassword").value=""
}

/*
** Handles any reset of the submit request check.
*/
function inc_ResetSubmitRequest() 
{
    _inc_requestSubmitted = false;
}

/*
** Handles page navigation requests from hyperlinks.
*/
function inc_ValidateLinkRequest() 
{
    // Any requests made from hyperlinks uses the form request check, but can in future be independent from this if required.    
    return inc_ValidateSubmitRequest();
}

/*
** Handles form submit requests.
*/
function inc_ValidateSubmitRequest() 
{
    if (_inc_requestSubmitted == true) 
    {
        alert("You have already submitted the request.. Please wait");
        return false;
    }

    _inc_requestSubmitted = true;

    return true;
}

function CheckDetailsLoginForm() 
{   
    if (inc_ValidateSubmitRequest()) 
    {
            if ((document.getElementById("txtEmail").value == "") || (document.getElementById("txtPassword").value == "")) 
            {
                inc_ResetSubmitRequest();
                alert(strEnterLogin);
                return false;
            }    
            
            document.getElementById("txtAction").value = "login";
            document.frmLogin.submit();
            return true;
      }
      else 
      {
         return false;
    }
}

	
function ReturnPressed() {
	if (window.event.keyCode == 13) {
		window.event.srcElement.click(); 
	}
}

function ResetSearch()
{
	if(IsValidObject(document.getElementById("p_quick_job_level_id")))
	{
	    frmQuickSearch.p_quick_job_level_id.selectedIndex = 0;
	    setCookie("QuickPosition", "", "", "");
	}
		
	if(IsValidObject(document.getElementById("p_job_region_id")))
	{
		frmQuickSearch.p_job_region_id.selectedIndex = 0;
		setCookie("QuickRecLoc", "", "", "");
	}
	
	if(IsValidObject(document.getElementById("p_quick_sector")))
	{
		frmQuickSearch.p_quick_sector.selectedIndex = 0;
		setCookie("QuickSecId", "", "", "");
	}
	
	if(IsValidObject(document.getElementById("p_quick_salary")))
	{
		frmQuickSearch.p_quick_salary.selectedIndex = 0;
		setCookie("QuickSalaryId", "", "", "");
	}
}

function PopUpContactUs(strURL) {
	var wHeight = 500;
	var wWidth = 750;
	var wTop = (screen.height / 2) - ( wHeight / 2);
	var wLeft = (screen.width / 2) - ( wWidth / 2);		
	var strPage = "ContactUs"
	
	wTop = (screen.height / 2) - ( wHeight / 2);
	wLeft = (screen.width / 2) - (wWidth / 2);

	try {
	    g_myWindow = window.open(strURL, strPage, "width=" + wWidth + ",height=" + wHeight + "resizable=yes,toolbar=no,status=no,scrollbars=yes,left=" + wLeft + ",top=" + wTop);
	    g_myWindow.focus();
	}
	catch (e) {
	    alert(strPopUpError);
	}
	finally {
	    inc_ResetSubmitRequest();
	}
}

function PopUpPrivacyPolicy(strURL) {
	var wHeight = 500;
	var wWidth = 750;
	var wTop = (screen.height / 2) - ( wHeight / 2);
	var wLeft = (screen.width / 2) - ( wWidth / 2);		
	var strPage = "PrivacyPolicyPopup"
	
	wTop = (screen.height / 2) - ( wHeight / 2);
	wLeft = (screen.width / 2) - ( wWidth / 2);
	
	try {
		g_myWindow = window.open(strURL, strPage, "width=" + wWidth + ",height=" + wHeight + "resizable=yes,toolbar=no,status=no,scrollbars=yes,left=" + wLeft + ",top=" + wTop);
		g_myWindow.focus();
	}
	catch(e) {
	    alert(strPopUpError);
	}
}

function PopUpEcourierTerms(strURL) {
	var wHeight = 415;
	var wWidth = 645;
	var wTop = (screen.height / 2) - ( wHeight / 2);
	var wLeft = (screen.width / 2) - ( wWidth / 2);		
	var strPage = "PrivacyPolicyPopup"
	
	wTop = (screen.height / 2) - ( wHeight / 2);
	wLeft = (screen.width / 2) - ( wWidth / 2);

	try {
		g_myWindow = window.open(strURL, strPage, "width=" + wWidth + ",height=" + wHeight + "resizable=yes,toolbar=no,status=no,scrollbars=no,left=" + wLeft + ",top=" + wTop);
		g_myWindow.focus();
	}
	catch(e) {
		alert(strPopUpError);
	}
}

function MyNavigate(url) 
{
    if (inc_ValidateLinkRequest()) 
    {
        window.location.href = url;
    }	    
}

function IsValidObject(obj) {
	if (obj == null || typeof(obj) == 'undefined') return false;
	return true;			
}

function validKeyPress(pattern, e) {
	var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	var character = String.fromCharCode(code);
	var reg = pattern

	//If the user clicks the backspace or tab key then do not do check
	if ((e.keyCode != 8)&&(e.keyCode != 9)&&(e.keyCode != 13)){ 
		return reg.test(character)
	}
}

function isValid(pattern, str) {
	return pattern.test(str);
}

window.onBeforeLoad = function(){
    alert("success")
}

//alert(window.location.href)

if(window.history.forward(-1) != null){
    location.replace(this.href); 
    event.returnValue=false

}



