/*
Reg exp functions
*/

function validateEmail(strValue) {
//Returns boolean true if valid, otherwise false.

var objRegExp  = /^[A-Za-z0-9\-_]+(\.[A-Za-z0-9\-_]+)*@([A-Za-z0-9\-_\.]+\.)+[A-Za-z]{2,3}$/i;
//check for valid email
return objRegExp.test(strValue);
}

///

function trimAll(strValue) {
//Removes leading and trailing spaces.

 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }
    
   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

///

function validateNotEmpty( strValue ) {
// Validates that a string is not all blank (whitespace) characters.
   var strTemp = strValue;
   strTemp = trimAll(strTemp);
   if(strTemp.length > 0){
     return true;
   }  
   return false;
}

/*
SQL Injection Control functions
*/

//This strips characters out of a string to protect against sqlinjection
function sqlProt(frmStr) {
 	   myregexp=(/'/g);
	   alert(myregexp);
	   alert(frmStr);
	   frmStr = frmStr.replace(myregexp,'"');
 	   alert(frmStr);
return frmStr     
}

///

function mk_test(this_value)
	{
		magBox(this_value);
		return(true);
	}


///
	
function validate(theForm) { // only submit form if search text present
	if (!validateNotEmpty(theForm.SearchText.value))
	{
		theForm.SearchText.focus();
		return (false);
	}
	return (true);
}

///

function validatorstnfeedbackform(STNfeedbackform)
{
  if (!validateNotEmpty(STNfeedbackform.firstname.value))
  {
    alert("Please enter a value for the \"First Name\" field.");
    STNfeedbackform.firstname.focus();
    return (false);
  }
  
  if (!validateNotEmpty(STNfeedbackform.lastname.value))
  {
    alert("Please enter a value for the \"Last Name\" field.");
    STNfeedbackform.lastname.focus();
    return (false);
  }
  
  if (!validateNotEmpty(STNfeedbackform.company.value))
  {
    alert("Please enter a value for the \"Company/Organisation\" field.");
    STNfeedbackform.company.focus();
    return (false);
  }
  
  if (!validateNotEmpty(STNfeedbackform.enquiry.value))
  {
    alert("Please enter a value for the \"Enquiry/Comment\" field.");
    STNfeedbackform.enquiry.focus();
    return (false);
  }
  
  if (!validateEmail(STNfeedbackform.emailaddress.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    STNfeedbackform.emailaddress.focus();
    return (false);
  }
  
  if (!validateNotEmpty(STNfeedbackform.tel.value))
  {
    alert("Please enter a value for the \"Telephone\" field.");
    STNfeedbackform.tel.focus();
    return (false);
  }

  return (true);
}

///

function validator(feedbackform)
{
  if (!validateNotEmpty(feedbackform.firstname.value))
  {
    alert("Please enter a value for the \"First Name\" field.");
    feedbackform.firstname.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.lastname.value))
  {
    alert("Please enter a value for the \"Last Name\" field.");
    feedbackform.lastname.focus();
    return (false);
  }
   
  if (!validateEmail(feedbackform.emailaddress.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    feedbackform.emailaddress.focus();
    return (false);
  }
  
    if (feedbackform.contact_you.value=="Yes")
  {
    if (feedbackform.contact_method.value=="PS") 
	{
    alert("Please tell us how you would like us to contact you");
    feedbackform.contact_method.focus();
    return (false); 
	}
  }
  
  return (true);
}

///

function validator_intranet(feedbackform)
{
  if(!validateNotEmpty(feedbackform.firstname.value))
  {
    alert("Please enter a value for the \"First Name\" field.");
    feedbackform.firstname.focus();
    return (false);
  }
  
  if(!validateNotEmpty(feedbackform.lastname.value))
  {
    alert("Please enter a value for the \"Last Name\" field.");
    feedbackform.lastname.focus();
    return (false);
  }
   
  return (true);
}

///

function validator_internet(feedbackform)
{
  if(!validateNotEmpty(feedbackform.firstname.value))
  {
    alert("Please enter a value for the \"First Name\" field.");
    feedbackform.firstname.focus();
    return (false);
  }
  
  if(!validateNotEmpty(feedbackform.lastname.value))
  {
    alert("Please enter a value for the \"Last Name\" field.");
    feedbackform.lastname.focus();
    return (false);
  }
   
  return (true);
}

///

function validatoreuroinfocentre(feedbackform)
{
  if (!validateNotEmpty(feedbackform.natureofenquiry.value))
  {
    alert("Please enter a value for the \"Natue of Enquiry\" field.");
    feedbackform.natureofenquiry.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.firstname.value))
  {
    alert("Please enter a value for the \"First Name\" field.");
    feedbackform.firstname.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.lastname.value))
  {
    alert("Please enter a value for the \"Last Name\" field.");
    feedbackform.lastname.focus();
    return (false);
  }
   
  if (!validateEmail(feedbackform.emailaddress.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    feedbackform.emailaddress.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.tel.value))
  {
    alert("Please enter a value for the \"Telephone Number\" field.");
    feedbackform.tel.focus();
    return (false);
  }
  
    if (feedbackform.numberofemployees.selectedIndex == 0)
  {
    alert("Please enter a value for the \"Number of Employess\" field.");
    feedbackform.numberofemployees.focus();
    return (false);
  }
  return (true);
}


