var htmlLocation = "http://www.vivashealth.ie";
var httpsLocation = "https://www.vivashealth.ie/SECURE";
var buyNowLocation = httpsLocation +"/html/buynowframeset.aspx";
var logInLocation = httpsLocation +"/html/loginframeset.aspx";
var businesslogInLocation = httpsLocation +"/secure/logon.aspx";
var intermediariesLogInLocation = httpsLocation +"/secure/logon.aspx";
var medicalProvidersLogInLocation = httpsLocation +"/secure/logon.aspx";
var contactUsLocation = httpsLocation +"/contactUs.jsp";
var quoteLocation = httpsLocation + "/html/quickquoteframeset.aspx";

var currentMotion = 0;
var currentPos = 0;
var distanceToMouse = 0;
var springConstant = 80;
var decay = 0.93;
var browserType = "";
notUsingIE = false;

//Preload images
/*
if(document.images) {

	//preload images
	home_off = new Image();
	home_off.src = "images/menubar/menu_home_off.gif";
	
	home_on = new Image();
	home_on.src = "images/menubar/menu_home_on.gif";
	
	buynow_off = new Image();
	buynow_off.src = "images/menubar/menu_buynow_off.gif";
	
	buynow_on = new Image();
	buynow_on.src = "images/menubar/menu_buynow_on.gif";
	
	ourplans_off = new Image();
	ourplans_off.src = "images/menubar/menu_ourplans_off.gif";
	
	ourplans_on = new Image();
	ourplans_on.src = "images/menubar/menu_ourplans_on.gif";
	
	plandetails_off = new Image();
	plandetails_off.src = "images/menubar/menu_plandetails_off.gif";
	
	plandetails_on = new Image();
	plandetails_on.src = "images/menubar/menu_plandetails_on.gif";
	
	contactus_off = new Image();
	contactus_off.src = "images/menubar/menu_contactus_off.gif";
	
	contactus_on = new Image();
	contactus_on.src = "images/menubar/menu_contactus_on.gif";
	
	whatsnew_off = new Image();
	whatsnew_off.src = "images/menubar/menu_whatsnew_off.gif";
	
	whatsnew_on = new Image();
	whatsnew_on.src = "images/menubar/menu_whatsnew_on.gif";
	
	aboutus_off = new Image();
	aboutus_off.src = "images/menubar/menu_aboutus_off.gif";
	
	aboutus_on = new Image();
	aboutus_on.src = "images/menubar/menu_aboutus_on.gif";
	
	faqs_off = new Image();
	faqs_off.src = "images/menubar/menu_faqs_off.gif";
	
	faqs_on = new Image();
	faqs_on.src = "images/menubar/menu_faqs_on.gif";
	
	login_off = new Image();
	login_off.src = "images/menubar/menu_login_off.gif";
	
	login_on = new Image();
	login_on.src = "images/menubar/menu_login_on.gif";

	business_off = new Image();
	business_off.src = "images/sidebar/business_btn_off.gif";
	
	business_on = new Image();
	business_on.src = "images/sidebar/business_btn_on.gif";
	
	travelInsurance_off = new Image();
	travelInsurance_off.src = "images/sidebar/travelInsurance_btn_off.gif";
	
	travelInsurance_on = new Image();
	travelInsurance_on.src = "images/sidebar/travelInsurance_btn_on.gif";
	
	irishHealth_off = new Image();
	irishHealth_off.src = "images/sidebar/irishHealth_btn_off.gif";
	
	irishHealth_on = new Image();
	irishHealth_on.src = "images/sidebar/irishHealth_btn_on.gif";
	
	intermediaries_off = new Image();
	intermediaries_off.src = "images/sidebar/intermediaries_btn_off.gif";
	
	intermediaries_on = new Image();
	intermediaries_on.src = "images/sidebar/intermediaries_btn_on.gif";
	
	medical_providers_off = new Image();
	medical_providers_off.src = "images/sidebar/medical_providers_btn_off.gif";
	
	medical_providers_on = new Image();
	medical_providers_on.src = "images/sidebar/medical_providers_btn_on.gif";
	
	login_btn_off = new Image();
	login_btn_off.src = "images/sidebar/login_btn_off.gif";
	
	login_btn_on = new Image();
	login_btn_on.src = "images/sidebar/login_btn_on.gif";

	switchnow_off = new Image();
	switchnow_off.src = "images/sidebar/switchnow_off.jpg";
	
	switchnow_on = new Image();
	switchnow_on.src = "images/sidebar/switchnow_on.jpg";

	member_on = new Image();
	member_on.src = "images/sidebar/member_btn_on.gif";
	
	member_off = new Image();
	member_off.src = "images/sidebar/member_btn_off.gif";

	discount_on = new Image();
	discount_on.src = "images/Offer Red1-100.gif";
	
	discount_off = new Image();
	discount_off.src = "images/Offer Green1-100.gif";

	discountbig_on = new Image();
	discountbig_on.src = "images/Offer Red1-255.gif";
	
	discountbig_off = new Image();
	discountbig_off.src = "images/Offer Green1-255.gif";
	
	buynownew_on = new Image();
	buynownew_on.src = "images/sidebar/buynownewon.gif";
	
	buynownew_off = new Image();
	buynownew_off.src = "images/sidebar/buynownew.gif";
	
	
}
*/

