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) {
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]="insurers/aetna.php"
imagelinks[1]="insurers/allianz.php"
imagelinks[2]="insurers/axa-ppp.php"
imagelinks[3]="insurers/blue-cross.php"
imagelinks[4]="insurers/bupa.php"
imagelinks[5]="insurers/cigna.php"
imagelinks[6]="insurers/expacare.php"
imagelinks[7]="insurers/global-health.php"
imagelinks[8]="insurers/gmc-services-international.php"
imagelinks[9]="insurers/goodhealth.php"
imagelinks[10]="insurers/healthcare-international.php"
imagelinks[11]="insurers/ihi-danmark.php"
imagelinks[12]="insurers/img.php"
imagelinks[13]="insurers/integra-global.php"
imagelinks[14]="insurers/interglobal.php"
imagelinks[15]="insurers/international-sos.php"
imagelinks[16]="insurers/medicare-international.php"
imagelinks[17]="insurers/multinational-underwriters.php"
imagelinks[18]="insurers/william-russel.php"

	var s = "";
	var tablestring = "";
	
	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><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);
}