///

function validatorglobalscot(feedbackform)
{
  if (!validateNotEmpty(feedbackform.firstname.value))
  {
    alert("Please enter a value for the \"First Name\" field.");
    feedbackform.firstname.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.lastname.value))
  {
    alert("Please enter a value for the \"Last Name\" field.");
    feedbackform.lastname.focus();
    return (false);
  }
   
  if (!validateEmail(feedbackform.emailaddress.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    feedbackform.emailaddress.focus();
    return (false);
  }
  return (true);
}


///

function validator_Ebus(feedbackform)
{
  if (!validateEmail(feedbackform.emailName.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    feedbackform.emailName.focus();
    return (false);
  }
  
  //Validation
  return (true);
}

///

function validator_rse(feedbackform)
{
  if (!validateNotEmpty(feedbackform.fname.value))
  {
    alert("Please enter a value for the \"First Name\" field.");
    feedbackform.fname.focus();
    return (false);
  }
 
  if (!validateNotEmpty(feedbackform.lname.value))
  {
    alert("Please enter a value for the \"Last Name\" field.");
    feedbackform.lname.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.cname.value))
  {
    alert("Please enter a value for the \"Company Name\" field.");
    feedbackform.cname.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.caddress.value))
 {
    alert("Please enter a value for the \"Company Address\" field.");
    feedbackform.caddress.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.ccountry.value))
  {
    alert("Please enter a value for the \"Country\" field.");
    feedbackform.ccountry.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.tel.value))
  {
    alert("Please enter a value for the \"Telephone\" field.");
    feedbackform.tel.focus();
    return (false);
  }
  
  if (!validateEmail(feedbackform.email.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    feedbackform.email.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.position.value))
  {
    alert("Please enter a value for the \"Postion\" field.");
    feedbackform.position.focus();
    return (false);
  }
  
  return (true);
}

///

function validateTendersEDS(feedbackform)
{
  if (!validateNotEmpty(feedbackform.natureofenquiry.value))
  {
    alert("Please enter a value for the \"Nature of your enquiry\" field.");
    feedbackform.natureofenquiry.focus();
    return (false);
  }
  if (!validateNotEmpty(feedbackform.firstname.value))
  {
    alert("Please enter a value for the \"First Name\" field.");
    feedbackform.firstname.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.lastname.value))
  {
    alert("Please enter a value for the \"Last Name\" field.");
    feedbackform.lastname.focus();
    return (false);
  }
  
  if (!validateEmail(feedbackform.emailaddress.value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    feedbackform.emailaddress.focus();
    return (false);
  }
  
  return (true);
}


///

//Broadband subscription validation added for custom accept terms field. Will be replaced by UPC.

function validate_form ( )
{
    if (!validateNotEmpty(broadband_subscribe.firstname.value))
    {
        alert ("Please fill in the \"First Name\" box.");
        broadband_subscribe.firstname.focus();
		return (false);
    }
	
    if (!validateNotEmpty(broadband_subscribe.lastname.value))
    {
        alert ("Please fill in the \"Last Name\" box.");
        broadband_subscribe.lastname.focus();
		return (false);
    }
  
  	if (!validateEmail(broadband_subscribe.emailaddress.value))
  	{
    	alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    	broadband_subscribe.emailaddress.focus();
    	return (false);
  	}
	  
	if (broadband_subscribe.TCAccepted.checked == false)
    {
        alert ("Please check the Terms & Conditions box.");
     	broadband_subscribe.emailaddress.focus();
		return (false);
    }

	return (true);
}


