/* Advansys miscellaneous javascript website specific functions */

function change_to(xValue) {
  if (xValue != 0) {
	location.href = xValue;
  }
}

// Change stylesheet class (used on onmouseover and onmouseout)
function hi(img, mode){
	if (mode==1){img.className = 'hi'} else img.className = 'lo';
}

function advtv(swf, width, height, id){
// Main Flash animation - XHTML 1.0 compliant workaround for IE and Firefox (write as javascript rather then embed HTML))
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" align="bottom">');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name="movie" value="'+swf+'"/>');
document.write('<param name="quality" value="high" />');
document.write('<param name="loop" value="false"/>');
document.write('<param name="allowfullscreen" value="true"/>');
document.write('<param name="displayheight" value="250"/>');
document.write('<embed type="application/x-shockwave-flash" src="'+swf+'" width="'+width+'" height="'+height+'"></embed>');
document.write('</object>');
}

function Portfolio(swf, height, width, loop, xml,fulllist,iscom,hb,pf){
// Main Flash animation - XHTML 1.0 compliant workaround for IE and Firefox (write as javascript rather then embed HTML))
qstring = "?"

if (xml != null){qstring = qstring+"xml="+xml+"&";}
if (fulllist != null){qstring = qstring+"fulllist="+fulllist+"&"}
if (iscom != null){qstring = qstring+"iscom="+iscom+"&"}
if (hb != null){qstring = qstring+"hb="+hb+"&"}
if (pf != null){qstring = qstring+"pf="+pf}

document.write('<object type="application/x-shockwave-flash" data="/swf/'+swf+qstring+'" width="'+width+'" height="'+height+'">');
document.write('<param name="movie" value="/swf/'+swf+qstring+'"/>');
document.write('<param name="wmode" value="opaque" />');
document.write('<param name="loop" value="'+loop+'"/>');
document.write('</object>');	
}

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/'+swf+'" width="'+width+'" height="'+height+'">');
document.write('<param name="movie" value="/swf/'+swf+'"/>');
document.write('<param name="wmode" value="opaque" />');
document.write('<param name="loop" value="'+loop+'"/>');
document.write('</object>');	
}

function EmbedFlash3(swf, width, height, id){
// Main Flash animation - XHTML 1.0 compliant workaround for IE and Firefox (write as javascript rather then embed HTML))
swf = swf +'&baseurl=http://advansys.onlinepreview.co.uk'
document.write('<object type="application/x-shockwave-flash" height="'+height+'" width="'+width+'" data="'+swf+'" id="'+id+'">');
document.write('<param name="movie" value="'+swf+'"/>');
document.write('<param name="loop" value="false"/>');
document.write('<param name="wmode" value="opaque"/>');
document.write('</object>');
}

function CheckEmail(address) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(address)){
	return (true)
	}
	return (false)
}

function ValidateSearch(form){
	if (form.q.value==''){alert('Please enter a keyword or phrase'); return false;}
	return true;
}

function ValidateContact(form){
if (form.name.value=='') {alert('Please fill in your name'); form.name.focus(); return false}
if (form.telephone.value=='') {alert('Please fill in your contact telephone number'); form.telephone.focus(); return false}
if (form.email.value=='') {alert('Please fill in your email address'); form.email.focus(); return false}
if (!CheckEmail(form.email.value)) {alert('Invalid email address'); form.email.focus(); return false}
if (form.howheard.value=='') {alert('Please tell us how you heard about us'); form.howheard.focus(); return false}
if (form.subject.value=='') {alert('Please enter a subject'); form.subject.focus(); return false}
if (form.message.value=='') {alert('Please enter your message'); form.message.focus(); return false}
}

function ValidateCallback(form){
if (form.name.value=='') {alert('Please fill in your name'); form.name.focus(); return false}
if (form.phone.value=='') {alert('Please fill in your contact telephone number'); form.phone.focus(); return false}
if (form.email.value=='') {alert('Please fill in your email address'); form.email.focus(); return false}
if (!CheckEmail(form.email.value)) {alert('Invalid email address'); form.email.focus(); return false}
if (form.subject.value=='') {alert('Please enter a subject'); form.subject.focus(); return false}
if (form.enquiry.value=='') {alert('Please enter enquiry details'); form.enquiry.focus(); return false}
if (form.captcha.value=='') {alert('Please enter the security code'); form.captcha.focus(); return false}
}

function articefrml(form){
if (form.firstname.value=='') {alert('Please fill in your first name'); form.firstname.focus(); return false}
if (form.lastname.value=='') {alert('Please fill in your last name'); form.lastname.focus(); return false}
if (form.email.value=='') {alert('Please fill in your email address'); form.email.focus(); return false}
if (!CheckEmail(form.email.value)) {alert('Invalid email address'); form.email.focus(); return false}
}

function showTooltip(show, id) {
	if (show == "1") {
		document.getElementById(id).style.display = "block";
	} else {
		document.getElementById(id).style.display = "none";
	}
}

function openpfl (id){
for (i=0;i<aPflinks.length;i++){
if (aPflinks[i].sID == id){
window.open('http://'+aPflinks[i].sLink,'_blank')
}
}
}
	function checkcommntfrm(form){
	if (form.name.value=='') {alert('Please select your name'); form.name.focus(); return false;}
	if (form.email.value=='') {alert('Please enter your email address');form.email.focus(); return false;}
	if (!CheckEmail(form.email.value)) {alert('Please enter a valid email address');form.email.focus(); return false;}
	if (form.message.value=='') {alert('Please enter your message');form.message.focus(); return false;}
	if (form.captcha.value=='') {alert('Please enter validation code');form.captcha.focus(); return false;}
	return true;
}


