/* Advansys miscellaneous javascript website specific functions */

function EmbedFlash(swf, height, width, loop){
// Main Flash animation - XHTML 1.0 compliant workaround for IE and Firefox (write as javascript rather then embed HTML))
document.write('<object type="application/x-shockwave-flash" data="'+swf+'" width="'+width+'" height="'+height+'">');
document.write('<param name="movie" value="'+swf+'"/>');
document.write('<param name="loop" value="'+loop+'"/>');
document.write('</object>');	
}
function ShowMap(MapURL,PostCode){
window.open(MapURL+'&pc='+PostCode,'map','width=700, height=500, scrollbars=yes, location=no, status=yes');
}

function Flash(swf, height, width){
// Main Flash animation - XHTML 1.0 compliant workaround for IE and Firefox (write as javascript rather then embed HTML))
document.write('<object type="application/x-shockwave-flash" data="'+swf+'" width="'+width+'" height="'+height+'" >');
document.write('<param name="movie" value="'+swf+'"/>');
document.write('<param name="wmode" value="transparent"/>');
document.write('</object>');	
}

var inputs = new Array(0);
var inputs2 = new Array(0);
var found = new Boolean();
var found2 = new Boolean();

function clinput(input) {
found = false;
for (x in inputs){
	if (inputs[x] == input.name) {
		found = true;
	}
}
	if (found == false)	{
		inputs.push(input.name);
		input.value = '';
	}
}

function clinput2(input) {
found2 = false;
for (x in inputs2){
	if (inputs2[x] == input.name) {
		found2 = true;
	}
}
	if (found2 == false)	{
		inputs2.push(input.name);
		input.value = '';
	}
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function popup(url) 
{
 var width  = 380;
 var height = 420;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=yes';
 params += ', scrollbars=no';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'windowname5', params);
 if (window.focus) {newwin.focus()}
 return false;
}

function findpostcode(AdvOrMember){
	if (AdvOrMember){
		ct = "&ct=2"
	}else if(AdvOrMember == false){
		ct = "&ct=1"	
	}else{
		ct = ""	
	}
	pscode = document.getElementById('id_post_code').value;
	pscode = pscode.replace(/^\s+|\s+$/g,"");
	if(pscode != ""){
		window.open('/getpostcode.asp?postcode='+pscode+ct,'mywin','width=800,height=300');
	return true;
	}else{alert("Post code required"); document.getElementById('id_post_code').focus();return false;}
}

function hideshowpostcode(value){
	if(value !='GB'){
		document.getElementById('id_post_codeimg').style.display='none';
		try {
			document.getElementById('postcodefindsel').style.display='none';
		}
		catch(err){}
			document.getElementById('pscode_searchused').value = '0';
			document.getElementById('id_address1').readOnly = false;
			document.getElementById('id_address2').readOnly = false;
			document.getElementById('id_townORcity').readOnly = false;
			document.getElementById('id_county').readOnly = false;
			document.getElementById('id_address1').style.backgroundColor='';
			document.getElementById('id_address2').style.backgroundColor='';
			document.getElementById('id_townORcity').style.backgroundColor='';
			document.getElementById('id_county').style.backgroundColor='';
	}else{
		try {
		document.getElementById('id_post_codeimg').style.display='inline';
		}
		catch(err){}
	}
}