///

function validator(newfeedbackform)
{
	if (!validateNotEmpty(newfeedbackform.comments.value))
		{	alert("Please enter a value for the \"comments\" field.");
			newfeedbackform.comments.focus();
			return (false);	}
			
  
    if (newfeedbackform.contact_you.value=="Yes")
  {
    if (newfeedbackform.contact_method.value=="PS") 
	{
    alert("Please tell us how you would like us to contact you");
    newfeedbackform.contact_method.focus();
    return (false); 
	}
  }			
			 
	if(!validateNotEmpty(document.forms.newfeedbackform.other_contact_type.value))
		{	alert("Please enter your contact details.");
			document.forms.newfeedbackform.other_contact_type.focus();
			return (false);	}
  return (true);
}  

///
// Used to prevent multiple submit button clicks

clickcounter = 0;
function NoRepeat() {
	if(clickcounter == 1) { return false; }
	clickcounter = 1;
	return true;
}


//Folding Sitemap Menu tree

var head="display:''"
img3=new Image()
img3.src="plus.gif"
img4=new Image()
img4.src="minus.gif"

var ns6=document.getElementById&&!document.all
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1

///

function checkcontained(e){
	var iscontained=0
	cur=ns6? e.target : event.srcElement
	i=0
	if (cur.id=="foldheader")
	iscontained=1
	else
	while (ns6&&cur.parentNode||(ie4&&cur.parentElement)){
	if (cur.id=="foldheader"||cur.id=="foldinglist")
	{
		iscontained=(cur.id=="foldheader")? 1 : 0
		break
	}
		cur=ns6? cur.parentNode : cur.parentElement
	}
	
	if (iscontained){
	var foldercontent=ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]
	if (foldercontent.style.display=="none"){
	foldercontent.style.display=""
	cur.style.listStyleImage="url(minus.gif)"
	}
	else{
	foldercontent.style.display="none"
	cur.style.listStyleImage="url(plus.gif)"
	}
	}
}

if (ie4||ns6)
document.onclick=checkcontained

///

function submit_feedback_form()
	{
		alert("submitting form");
		document.feedbackform.submit();
		return true;	
	}

///

function PrivacyTest(form)
	{
		alert("Test");
		if(form.privacy.checked == true)
		  {
		    alert("Please confirm you have read the Privacy Policy by selecting the checkbox.");
			return(false);
		  }		  
		return(true);	
	}

///

//This assumes that the form is called newfeedbackform and that the checkbox is called privacy
function checkprivacy()
{	//if(document.forms.newfeedbackform.privacy.checked)
	if(newfeedbackform.privacy.checked)
		{
			return(true);
		}
alert("Please confirm you have read the Privacy Policy by selecting the checkbox.")
return(false)
}

/* dropdown text from dynamic drive added 180604 */


/***********************************************
* Switch Content script- &#169; Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated Mar 23rd, 2004.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

///

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

///

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}


///

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
}
}

///

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

///

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

///

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

///

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined"){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
}


if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

/* end of dropdown text */

///

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

///

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

///

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

///

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

///

