var HideName="";
var ActiveMenuID=0;
var StartMenuID=0;
var StartSubOption=0;
var RollOn=0;
var RollDelay=0;
var SlideDelay=0;
var WaitForSlide=0;
var MaxHide=0;
var collDiv;


function popup_window( url, id){popup = window.open( url, id, 'toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=yes' )}
function ShowAsPopup(aName){
	if (HideName==""){
		if (RollOn==1){
			HideName=aName;
			document.all(HideName).className="rollin";
			window.setTimeout("tick();", 1000)
}}}
function tick(){
	if (HideName!=""){
		with (document.all(HideName)){
			className="rollout"
		};
		HideName=""
}}
function ShowSubMenu(menuID){
	if (menuID>=0 && menuID!=ActiveMenuID){
		HideSubMenu();
		if (document.all("SubMenu"+menuID)!=null){
			with (document.all("SubMenu"+menuID)){className="MenuOn"}
		}
		if (document.all("Menu"+menuID)!=null){
			document.all("Menu"+menuID).className="MenuSelect"
		}
		ActiveMenuID=menuID;
}}
function SubOptionSelect(menuSubOption){
		if (menuSubOption>=0 && ActiveMenuID!=0){
			if (document.all("Menu"+ActiveMenuID+"Option"+menuSubOption)!=null){
				document.all("Menu"+ActiveMenuID+"Option"+menuSubOption).className="MenuSelect"
}}}
function HideSubMenu(){
	if (ActiveMenuID>=0){
		if (document.all("SubMenu"+ActiveMenuID)!=null){
			with (document.all("SubMenu"+ActiveMenuID)){className="MenuOff"}
		}
		if (document.all("Menu"+ActiveMenuID)!=null){
			document.all("Menu"+ActiveMenuID).className="MenuDeselect"
		}
		ActiveMenuID=0;
}}
function Slider(aName){
	if (document.all(aName)!=null){
		with (document.all(aName)){
			filters[0].Apply();
			if (style.visibility=="visible"){
				style.visibility="hidden"
			}else{
				style.visibility="visible"
			};
			filters[0].Play();
			if (style.visibility=="visible"){
				if (RollDelay!=0){
					if (WaitForSlide!=1){
						WaitForSlide=1;
						window.setTimeout("SliderTick();", SlideDelay)
}}}}}}
function Hider(aNumber, AlwaysShow){
	if (document.all("HiderDiv")!=null && document.all("HiderImage")!=null){
		if (AlwaysShow==true || HiderDiv.style.visibility=="visible"){
			var aSrc="images/"+hideName[aNumber]+".gif";
			if (((HiderImage.src.indexOf(aSrc)>0) && (AlwaysShow==true)) || aNumber==0){
				HiderDiv.style.visibility="hidden";
			}else{
				HiderImage.src=aSrc;
				HiderDiv.style.visibility="visible"
}}}}
function SliderTick(){
	if (collDiv==null){
		collDiv=document.all.tags("DIV")
	};
	if (collDiv!=null){
		for (i=0;i<collDiv.length;i++){
			if (collDiv[i].className=="slider"){
				if (collDiv[i].style.visibility=="visible"){
					Slider(collDiv[i].id)
	}}}};
	WaitForSlide=0
}

function ValidatePurchaseForm(oForm){
var i;
var v;
var c;
var p;
var u;
var e;
var pc;

/* _ -----------------------------------------------------------------------------------------
_ 	Find the selected Product Code
_ 	and extract the Price & product name	format is "WM99Pxxx"
_ ----------------------------------------------------------------------------------------- */
	pc="";
	for (i=0;i < document.all("product").length; i++){
		if (document.all("product")[i].checked){
			pc=document.all("product")[i].value;
	}};
	p=pc.slice(0,2)
	if (p=="WM"){
		p="MAX";
	}else{
	if (p=="WV"){
		p="SmartVision";
	}else{
	if (p=="WO"){
		p="Omnis";
	}else{
	if (p=="WS"){
		p="Sigma";
	}else{
		p="";
	}}}};

	if (p==""){
		return false;
	}else{

		e=pc.slice(4,5);
		u=pc.slice(2,4);

/* _ -----------------------------------------------------------------------------------------
_ 	Validate CustomerID - must be 5 or 8 digits!
_ ----------------------------------------------------------------------------------------- */
		v=ID_CustomerID.value;					
		if ((v == "") || ((v.length != 5) && (v.length != 8))) {
			alert("Enter Your " + p + " Customer ID - Must be 5 or 8 digits");
			return false;
		};
		c=0;
		for (i=0;i < v.length; i++){
			if ((v.slice(i,(i+1))>="0") && (v.slice(i,(i+1))<="9")){c=c+1;}
		};
		if ((c!=5) && (c!=8)){
			alert("Enter Your " + p + " Customer ID - all 5 or 8 characters must be numeric");
			return false;
		};
/* _ -----------------------------------------------------------------------------------------
_ 	Validate Contact, Company and Emails
_ ----------------------------------------------------------------------------------------- */
		if (ID_contact.value == "") {
			alert("Pease enter your Contact Name");
			return false;
		};
		if (ID_email.value == "") {
			alert("Please enter your Email Address");
			return false;
		};
		if (ID_Company.value == "") {
			alert("Enter Your Company Name");
			return false;
		};
		if (ID_email.value != ID_emailValidate.value) {
			alert("Your eMail Validation does not match the eMail Address");
			return false;
		};

/* _ Expand p to full product description */

		if (e=="P"){
			p=" WinView For " + p + " Professional Edition"
		}else{
			if (e=="S"){
				p=" WinView For " + p + " Standard Edition"
			}else{
				p=" WinView For " + p + " Lite Edition"
			}
		};
		if (u=="99"){
			p="Site Licence for" + p;
		}else{
			if (u=="01"){
				p="Single user" + p;
			}else{
				p=u +" User Licence for" + p;
			}
		};
/* _									Must set email for mailform.pl */
		Order_Form.email.value=ID_email.value;

/* _ 									Product Code, Name, Value */
		oForm.item_number.value=pc.slice(0,5);
	 	oForm.item_name.value=p;
	 	oForm.amount.value=pc.slice(5)+".00";

/* _ FORTESTING!!
_ 		 oForm.amount.value="1.20";
_ REPLACE AMOUNT here (to stop test users going over limits) */

/* _									os0 is Details, os1 is Customer ID */
		oForm.os0.value=ID_contact.value + ", Company:" +ID_Company.value + ", Email:" +  ID_email.value;
		oForm.os1.value=ID_CustomerID.value;
/* _									custom is for all our data (packed together) */
		oForm.custom.value=v + ", Contact:"+oForm.os0.value + ", CustomerID:" + ID_CustomerID.value;
/* _									Ok - let ppal do its thing! */
		return true;
	}
}
