<!--


//use OnClick="submitFormCategory([Put ID here]);" to enforce form submittal on click. [LX]
//also set the value of the select list to filter the form..
function submitFormCategory(id)
{
		var x = document.getElementById('jobSrch');
		var job_category_id = document.getElementById('Category');
		var Store = document.getElementById('Store');
		var job_type = document.getElementById('job_type');
		var job_duration = document.getElementById('job_duration');
		

		job_category_id.value = id
//		job_category_id.options[id].selected = true;
		Store.options[0].selected = true;
		job_type.options[0].selected = true;
		job_duration.options[0].selected = true;
		x.submit();
}

function submitFormStore(id)
{
		var x = document.getElementById('jobSrch');
		var job_category_id = document.getElementById('Category');
		var Store = document.getElementById('Store');
		var ftOrPt = document.getElementById('ftOrPt');
		var permTemp = document.getElementById('permTemp');

		Store.value = id
//		Store.options[id].selected = true;
		job_category_id.options[0].selected = true;
		ftOrPt.options[0].selected = true;
		permTemp.options[0].selected = true;
		x.submit();
}


function formAction(action)
//sets the action tag to the passed in variable
{
		var x = document.getElementById('search_form');
		x.action = action
}

function changeInputName(name)
//changes the INPUT NAME to the passed in variable
{
		var x = document.getElementById('search_form');
		var AZelement = document.getElementById('AZ');
		AZelement.name = name;
		
//		alert('input name is :  ' + AZelement.name);
}

function DoSearch(bit)
//changes the input "DoSearch" to either 1 or zero
//pass only 1 or 0 into this function to set DoSearch to true or false
{
		var x = document.getElementById('search_form');
		var DoSearchElement = document.getElementById('DoSearch');

		DoSearchElement.value = bit -0; //Force it to subtract zero making it an int..
		
		//alert('will the search appear? :  ' + DoSearchElement.value);
}

function submitSearch(AZ)
//submits the search.asp & search.htm pages
//passing a string in the form Uppercase "X-X"
{
		var x = document.getElementById('search_form');
		var AZelement = document.getElementById('AZ');

		AZelement.value = AZ;
	//	AZelement.style = '"background-color: transparent;background-image: url(/site/gfx/search_nav_buttonalpha_over.png);background-repeat: no-repeat;background-attachment: scroll;color: rgb(18, 119, 181);"';

		//alert('hidden form field value is ' + AZelement.value);
		//alert('form will redirect to :  ' + x.action);
		//AZelement.className='Test';
		x.submit();
		//identity=document.getElementById(id);

 		
}
//function swapClass(id, newClass) {

//var x = document.getElementById(id);
//alert (x)
//x.className=newClass;
//alert(x.ClassName)
//}

function submitSearchcatID(id, name)
//submits the search.asp & search.htm pages
//passing an integer in the form 1
//additionally we pass the CATEGORY NAME for the srch breadcrumb.
{
		var x = document.getElementById('search_form');
		var categoryIDelement = document.getElementById('categoryID');
		var category_name = document.getElementById('category_name');

		categoryIDelement.value = id -0; //Force it to subtract zero making it an int..
		category_name.value = name;
		
		//alert('form will redirect to :  ' + x.action);
		//alert('the value of categoryIDelement is ' + categoryIDelement.value);
		x.submit();
}

function setSubRetailerCategoryID(id)
//changes the subcategory id to its correct value from the recordset.
{
		var subCategoryIDelement = document.getElementById('subCategoryID');

		subCategoryIDelement.value = id -0; //Force it to subtract zero making it an int..

		//alert('the value of subCategoryID is ' + subCategoryIDelement.value);

}

/* Keyword search related */
function clearKeywords(keywords)
{
	
	if (keywords.value=='enter text here') 
	{	
		keywords.value='';
	}
}


function checkKeywordsNotNull()
{
	if (document.search_form_keyword.keywords.value=='' || document.search_form_keyword.keywords.value=='enter text here')  
	{
		window.alert('Please enter one or more keywords');
		return false;
	}
	else
	{
		return true;
	}
}



function popupWin(width, height, url)
{

	var intScWidth,intScHeight,intXPos,intYPos;
	
	intScWidth = screen.availWidth;
	intScHeight = screen.availHeight;
	
	intXPos = ((intScWidth - width) / 2);
	intYPos = ((intScHeight - height) / 2);

	var features = "height="+height+",width="+width+",screenX=" + intXPos + ",screenY=" + intYPos + ",left=" + intXPos + ",top=" + intYPos + ",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes";
	window.open(url, null, features);
}