function isDate(dtStr){
    var minYear=1900;
    var maxYear=2100;
    var dtCh= "/";
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

///

function ValidateDate( strDate ) {
	
	//var dt=document.feedbackform.event_date;
	var dt=strDate;
	if (isDate(dt.value)==false){
			
		return false;
	}
    return true;
 }
 
 
/// 
 
function checkPhone( strcheckPhone )
{
var strPhone2 = strcheckPhone;
var digits = "0123456789";
var phoneNumberDelimiters = " ";
var validWorldPhoneChars = phoneNumberDelimiters;
s=stripCharsInBag(strPhone2,validWorldPhoneChars);
return (isInteger(s));
}


///

function validateNumberGreaterThanOne( strNumber )
{
	
	 var checkOK = "0123456789";
     var checkStr = strNumber.value;
     var allValid = true;
     var allNum = "";
	 if (checkStr=="")
		{
		
           return (true);
		}
		
      for (i = 0;  i < checkStr.length;  i++)
      {
        ch = checkStr.charAt(i);
           for (j = 0;  j < checkOK.length;  j++)
               if (ch == checkOK.charAt(j))
               break;
           if (j == checkOK.length)
           {
            allValid = false;
            break;
           }
           
		   
		   if (ch != ",")
           allNum += ch;
           }
           
		   if (!allValid)
           {
           alert("Please enter only numerical characters in the \"capacity\" field.");
           strNumber.focus();
           return (false);
		   
		   
		   
      }
		if (checkStr <= 0)
		{
		alert("Please enter a number greater than 0 in the \"capacity\" field.");
           strNumber.focus();
           return (false);
		}
	return true;
 }

///

function validatePhone( strPhone )
{
	
	var Phone=strPhone;
	
	
	if (checkPhone(Phone.value)==false){
		alert("Please enter a valid telephone number (numerics and blanks)");
		
		return false;
			}
	

	feedbackform.telephone.focus();
	return true;
 }
 
///
 
function checkPostCode (toCheck) 
{

var pcexp = new Array ();
pcexp.push (/^([a-z]{1,2}[0-9]{1,2})(\s*)([0-9]{1}[abdefghjlnpqrstuwxyz]{2})$/i);
pcexp.push (/^([a-z]{1,2}[0-9]{1}[a-z]{1})(\s*)([0-9]{1}[abdefghjlnpqrstuwxyz]{2})$/i);
pcexp.push (/^(GIR)(\s*)(0AA)$/i);

var postCode = toCheck.value;
var valid = false;
  
for ( var i=0; i<pcexp.length; i++) 
{
    if (pcexp[i].test(postCode)) 
	{
    pcexp[i].exec(postCode);
    postCode = RegExp.$1.toUpperCase() + " " + RegExp.$3.toUpperCase();
    valid = true;
    break;
    }
  }  
  if (valid) {return postCode;} else return false;
}

///

function checkUKTelephone (telephoneNumber) {
    // alert("telephoneNumber is "+ telephoneNumber);
  // Convert into a string and check that we were provided with something
  var telnum = telephoneNumber + " ";
  if (telnum.length == 1)  {
     telNumberErrorNo = 1;
     return false
  }
  telnum.length = telnum.length - 1;
  // alert("telnum is "+ telnum);
  // Don't allow country codes to be included (assumes a leading "+")
  var exp = /^(\+)[\s]*(.*)$/;
  if (exp.test(telnum) == true) {
     telNumberErrorNo = 2;
     return false;
  }
  
  // Remove spaces from the telephone number to help validation
  while (telnum.indexOf(" ")!= -1)  {
    telnum = telnum.slice (0,telnum.indexOf(" ")) + telnum.slice (telnum.indexOf(" ")+1)
  }
  
  // Remove hyphens from the telephone number to help validation
  while (telnum.indexOf("-")!= -1)  {
    telnum = telnum.slice (0,telnum.indexOf("-")) + telnum.slice (telnum.indexOf("-")+1)
  }  
  
  // Now check that all the characters are digits
  exp = /^[0-9]{10,11}$/
  if (exp.test(telnum) != true) {
   // alert(telnum);
     telNumberErrorNo = 3;
     return false;
  }
  
  // Now check that the first digit is 0
  exp = /^0[0-9]{9,10}$/
  if (exp.test(telnum) != true) {
     telNumberErrorNo = 4;
     return false;
  }
  
  // Finally check that the telephone number is appropriate.
  //exp = /^(01|02|05|070|077|078|079)[0-9]+$/;
  //if (exp.test(telnum) != true) {
    // telNumberErrorNo = 5;
     //return false;
  //}
  
  // Telephone number seems to be valid - return the stripped telehone number  
  return telnum;
}
var telNumberErrorNo = 0;
var telNumberErrors = new Array ();
telNumberErrors[0] = "Valid UK telephone number";
telNumberErrors[1] = "Telephone number not provided";
telNumberErrors[2] = "UK telephone number without the country code, please";
telNumberErrors[3] = "UK telephone numbers should contain 10 or 11 digits";
telNumberErrors[4] = "The telephone number should start with a 0";
telNumberErrors[5] = "The telephone number is either invalid or inappropriate";
  
  //return true;
//}

///

function IsFutureDate( str1 )
     {
          // Parse the string in DD/MM/YYYY format
          re = /(\d{1,2})\/(\d{1,2})\/(\d{4})/
          var arr = re.exec( str1 );
          var dt1 = new Date( parseInt(arr[3]), parseInt(arr[2], 10) - 1, parseInt(arr[1], 10) );
     
          return dt1 > new Date();
     }

///	 
	 
function IsEndDateBeforeStartDate( str1,str2 )
     {
          // Parse the string in DD/MM/YYYY format
          re = /(\d{1,2})\/(\d{1,2})\/(\d{4})/
          var arr = re.exec( str1 );
		  var arr2 = re.exec( str2 );
		  
          var dt1 = new Date( parseInt(arr[3]), parseInt(arr[2], 10) - 1, parseInt(arr[1], 10) );
		  var dt2 = new Date( parseInt(arr2[3]), parseInt(arr2[2], 10) - 1, parseInt(arr2[1], 10) );
		  
		  
		  //alert("dt1 is "+dt1+" dt2 is "+dt2);
		  
          //var startdate =  feedbackform.end_date.value;  
		  
          // return dt1 > new Date();
		  //alert("startdate is "+startdate);
		  return dt1 > dt2;
		  
     }	 
	 
	 
///

/*
Validation functions added by Robin McLeary for Event Submission Form
*/ 
function validateNumeric(strValue) {
//Returns boolean true if valid, otherwise false.

var objRegExp  = /^\d+$/;
//check for valid number
return objRegExp.test(strValue);
}

///

function is24hourTime(strValue) {

    var objRegExp  = /^([01]?[0-9]|[2][0-3])(:[0-5][0-9])?$/;
	
	return objRegExp.test(strValue);
}

///

function eventrequestvalidation(feedbackform)
{
  if (!validateNotEmpty(feedbackform.wave_id.value))
  {
    alert("Please enter a value for the \"Wave ID\" field.");
    feedbackform.wave_id.focus();
    return (false);
  }
  
  if (!ValidateDate(feedbackform.start_date))
  {
   
    feedbackform.start_date.focus();
    return (false);
  }
  
  if (!IsFutureDate(feedbackform.start_date.value))
  {
    alert("Please enter a date in the future for the advertising start date");
    feedbackform.start_date.focus();
    return (false);
  }
  
  
  
  
  
   
  if (!ValidateDate(feedbackform.end_date))
  {
    
    feedbackform.end_date.focus();
    return (false);
  }
  
  
  if (!IsFutureDate(feedbackform.end_date.value))
  {
    alert("Please enter a date in the future for the advertising end date");
    feedbackform.end_date.focus();
    return (false);
  }
  
  if (!IsEndDateBeforeStartDate(feedbackform.end_date.value,feedbackform.start_date.value))
  {
    alert("Please enter an advertisng end date after the advertising start date");
    feedbackform.end_date.focus();
    return (false);
  }
  
  
  
  
  
  
  if (!validateNotEmpty(feedbackform.title.value))
  {
    alert("Please enter a value for the \"Title\" field.");
    feedbackform.title.focus();
    return (false);
  }




  if (!validateNotEmpty(feedbackform.summary_description.value))
  {
    alert("Please enter a value for the \"Summary Description\" field.");
    feedbackform.summary_description.focus();
    return (false);
  }


  
  if (!validateNotEmpty(feedbackform.category.value))
  {
    alert("Please enter a value for the \"Category\" field.");
    feedbackform.category.focus();
    return (false);
  }
  
  
  if (!validateNotEmpty(feedbackform.region.value))
  {
    alert("Please enter a value for the \"Region\" field.");
    feedbackform.region.focus();
    return (false);
  }
  
  
  
  if (!ValidateDate(feedbackform.event_date))
  {
	feedbackform.event_date.focus();
    return (false);
  }
  
 
  
  if (!IsFutureDate(feedbackform.event_date.value))
  {
    alert("Please enter a date in the future for the event date");
    feedbackform.event_date.focus();
    return (false);
  }

  
   if (!validateNotEmpty(feedbackform.start_time.value))
  {
    alert("Please enter a value for the \"Start Time\" field.");
    feedbackform.start_time.focus();
    return (false);
  }
  
  
  
   if (!validateNotEmpty(feedbackform.duration.value))
  {
    alert("Please enter a value for the \"Duration\" field.");
    feedbackform.duration.focus();
    return (false);
  }
  
  
  if (!validateNumberGreaterThanOne(feedbackform.capacity))
  {
    
    feedbackform.capacity.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.full_description.value))
  {
    alert("Please enter a value for the \"Full Description\" field.");
    feedbackform.full_description.focus();
    return (false);
  } 
  

  if (!validateNotEmpty(feedbackform.name.value))
  {
    alert("Please enter a value for the \"Venue Name\" field.");
    feedbackform.name.focus();
    return (false);
  }
  
  if (!validateNotEmpty(feedbackform.address1.value))
  {
    alert("Please enter a value for the \"Venue Address 1\" field.");
    feedbackform.address1.focus();
    return (false);
  }
  

  if (!validateNotEmpty(feedbackform.postcode.value))
  {
    alert("Please enter a value for the \"Venue Postcode\" field.");
    feedbackform.postcode.focus();
    return (false);
  }
  
  
  if (!checkPostCode(feedbackform.postcode))
  {
    alert("Please enter a valid postcode for the \"Venue Postcode\" field.");
    feedbackform.postcode.focus();
    return (false);
  }
  
  
  
  if (!validateNotEmpty(feedbackform.town.value))
  {
    alert("Please enter a value for the \"Venue Town/City\" field.");
    feedbackform.town.focus();
    return (false);
  }
  

  if (!validateNotEmpty(feedbackform.organiser.value))
  {
    alert("Please enter a value for the \"Venue Organiser\" field.");
    feedbackform.organiser.focus();
    return (false);
  }
  

if (!validateEmail(feedbackform.email_address.value))
  {
    alert("Please enter a complete organiser email address in the form: yourname@yourdomain.com");
    feedbackform.email_address.focus();
    return (false);
  }
  
  


	
if ((feedbackform.telephone.value!=null)&&(feedbackform.telephone.value!=""))
    { 	
	if (!checkUKTelephone(feedbackform.telephone.value)) 
      {
     alert (telNumberErrors[telNumberErrorNo]);
	 return (false);
      }
	}
	
		
  return (true);
}

