Array.prototype.indexOf = function(v){
       for(var i = this.length; i-- && this[i] !== v;);
       return i;
};

function get9() {
	var list = new Array();

	for (var count = 0; count < 9;) {
		var no = Math.floor(Math.random() * 19);
		
		if (list.indexOf(no) <= -1) {
			list[list.length] = no;
			count++;
		}
	}

	return list;
}

function output(arr,folder) {
var insurerImages=new Array()
//specify random images below. You can have as many as you wish
insurerImages[0]="/images/insurers/insurers_aetna.jpg"
insurerImages[1]="/images/insurers/insurers_allianz.jpg"
insurerImages[2]="/images/insurers/insurers_axa_ppp.jpg"
insurerImages[3]="/images/insurers/insurers_bluecross.jpg"
insurerImages[4]="/images/insurers/insurers_bupa.jpg"
insurerImages[5]="/images/insurers/insurers_cigna.jpg"
insurerImages[6]="/images/insurers/insurers_expacare.jpg"
insurerImages[7]="/images/insurers/insurers_globalhealth.jpg"
insurerImages[8]="/images/insurers/insurers_gmc.jpg"
insurerImages[9]="/images/insurers/insurers_goodhealth.jpg"
insurerImages[10]="/images/insurers/insurers_healthcare.jpg"
insurerImages[11]="/images/insurers/insurers_ihi.jpg"
insurerImages[12]="/images/insurers/insurers_img.jpg"
insurerImages[13]="/images/insurers/insurers_integra_global.jpg"
insurerImages[14]="/images/insurers/insurers_interglobal.jpg"
insurerImages[15]="/images/insurers/insurers_international_sos.jpg"
insurerImages[16]="/images/insurers/insurers_medicare.jpg"
insurerImages[17]="/images/insurers/insurers_mnu.jpg"
insurerImages[18]="/images/insurers/insurers_william_russell.jpg"

//specify corresponding links below
var imagelinks=new Array()
imagelinks[0]=folder+"/aetna.php"
imagelinks[1]=folder+"/allianz.php"
imagelinks[2]=folder+"/axa-ppp.php"
imagelinks[3]=folder+"/blue-cross.php"
imagelinks[4]=folder+"/bupa.php"
imagelinks[5]=folder+"/cigna.php"
imagelinks[6]=folder+"/expacare.php"
imagelinks[7]=folder+"/global-health.php"
imagelinks[8]=folder+"/gmc-services-international.php"
imagelinks[9]=folder+"/goodhealth.php"
imagelinks[10]=folder+"/healthcare-international.php"
imagelinks[11]=folder+"/ihi-danmark.php"
imagelinks[12]=folder+"/img.php"
imagelinks[13]=folder+"/integra-global.php"
imagelinks[14]=folder+"/interglobal.php"
imagelinks[15]=folder+"/international-sos.php"
imagelinks[16]=folder+"/medicare-international.php"
imagelinks[17]=folder+"/multinational-underwriters.php"
imagelinks[18]=folder+"/william-russel.php"

	var s = "";
	var tablestring = "";
	var imageLoc = "";
	//var lang = "";
		
	tablestring = "<table border='0' width='100%' cellspacing='0' cellpadding='0'><tr>";
		
	for (var i = 0; i < arr.length; i++) {	
		var imageNewOrder = arr[i]
		if (i == 3 || i == 6)
		{
				tablestring = tablestring + "</tr>"
		}
		tablestring = tablestring + "<td width='33%' style='text-align:center;' ><img src='" + insurerImages[imageNewOrder] + "' style='cursor:pointer' onClick=location.href='/" + imagelinks[imageNewOrder] + "';></td>";
	}
	
	tablestring = tablestring + "</tr></table>";
	return tablestring;
}

function btnOver(obj, image, fileType) {
	obj.src=image + "_b." + fileType;
}

function btnOut(obj, image, fileType) {
	obj.src=image + "_a." + fileType;
}

function goPlan(plan) {
	for(var i = 0; i < plan.length; i++) {
		if(plan[i].checked) {
			var filename = plan[i].value;
		}
	}
   this.location.href="quotation/" + filename + ".php";
}

function 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=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];}}
}

// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

function redirectTravel(source,type,countryOfCover,lengthOfCover)
{
	if(lengthOfCover=='0 to 3 months' && countryOfCover!='----------------' && countryOfCover!='' && countryOfCover!='China' && countryOfCover!='China Only' && countryOfCover!='Hong Kong' && countryOfCover!='HK' && countryOfCover!='Macau')
		{window.location='redirectToTravel.php?fromPage=quote1&countryofcoverage='+countryOfCover+'&source='+source+'&type='+type;}
}



function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}


function updatetopage(topage,frompage){
	
	var http = createRequestObject(); 
	var url = "/quotation/updateToPage.php?toPage=" + topage;	
	url += '&fromPage=' + frompage;
	http.open("GET",url,true);
	http.send(null);
}

function resizeFrame() {

var f = document.getElementById('ifq');
//alert(f.contentWindow.document.body.scrollHeight);//1 for fix quake
f.style.height = f.contentWindow.document.body.scrollHeight+1 + 'px';
}

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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