function handleRegisterForm()
{
	var strMsg = 'Please correct the following...\n---------------------------------------\n';
	var blnCanSubmit = true;

	var frm_register = document.frm_register;
	
	var txt_firstName = document.getElementById('first_name');
	var txt_lastName = document.getElementById('last_name');
	var txt_email = document.getElementById('user_email');
	var chk_terms = document.getElementById('chk_terms');	
		
	var strPleaseCorrectColour = '42A6CC';
	var strOKColour = 'ffffff';

	setBGColour(txt_firstName,strOKColour);
	if(txt_firstName.value == '')
	{
		setBGColour(txt_firstName,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += 'Please enter your First Name.\n';
	}

	setBGColour(txt_lastName,strOKColour);
	if(txt_lastName.value == '')
	{
		setBGColour(txt_lastName,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += 'Please enter your Last Name.\n';
	}

	setBGColour(txt_email,strOKColour);
	if(txt_email.value == '')
	{
		setBGColour(txt_email,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += 'Please enter your email address.\n';
	}
	else
	{
		if(!emailCheck(txt_email.value))
		{
			setBGColour(txt_email,strPleaseCorrectColour);
			blnCanSubmit = false;
			strMsg += 'Please enter a valid email address.\n';	
		}
	}

	setBGColour(chk_terms,strOKColour);
	if(!chk_terms.checked)
	{
		setBGColour(chk_terms,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += 'Please tick box to confirm you have read Terms & Conditions.\n';
	}

	if(blnCanSubmit == false)
	{
		alert(strMsg);
	}

	else
	{
		frm_register.submit();
	}
}

function setBGColour(element, colour){

	element.style.backgroundColor = colour;

}



function emailCheck(strEmail) 
{
	var email = strEmail;
	invalidChars = " /:,;"

	if (email == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1) > -1) {
		return false;
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3 > email.length)	{
		return false;
	}
	return true;
}

function getObj(name){ 
	if (document.getElementById){
		return document.getElementById(name);
	}else if (document.all){
		return document.all[name];
	}else if (document.layers){
		return document.layers[name];
	}
}
function clearSearchBox()
{
	var objBox=getObj("searchtext");
	objBox.value="";
}

var min=8;
var max=22;

//Vector holds the number of times the text is changed in size from the base line
var text_vector=0;

function isThere(elementName) {
	var element = getObj(elementName);
	var elementValue = (element.value).replace(/^\s*|\s*$/g,'');
	if (elementValue == "") {
		return false;
	} else {
		return true;
	}
}

function isNumericOnlyorNull(elementName) {
	var element = getObj(elementName);
	var strString = element.value;
	if (strString == "") {
		return true;
	}
  var strValidChars = "0123456789.+ ";
  var strChar;
  var blnResult = true;


  //  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;
        }
    }
    //blnResult = true;
  return blnResult;

}

function isValidInputChars(elementName) {
	var element = getObj(elementName);
    var strString = element.value;

  var strValidChars = "abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ0123456789.,'-& ";
  var strChar;
  var blnResult = true;


  //  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;
        }
    }
    //blnResult = true;
  return blnResult;

}

function isValidPostcodeChars(elementName) {
	var element = getObj(elementName);
    var strString = element.value;

  var strValidChars = "abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ0123456789 ";
  var strChar;
  var blnResult = true;


  //  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;
        }
    }
    //blnResult = true;
  return blnResult;

}


function gp_login()
{
    var ok = true;
    var strMsg = "";
    
    if (!isThere("txt_email"))
    {
        strMsg += "Please enter your email address\n";
        ok = false;
    }
    
    if (!isThere("txt_password"))
    {
        strMsg += "Please enter your password\n";
        ok = false;
    }
    
    if (!ok)
    {
        alert(strMsg);
    }
    else
    {
        document.frmGpLogin.submit();
    }
}

function gp_postFormV2(page)
{
    
    var ok = true;
    var strMsg = "";
    
    // name
    if (!isThere("txt_name"))
    {
        strMsg += "Please enter your name.\n";
        ok = false;
    }
    
    // organisation
    if (!isThere("txt_organisation"))
    {
        strMsg += "Please enter your NHS Organisation.\n";
        ok = false;
    }
    
    
    // org code
    if (!isThere("txt_org_code"))
    {
        strMsg += "Please enter your Practice / Organisation Code.\n";
        ok = false;
    }
    
    
    //postcode
    if (!isThere("txt_postcode"))
    {
        strMsg += "Please enter your postcode.\n";
        ok = false;
    }
    
    
    if (!isNumericOnlyorNull("txt_phone"))
    {
        strMsg += "Please provide your telephone number in numbers only.\n";
        ok = false;
    }
    
    
    
    if (!isThere("txt_email"))
    {
        strMsg += "Please enter your email address\n";
        ok = false;
    }
    
    if (isThere("txt_email"))
    {
        var elementEmail = getObj("txt_email");
        if(!emailCheck(elementEmail.value))
        {
            strMsg += "Please enter a valid email address.\n";
            ok = false;
        }
    }
    
    if (!ok)
    {
        alert(strMsg);
    }
    else
    {
        if (page == "register")
        {
            document.frmGpRegister.submit();
        }
        if (page == "update")
        {
            document.frmGpUpdate.submit();
        }
    }
    
}