///



///

function validator_extranet(agreementform)
{
  if(!validateNotEmpty(agreementform.username.value))
  {
    alert("Please enter a value for the \"Name\" field.");
    agreementform.username.focus();
    return (false);
  }
  
  if(!validateNotEmpty(agreementform.companyname.value))
  {
    alert("Please enter a value for the \"Company name\" field.");
    agreementform.companyname.focus();
    return (false);
  }

  if(!validateNotEmpty(agreementform.extranetname.value))
  {
    alert("Please enter a value for the \"Extranet name\" field.");
    agreementform.extranetname.focus();
    return (false);
  }

    
  return (true);
}

///
	
function checkPeopleSearch()
{
	var returnvalue = true;
	if ((document.advSearch.Firstname.value.length > 0) || (document.advSearch.Surname.value.length > 0) || (document.advSearch.JobTitle.value.length > 0))
		{
			//no action needed
		}
	else
		{
			alert("Please enter search keyword")
			document.advSearch.Firstname.focus()
			returnvalue = false;
		}

	return(returnvalue);
}

///

function checkAdvancedPeopleSearch()
{
	var returnvalue = true;
	
	
	if ((document.advSearch.Firstname.value.length > 0) || (document.advSearch.Surname.value.length > 0) || (document.advSearch.JobTitle.value.length > 0) || (document.advSearch.SubSpecial.value.length > 0) || (document.advSearch.AreaInterest.value.length > 0)  || (document.advSearch.OtherExp.value.length > 0) || (document.advSearch.Biography.value.length > 0) || (document.advSearch.SocialInt.value.length > 0))
		{
		
			//no action needed
		}
	else
		{
			alert("Please enter search keyword")
			document.advSearch.Firstname.focus()
			returnvalue = false;
		}

	return(returnvalue);
	
}

///

function popup700(href)
{	
	var tmpSuccess;
	tmpSuccess = window.open(href,'Scotent' , 'width=700,scrollbars=yes,menubar=no,titlebar=no,status=no');
}









