

function openTerms()
{
	newwin = window.open("/terms.html","terms","width=505,height=400,scrollbars=yes");
}

function openPrivacy()
{
	newwin = window.open("/privacy.html","terms","width=505,height=400,scrollbars=yes");
}

function emailAFriend(path)
{
	newwin = window.open("/emailafriend.aspx?path=" + path,"terms","width=470,height=470,scrollbars=yes");
}

function openAgreement()
{
	newwin = window.open("/productsupportagreement.html","Agreement","width=505,height=400,scrollbars=yes");
}

function openLargeImage(imageSrc)
{
	imageWindow = window.open("/imagepopup.html?image=" + imageSrc, "largeImage", "width=400,height=400,top=0,left=0,resizable=yes");
	imageWindow.focus();
}

function openLargeImage2(imageSrc)
{
	imageWindow = window.open("/imagepopup2.html?image=" + imageSrc, "largeImage", "width=400,height=400,top=0,left=0,resizable=yes");
	imageWindow.focus();
}

function navOver(imgName)
{
 var theImage = document.getElementById(imgName);
 if(theImage.src.indexOf("_off.gif") != -1)
 {
  theImage.src = theImage.src.replace("_off.gif","_over.gif");
 }
 else
 {
  theImage.src = theImage.src.replace("_over.gif","_off.gif");
 }
}



/* START NAVIGATION */
var menuOffDelay = 50;
onMenus = new Array();

function showMenu(whichMenu)
{
	onMenus.push(whichMenu);
	var windowWidth = getWindowWidth();
	navTop = 129;
	navLeft = (windowWidth - 796) / 2;
	
	
	var dropmenuobj = document.getElementById(whichMenu);

	dropmenuobj.style.top = navTop;
	
	switch(whichMenu)
	{
		case "newsAndEventsSubMenu" :
			dropmenuobj.style.left = ((navLeft + 11) + "px");					
			break;
			
		case "ourproductsSubMenu" :
			dropmenuobj.style.left = ((navLeft + 132) + "px");
			break;
			
		case "serviceSubMenu" :
			dropmenuobj.style.left = ((navLeft + 240) + "px");
			break;
			
		case "productsupportSubMenu" :
			dropmenuobj.style.left = ((navLeft + 312) + "px");
			break;
			
		case "requestquoteSubMenu" :
			dropmenuobj.style.left = ((navLeft + 433) + "px");
			break;
			
		case "aboutusSubMenu" :
			dropmenuobj.style.left = ((navLeft + 558) + "px");
			break;			
			
	}
	dropmenuobj.style.visibility = "visible";
} 


function getWindowWidth() 
{
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') 
	{
		windowWidth = window.innerWidth;				
		
		theDiv = document.getElementById("containerbg");
		theWidth = theDiv.offsetLeft * 2 + theDiv.offsetWidth;
		
		if(window.innerWidth > theWidth)
		{
		  windowWidth = theWidth;
		}  
			
	}
	else 
	{
		if (document.documentElement && document.documentElement.clientWidth) 
		{		
			windowWidth = document.documentElement.clientWidth;
		}
		else 
		{
			if (document.body && document.body.clientWidth) 
			{
				windowWidth = document.body.clientWidth;
			}
		}
	}
	
	return windowWidth;
}



function hideMenu(whichMenu)
{
	for(i=0;i<onMenus.length;i++)
	{
		if(onMenus[i] == whichMenu)
		{
			onMenus[i] = null;
			break;
		}
	}
	setTimeout("removeMenuNow('" + whichMenu + "');",menuOffDelay);
}

function removeMenuNow(whichMenu)
{
	var shouldBeVisible = false;
	for(i=0;i<onMenus.length;i++)
	{
		if(onMenus[i] == whichMenu)
		{
			shouldBeVisible = true;
			break;
		}
	}
	if(!shouldBeVisible)
	{
		var dropmenuobj = document.getElementById(whichMenu)
		dropmenuobj.style.visibility="hidden";
	}
}

/* END NAVIGATION */

