//flash detection script
var flash5 = false; 
var flash6 = false;
cnflashDetect=false;
detectFlash()

//Flash detect function
function detectFlash()
{ 
	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
	// Write vbscript detection on ie win. IE on Win 
	if(isIE && isWin)
	{
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
	document.write('flash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
	document.write('</SCR' + 'IPT\> \n');
	} 
	// If netscape or mac(not version 4.5)
	if (navigator.plugins) 
	{		
		if ( navigator.plugins["Shockwave Flash"])// ...then check flash 3+. 
		{
		var flashDescription = navigator.plugins["Shockwave Flash"].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		flash5 = flashVersion == 5;
		flash6 = flashVersion >= 6;	  
		}
	}
	//set flash detect variable
	if(flash5==true || flash6==true)
	{cnflashDetect=true;}
}
//end of flash detection script

//Generic popup function   
function openPopup(urllink,popName,h,w,scroll)
{
  dummy=window.open(urllink,popName,"toolbar=0,status=no,menuBar=0,scrollbars="+scroll+",resizable=no,width=" + w + ",height=" + h + ",left=10,top=10");
}

//Open link in new window
function openLink(urllink,popName)
{
	if (urllink != '')
		dummy=window.open(urllink,popName);
}

//Checks for blank elements
function isblank(s)
{
  for(var i = 0; i < s.length; i++)
  {
    var c = s.charAt(i);
    if ((c!=' ') && (c!='\n') && (c!='\t')) return false;
  }
  return true;
}
 
//Checks for empty elements
function isEmpty(s)
{
  if (!(s.value==null || s.value=="" || isblank(s.value)))return false;
  return true;
}
 
function isValid(element, identifier) {
    if (isEmail(element.value) == false) {
        element.focus();
		FormError += "Please enter a valid email address" + (identifier != null && identifier.length > 0 ? " for " + identifier : "") + ".\n";
        return false;
    } 
    return true;
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}
	
function isPostcode(strPost,country) 
{
    var country=new String(country.value)
	country=country.toUpperCase()
	var strPost=new String(strPost.value)
	strPost=strPost.toLowerCase()
	if(country=="UK" || country=="BRITISH" || country=="BRITAIN" || country=="WALES" || country=="SCOTLAND" || country=="ENGLAND" || country=="UNITED KINGDOM")
		{
		if (strPost.search(/[a-z]{1,2}\d{1,2}[a-z]?\s*\d[a-z]{2}/) != -1)
			return true;
    	else
			FormError=FormError+"Please enter a valid postcode.\n";
        	return false;
		}
	else
		return true;
}