var rimage;

function init(i) {
	rimage = i;
	document['mainImage'].src = i;
}

function rolloverRestore(img_name) {
	document[img_name].src = rimage;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function roll_over(img_name, img_src)
   {
   document[img_name].src = img_src;
   }
   
function showDiv(divName){ 
   if (document.all) { 
      document.all[divName].style.visibility = "visible" 
   } 
   else { 
      document.getElementById(divName).style.visibility = "visible" 
   }  
} 

function hideDiv(divName){ 
   if (document.all) { 
      document.all[divName].style.visibility = "hidden" 
   } 
   else { 
      document.getElementById(divName).style.visibility = "hidden" 
   }  
}

function loadPage(page) {
	document.location.href = page;
}

function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}
 
function validate(f)
{
  if (f.Name.value == "")
  {
     alert("Sorry - Name appears to be blank!");
     return false;
  }
  return true;
}

function changeZone(z) {
   document.shipping.zn.selectedIndex = z;
}

function showViewcart() {
   if (document.all) { 
      document.all['popup'].style.visibility = "visible"
   } 
   else { 
      document.getElementById('popup').style.visibility = "visible" 
   }  
   frames['viewcart'].location.href = "http://www.idxtra.com/php/viewcart.php";   
}

function showPdf(nm) {
   if (document.all) { 
      document.all['pdfwin'].style.visibility = "visible"
   } 
   else { 
      document.getElementById('pdfwin').style.visibility = "visible" 
   }  
   frames['brochure'].location.href = nm;   
}	

function customLanyards() {
   if (document.all) { 
      document.all['lanyards'].style.visibility = "visible"
   } 
   else { 
      document.getElementById('lanyards').style.visibility = "visible" 
   }  
   frames['clan'].location.href = 'http://www.idxtra.com/customlan.html';   
}	

function viewPic(pic) {
   nm = "http://www.idxtra.com/php/viewpic.php?pic=";
   nm = nm + pic;
   
   if (document.all) { 
      document.all['pics'].style.visibility = "visible"
   } 
   else { 
      document.getElementById('pics').style.visibility = "visible" 
   }  
   frames['largepic'].location.href = nm;   
}

function showSpec(nm) {
   if (document.all) { 
      document.all['specs'].style.visibility = "visible"
   } 
   else { 
      document.getElementById('specs').style.visibility = "visible" 
   }  
   frames['prodspec'].location.href = nm;   
}	

function printPage()
{
window.print();
}

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Handle all the the FSCommand messages in a Flash movie

function main1_DoFSCommand(command, args) {

  var main1Obj = InternetExplorer ? main1 : document.main1;

	if (command == "messagebox") {

//		alert(args);

		parent.location.href = "http://www.idxtra.com/shared/registration.html";

	}

}
// Hook for Internet Explorer 

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {

	document.write('<SCRIPT LANGUAGE=VBScript\> \n');

	document.write('on error resume next \n');

	document.write('Sub main1_FSCommand(ByVal command, ByVal args)\n');

	document.write('  call main1_DoFSCommand(command, args)\n');

	document.write('end sub\n');

	document.write('</SCRIPT\> \n');

}

function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

   function validate(f)
   {
     if (f.Name.value == "")
     {
        alert("Sorry - Name appears to be blank!");
        return false;
     }
     else if (f.JobTitle.value == "")
     {
        alert("Sorry - Job Title appears to be blank!");
        return false;
     }
		 else if (f.Org.value == "")
     {
        alert("Sorry - Organisation appears to be blank!");
        return false;
     }
		 else if (f.Address1.value == "")
     {
        alert("Sorry - the first address line appears to be blank!");
        return false;
     }
		 else if (f.Postcode.value == "")
     {
        alert("Sorry - Postcode or Zipcode appears to be blank!");
        return false;
     }
		 else if (f.Country.value == "")
     {
        alert("Sorry - Country appears to be blank!");
        return false;
     }
		 else if (f.Email.value == "")
     {
        alert("Sorry - Email appears to be blank!");
        return false;
     }
 		 else if (!isEmailAddr(f.Email.value))
     {
		 		alert("Sorry - Email address appears not to be valid!");
        return false;
     }

     return true;
   }
   

function changePrice(totPrc,prc,frm,s1,s2,check1,check2) {
 
   if (check1 == 1) {
      var select1Array=document.forms[frm].select1.value.split(":");
   }
   
   if (check2 == 1) {
      var select2Array=document.forms[frm].select2.value.split(":");
   }
   
   if (check1 == 1) {
      totPrc = totPrc + parseFloat(select1Array[1]);
   }
   
   if (check2 == 1) {
      totPrc = totPrc + parseFloat(select2Array[1]);
   }
   
   document.getElementById(prc).innerHTML = totPrc.toFixed(2);
   
}

function validateForm(frm,a,b,c) {
	if (a == 1) {
   	   if (document.forms[frm].select1.selectedIndex==0) { 
	      alert('Please Select Your Model Choice.'); 
	      return false; 
	   }
	}
	
	if (b == 1) {
	   if (document.forms[frm].clr.selectedIndex==0) {
		   alert('Please Select Your Colour.');
		   return false;
	   }
	}
	
	if (c == 1) {
	   if (document.forms[frm].select2.selectedIndex==0) { 
	      alert('Please Select Your Service Option.'); 
	      return false; 
	   }
	}		
}

function validateContact(f) {
	     if (f.Name.value == "")
     {
        alert("Sorry - Name appears to be blank!");
        return false;
     }
     else if (f.JobTitle.value == "")
     {
        alert("Sorry - Job Title appears to be blank!");
        return false;
     }
		 else if (f.Org.value == "")
     {
        alert("Sorry - Organisation appears to be blank!");
        return false;
     }
		 else if (f.Email.value == "")
     {
        alert("Sorry - Email appears to be blank!");
        return false;
     }
 		 else if (!isEmailAddr(f.Email.value))
     {
 		alert("Sorry - Email address appears not to be valid!");
        return false;
     }
	    else if (f.Comment.value == "") 
	 {
		alert("Sorry - You must enter your comments!");
		return false;
	 }

     return true;
}