/* newsletter subscription */
function validateEmail(theForm)
{
	valid = true;
	 
	if(theForm.elements["email"].value == "")
	{
	message = "Please enter your email address\n";
	valid = false;
	}
	
	if(theForm.elements["email"].value != "") 
	{
		 var supEmail = theForm.elements["email"].value;
		 var emLen = supEmail.length;
		 var posAt = supEmail.indexOf('@')
		 var posDot = supEmail.lastIndexOf('.')
		 if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
		 {
		  message = "Please enter a valid email address\n";
		  valid = false;
		 }
	}
	 
	if(valid)
	{
		return true;
	}
	
	else
	
	{
		alert(message);
		return false;
	}
} 
 

/* start validation */
function validateForm(theForm)
{
	valid = true;
	message = "So we can deal with your enquiry:\n\n";

	if(theForm.elements["firstname"].value == "")
	{
		message += "Please enter your first name\n";
		valid = false;
	}
	 
	if(theForm.elements["surname"].value == "")
	{
		message += "Please enter your surname\n";
		valid = false;
	}
	
	if(theForm.elements["email"].value == "")
	{
		message += "Please enter your email address\n";
		valid = false;
	}
	 
	if(theForm.elements["phone"].value == "")
	{
		message += "Please enter your phone number\n";
		valid = false;
	}
	 
	if(theForm.elements["email"].value != "")
	{
		var supEmail = theForm.elements["email"].value;
		var emLen = supEmail.length;
		var posAt = supEmail.indexOf('@')
		var posDot = supEmail.lastIndexOf('.')
		if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
		{
			message += "Please enter a valid email address\n";
			valid = false;
		}
	}
	
	if(valid)
	{
		return true;
	}
	else
	{
		alert(message);
		return false;
	}
}
/* end validation */

/* start validation */
function validateRequest(theForm)
{
	valid = true;
	message = "So we can deal with your request:\n\n";
 
	if(theForm.elements["firstname"].value == "")
	{
		message += "Please enter your first name\n";
		valid = false;
	}
	 
	if(theForm.elements["surname"].value == "")
	{
		message += "Please enter your surname\n";
		valid = false;
	}
	
	if(theForm.elements["email"].value == "")
	{
		message += "Please enter your email address\n";
		valid = false;
	}
	 
	if(theForm.elements["company"].value == "")
	{
		message += "Please enter your company name\n";
		valid = false;
	}
	 
	if(theForm.elements["email"].value != "")
	{
		var supEmail = theForm.elements["email"].value;
		var emLen = supEmail.length;
		var posAt = supEmail.indexOf('@')
		var posDot = supEmail.lastIndexOf('.')
		if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
		{	
			message += "Please enter a valid email address\n";
			valid = false;
		}
	}
	
	if(valid)
	{
		return true;
	}
	
	else
	
	{
		alert(message);
		return false;
	}
}


/* start validation */
function validateRequestAccess(theForm)
{
	valid = true;
	message = "So we can process your access request:\n\n";
	
	if(theForm.elements["product_name"].value == "")
	{
		message += "Please enter the product name\n";
		valid = false;
	}
	 
	if(theForm.elements["part_number"].value == "")
	{
		message += "Please enter the part number\n";
		valid = false;
	}
	 
	if(theForm.elements["serial_number"].value == "")
	{
		message += "Please enter the serial number\n";
		valid = false;
	} 
	 
	if(theForm.elements["firstname"].value == "")
	{
		message += "Please enter your first name\n";
		valid = false;
	}
	 
	if(theForm.elements["surname"].value == "")
	{
		message += "Please enter your surname\n";
		valid = false;
	}
	
	if(theForm.elements["phone"].value == "")
	{
		message += "Please enter your phone number\n";
		valid = false;
	}
	 
	if(theForm.elements["email"].value != "")
	{
		var supEmail = theForm.elements["email"].value;
		var emLen = supEmail.length;
		var posAt = supEmail.indexOf('@')
		var posDot = supEmail.lastIndexOf('.')
		if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
		{
			message += "  Please enter a valid email address\n";
			valid = false;
		}
	}
	 
	if(theForm.elements["email"].value == "")
	{
		message += "Please enter your email address\n";
		valid = false;
	}
	
	if(document.getElementById("agreement").checked == "")
	{
		message += "Indicate that you agree with the terms of use\n";
		valid = false;
	}
	 
	if(valid)
	{
		return true;
	}
	
	else
	
	{
		alert(message);
		return false;
	}
}
/* end validation */