//Perform browser check
switch(navigator.family)
{
	case 'gecko':
		if (navigator.org == 'netscape'){
			// Netscape 6.x and higher
			browserType = "ns6";
			}
		if (navigator.org == 'mozilla'){
			// Mozilla browsers
			browserType = "mozilla";
			}
		else{
			// other Mozilla based browsers
			browserType = "nsx";
			}
		break;
		  
	case 'ie4':
		if (navigator.version >= 5){
			// IE 5.x
			browserType = "ie5";
			}
		if (navigator.version >= 5.5){
			// IE 5.5
			browserType = "ie55";
			}
		if (navigator.version >= 6){
			// IE 6.0+
			browserType = "ie6";
			}
		if (navigator.version < 5){
			// IE 4.x
			browserType = "ie4";
			}
		break;
		  
	case 'nn4':
		// Netscape Navigator 4.x
		browserType = "ns4";
		break;
}

// Find out if browser supports flash
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
	if (navigator.plugins && navigator.plugins["Shockwave Flash"])
		plugin = 1;
	}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))\n');
	document.write('if ( plugin <= 0 ) then plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');
	document.write('if ( plugin <= 0 ) then plugin = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
	document.write('</SCRIPT\> \n');
	}

function MM_findObj(n, d) { //v4.0
	
	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 && document.getElementById)
		x=document.getElementById(n);
	
	return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0

	var obj = MM_findObj(objName);
	
	if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}

function MM_getProp(objName,theProp) { //v3.0

	var obj = MM_findObj(objName);
	
	if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("var y = obj."+theProp+";");
	return y;
}


function simulateSpringMotion(){
	if(browserType.indexOf("ie") != -1 && browserType != "ie4"){
		currentPos = MM_getProp("arrowdn","style.left");
		if(currentPos == null){ MM_getProp("arrowdn","left"); }
		currentPos = parseFloat(currentPos.substr(0, currentPos.length - 2));
		
		distanceToMouse = Xpos - currentPos;
		acceleration = distanceToMouse / springConstant;
		currentMotion = currentMotion + acceleration;
		currentMotion = currentMotion * decay;
		
		MM_changeProp("arrowdn",'','style.left',currentPos + currentMotion,'LAYER');
		MM_changeProp("arrowdn",'','left',currentPos + currentMotion,'LAYER');
		MM_changeProp("arrowup",'','style.left',currentPos + currentMotion,'LAYER');
		MM_changeProp("arrowup",'','left',currentPos + currentMotion,'LAYER');
		}
	else {
		stopArrowMove();
		document.images.arrowdnpic.src = "images/spacer.gif";
		document.images.arrowuppic.src = "images/spacer.gif";
		}
}

function startArrowMove(){
	movePointer = setInterval( "simulateSpringMotion()", 1 );
}

function stopArrowMove(){
	clearInterval(movePointer);
}

function imageOn(imageName) {
	if (document.images) {
		eval("document." + imageName + ".src = " + imageName + "_on.src;");
		}
}

function imageOff(imageName) {
	if (document.images) {
		eval("document." + imageName + ".src = " + imageName + "_off.src;");
		}
}

function replaceChar(myString, myChar, myReplacement) {

	//Loop to find the first instance of the character
	//and remove it, until the first instance of the
	//charcter occurs at position -1

	myString = escape(myString);
	var n = myString.indexOf(myChar);
	while( n != -1 ){
		myString = myString.substr(0, n) + escape(myReplacement) + myString.substr(n + myChar.length, myString.length - myChar.length);
		n = myString.indexOf(myChar);
		}
	return unescape(myString);
}

function openWindow(width, height, xpos, ypos, content, name){
	eval("window.open('" + content + "', '" + name + "', 'width=" + width + ",height=" + height + ",resizable=1,top=" + ypos + ",left=" + xpos + ",scrollbars=1');");
}

function insertFlash(flashFile, imageFile, movieWidth, movieHeight, thisURL, mapName){

	flashLocation = "flash/";
	imageLocation = "images/flash";
	movieName = flashFile.substring(0, flashFile.indexOf(".swf"));
		
	if ( plugin ) {
		document.writeln("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='" + movieWidth + "' height='" + movieHeight + "' id='" + movieName + "'>");
		document.writeln("	<param name=movie value='" + flashLocation + flashFile + "'>");
		document.writeln("	<param name=quality value=high>");
		document.writeln("	<param name=wmode value=transparent>");
		document.writeln("	<embed src='" + flashLocation + flashFile + "'");
		document.writeln("		quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'");
		document.writeln("		name='" + movieName + "'");
		document.writeln("		type='application/x-shockwave-flash'");
		document.writeln("		wmode='transparent'");
		document.writeln("		width='" + movieWidth + "'");
		document.writeln("		height='" + movieHeight + "'>");
		document.writeln("	</embed>");
		document.writeln("</object>");
		}
	else {
		if (thisURL == ""){
			document.writeln("<img src='" + imageLocation + imageFile + "' border=0>");
			}
		else{
			document.writeln("<a href='" + thisURL + "'><img src='" + imageLocation + imageFile + "' border=0 usemap='" + mapName + "'></a>");
			}
		}
	}

function exitSite(toURL) {
	if (confirm("You are about to go to an external site which does not belong to and is not operated by VIVAS Health. You are reminded that your use of this external site is subject to the terms and conditions of that site. Continue?"))
		//window.location = toURL;
		window.open(toURL);
}