function gp_postForm(page)
{
    var ok = true;
    var strMsg = "";
    
    if (!isThere("txt_email"))
    {
        strMsg += "Please enter your email address\n";
        ok = false;
    }
    
    if (isThere("txt_email"))
    {
        var elementEmail = getObj("txt_email");
        if(!emailCheck(elementEmail.value))
        {
            strMsg += "Please enter a valid email address.\n";
            ok = false;
        }
    }
    
    if (!isThere("txt_password"))
    {
        strMsg += "Please enter your password\n";
        ok = false;
    }
    else
    {
        if(!isValidInputChars("txt_password"))
        {
            strMsg += "Please enter your password using alpha numeric characters only.\n";
            ok = false;
        }
    }
    
    
    if (!isThere("txt_cnfpassword"))
    {
        strMsg += "Please confirm your password\n";
        ok = false;
    }
    
    if (isThere("txt_password") && isThere("txt_cnfpassword"))
    {
        var elementPassword = getObj("txt_password");
        var elementCnfPassword = getObj("txt_cnfpassword");
        
        if (elementPassword.value != elementCnfPassword.value)
        {
            strMsg += "Your passwords do not match.\n";
            ok = false;
        }
        
        if (elementPassword.value.length < 8)
        {
            strMsg += "Your password must be at least 8 characters long.\n";
            ok = false;
        }
    }
    
    if (!isNumericOnlyorNull("txt_phone"))
    {
        strMsg += "Please provide your telephone number in numbers only.\n";
        ok = false;
    }
    
    if (isThere("txt_practiseName"))
    {
        if(!isValidInputChars("txt_practiseName"))
        {
            strMsg += "Please enter your GP Practise name using alpha numeric characters only.\n";
            ok = false;
        }
    }
    
    if (isThere("txt_hospitalName"))
    {
        if(!isValidInputChars("txt_hospitalName"))
        {
            strMsg += "Please enter your hospital name using alpha numeric characters only.\n";
            ok = false;
        }
    }
    
    if (isThere("txt_postcode"))
    {
        if(!isValidPostcodeChars("txt_postcode"))
        {
            strMsg += "Please enter your postcode using alpha numeric characters only.\n";
            ok = false;
        }
    }
    
    
    if (!ok)
    {
        alert(strMsg);
    }
    else
    {
        if (page == "register")
        {
            document.frmGpRegister.submit();
        }
        if (page == "update")
        {
            document.frmGpUpdate.submit();
        }
    }
}





//function gp_update()
//{
//    var ok = true;
//    var strMsg = "";
//    
//    if (!isThere("txt_email"))
//    {
//        strMsg += "Please enter your email address\n";
//        ok = false;
//    }
//    
//    if (isThere("txt_email"))
//    {
//        var elementEmail = getObj("txt_email");
//        if(!emailCheck(elementEmail.value))
//        {
//            strMsg += "Please enter a valid email address.\n";
//            ok = false;
//        }
//    }
//    
//    if (!isThere("txt_password"))
//    {
//        strMsg += "Please enter your password\n";
//        ok = false;
//    }
//    else
//    {
//        if(!isValidInputChars("txt_password"))
//        {
//            strMsg += "Please enter youe password using alpha numeric characters only.\n";
//            ok = false;
//        }
//    }
//    
//    if (!isThere("txt_cnfpassword"))
//    {
//        strMsg += "Please confirm your password\n";
//        ok = false;
//    }
//    
//    if (isThere("txt_password") && isThere("txt_cnfpassword"))
//    {
//        var elementPassword = getObj("txt_password");
//        var elementCnfPassword = getObj("txt_cnfpassword");
//        
//        if (elementPassword.value != elementCnfPassword.value)
//        {
//            strMsg += "Your passwords do not match.\n";
//            ok = false;
//        }
//        
//        if (elementPassword.value.length < 8)
//        {
//            strMsg += "Your password must be at least 8 characters long.\n";
//            ok = false;
//        }
//    }
//    
//    if (!isNumericOnlyorNull("txt_phone"))
//    {
//        strMsg += "Please provide your telephone number in numbers only.\n";
//        ok = false;
//    }
//    
//    
//    if (!ok)
//    {
//        alert(strMsg);
//    }
//    else
//    {
//        document.frmGpUpdate.submit();
//    }
//}




/*
function setFontSize(fontSize) {

	var actualFontSize = "";
	switch (fontSize)
	{
	 case "normal":  actualFontSize = "75%";
	                 break;
	 case "medium":  actualFontSize = "90%";
	                 break;
	 case "large":   actualFontSize = "110%";
	                 break;
	 default:        actualFontSize = "75%";
	}
   
	document.body.style.fontSize = actualFontSize;

	var theMenu = document.getElementById("mainMenu");
	try
	{
		var theItem = theMenu.getElement("li");
	}
	catch(err)
	{
	//DO NOTHING	
	}
		try
	{
		theItem.style.fontSize = actualFontSize;
	}
	catch(err)
	{
	//DO NOTHING	
	}
   createCookie("textvector",fontSize,365);
}


function CheckFontSize() {
    text_vector=readCookie("textvector");
    setFontSize(text_vector);
}

function createCookie(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 readCookie(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 eraseCookie(name) {
	createCookie(name,"",-1);
}
*/







-->