/* start validation */
function validateFaultReport(theForm)
{
	valid = true;
	message = "So we can deal with your fault report:\n\n";

	if(theForm.elements["coil_description"].value == "")
	{
		message += "Please enter the coils description\n";
		valid = false;
	}
	 
	if(theForm.elements["part_serialnumber"].value == "")
	{
		message += "Please enter the coils part and serial number\n";
		valid = false;
	}
	
	if(theForm.elements["company"].value == "")
	{
		message += "Please enter the name of your company/institute\n";
		valid = false;
	}
	 
	if(theForm.elements["name"].value == "")
	{
		message += "Please enter your name\n";
		valid = false;
	}
	 
	if(theForm.elements["address"].value == "")
	{
		message += "Please enter your location\n";
		valid = false;
	}
	 
	if(document.getElementById('termAgreement').checked != true)
	{
		message += "Please indicate that you agree to the terms and conditions\n";
		valid = false;
	}	 	 
	
	if(valid)
	{
		return true;
	}
	else
	{
		alert(message);
		return false;
	}
}
/* end validation */

/* start validation */
function validateFaultReport_BioVet(theForm)
{
	valid = true;
	message = "So we can deal with your fault report:\n\n";

	if(theForm.elements["biovet_serialnumber"].value == "")
	{
		message += "Please enter the BioVet serial number\n";
		valid = false;
	}
	 
	
	if(theForm.elements["company"].value == "")
	{
		message += "Please enter the name of your company/institute\n";
		valid = false;
	}
	 
	if(theForm.elements["name"].value == "")
	{
		message += "Please enter your name\n";
		valid = false;
	}
	 
	if(theForm.elements["address"].value == "")
	{
		message += "Please enter your location\n";
		valid = false;
	}
	 
	if(document.getElementById('termAgreement').checked != true)
	{
		message += "Please indicate that you agree to the terms and conditions\n";
		valid = false;
	}	 	 
	
	if(valid)
	{
		return true;
	}
	else
	{
		alert(message);
		return false;
	}
}
/* end validation */

/* start validation */
function validateProductRegistration(theForm)
{
	valid = true;
	message = "So we can deal with your product registration:\n\n";

	if(theForm.elements["firstname"].value == "")
	{
		message += "Please enter your first name\n";
		valid = false;
	}
	 
	if(theForm.elements["surname"].value == "")
	{
		message += "Please enter your surname\n";
		valid = false;
	}
		

	if(theForm.elements["phone"].value == "")
	{
		message += "Please enter your phone number\n";
		valid = false;
	}

	if(theForm.elements["email"].value == "")
	{
		message += "Please enter your email address\n";
		valid = false;
	}
				
			 
	if(theForm.elements["email"].value != "")
	{
		var supEmail = theForm.elements["email"].value;
		var emLen = supEmail.length;
		var posAt = supEmail.indexOf('@')
		var posDot = supEmail.lastIndexOf('.')
		if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
		{
			message += "Please enter a valid email address\n";
			valid = false;
		}
	}
		
	if(theForm.elements["mailingAddress"].value == "")
	{
		message += "Please enter your mailing address\n";
		valid = false;
	}
		
	if(theForm.elements["postcode"].value == "")
	{
		message += "Please enter your postcode\n";
		valid = false;
	}	 
	
	if(valid)
	{
		return true;
	}
	else
	{
		alert(message);
		return false;
	}
}
/* end validation */

// Flash test
var isDOM = (document.getElementById) ? true : false;
var isIE = (navigator.appName == "Microsoft Internet Explorer") ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var isNetscape = (!isOpera && (navigator.appName.indexOf("Netscape") != -1 && navigator.userAgent.indexOf("4.") != -1)) ? true : false;
var isMac = (navigator.userAgent.indexOf("Mac") != -1) ? true : false;

var bUsedHTML = ((isDOM || isIE || isNetscape) && !isMac) ? true : false
var iLatestFlashVersion = 7;
var iMinimumFlashVersion = 6;
var iFlashVersion = -1;

// Variable must be global for VBScript to work correctly.
var thisFlashVersion;
function flash_getIEVersion() 
{
	var thisMaxVersion = false;
	for(var currentVersion=iMinimumFlashVersion; currentVersion<=iLatestFlashVersion; currentVersion++)
	{
		document.write('<SCR'+'IPT LANGUAGE="VBScript">\n');
		document.write('on error resume next\n');
		document.write('thisFlashVersion = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+currentVersion+'")))\n');
		document.write('</SCR'+'IPT>\n');

		if(thisFlashVersion) 
		{
			thisMaxVersion = currentVersion;
		}
		
	}
	return thisMaxVersion;
}

function flash_setVersion() 
{
	if (navigator.plugins.length > 0) 
	{
		// Plugin detect, no VBScript support
		navigator.plugins.refresh(false);
		numPlugins = navigator.plugins.length;
		for(var i=0; i<numPlugins; i++)	
		{
			plugDesc = navigator.plugins[i].description;
			iFlashVersion = (plugDesc.indexOf("Flash") != -1) ? parseInt(plugDesc.charAt(parseInt(plugDesc.indexOf("Flash"))+6)) : 0;
			if(iFlashVersion > 0) 
			{
				return;
			}
		}
		
	} 
	
	else if(!isMac && (isIE || isOpera)) 
	
	{
		// No plugin detect, VBScript support
		iFlashVersion = flash_getIEVersion();
	} 
	
	else 
	
	{
		// No plugin detect, no VBScript support
		iFlashVersion = iLatestFlashVersion;
	}
}

// Set Flash Version
flash_setVersion();

function printFlash(flashSRC, imageSRC, width, height, map)
{
	var pntStr;
	if(iFlashVersion >= iMinimumFlashVersion)
	{
		pntStr = "<object width=" + width + " height=" + height + " VIEWASTEXT>";
		pntStr += "<param name='movie' value='" + flashSRC + "'>";
		pntStr += "<param name='quality' value='high'>";
		pntStr += "<embed src='" + flashSRC + "' quality='high' ";
		pntStr += "type='application/x-shockwave-flash' width=" + width + " height=" + height + " wmode='opaque'>";
		pntStr += "</embed></object>";
	}
	else
	{
		pntStr = "<img usemap='#" + map + "' src='" + imageSRC + "' width=" + width + " height=" + height + " alt='' border=0>";
	}
	
	document.write(pntStr);
}

function setNavigation(valueID)
{
	var theId = valueID;
	
	if(theId == "news")
	{		
		var imageID = document.getElementById("newsevents");
		imageID.src = imageID.src.replace("_off.gif","_on.gif");		
	}
	
	else if(theId == "products")
	{
		var imageID = document.getElementById('ourproducts');
		imageID.src = imageID.src.replace("_off.gif","_on.gif");
	}
	
	else if (theId == "service")
	{
		var imageID = document.getElementById('service');
		imageID.src = imageID.src.replace("_off.gif","_on.gif");	
	}
	
	else if (theId == "productSupport")
	{
		var imageID = document.getElementById('productsupport');
		imageID.src = imageID.src.replace("_off.gif","_on.gif");	
	}
	
	else if (theId == "requestQuote")
	{
		var imageID = document.getElementById('requestaquote');
		imageID.src = imageID.src.replace("_off.gif","_on.gif");	
	}	
	
	else if(theId == "aboutUs")
	{
		var imageID = document.getElementById('aboutus');
		imageID.src = imageID.src.replace("_off.gif","_on.gif");	
	}
	
	else if (theId == "contactUs")
	{
		var imageID = document.getElementById('contactus');
		imageID.src = imageID.src.replace("_off.gif","_on.gif");	
	}				
	
}

function NavOver(imgID)
{
	var theImage = document.getElementById(imgID);
	
	if(theImage.src.indexOf("_off.gif") != -1)	
	{
		theImage.src = theImage.src.replace("_off.gif","_over.gif");
	}
	
	else if(theImage.src.indexOf("_over.gif") != -1)	
	{
		theImage.src = theImage.src.replace("_over.gif","_off.gif");
	}

}



