/*
	'--------------------------------------------------------------
	'--- File Name: mouseovers, layers, clipping for layers for all sections
	'--- Module: 
	'--- Purpose: 
	'---		
	'--- Called From:
	'---		
	'--- Calls: 
	'---	/js/js_variables.js	
	'--- Inputs:
	'---		
	'--- Outputs:
	'---
	'--- VERSION HISTORY: (newest at top)
	'---		05/03/02 - MSallave added popup for Gallery
	'---		04/11/02 - MSallave- created
	'---		
	'---		
*/
//onload and onresize feature
function init() {
	if (ntsp){
		block = document.MyFolder;
		winNtspSize = window.innerWidth;
		if (winNtspSize <= 788){
			document.layers.MyFolder.left = 590;
		}
		else{
			document.layers.MyFolder.left = window.innerWidth - 167;
		}
	}
	else if (ie){
		block = MyFolder.style;
		WinIESize = document.body.clientWidth;
		if (WinIESize <= 740){
			document.all.MyFolder.style.left = 565; 
		} 
		else {
			if (navigator.appVersion.indexOf("Mac") != -1){
			document.all.MyFolder.style.left = WinIESize - 150;
			}
			else{
			document.all.MyFolder.style.left = WinIESize - 165;
			}
		}
	}
}

//resizing of Netscape
function handleResize() {
//alert(ntsp);
	if (ntsp){
		document.location.reload(); 
		return false;
	}
}


 //image rollovers that call the images name and the number of the image with the array
 function imgOff(imgName) {
        if (document.images) {
            document[imgName].src = eval(imgName + "_off.src");
        }
}

function imgOn(imgName) {
        if (document.images) {
            document[imgName].src = eval(imgName + "_on.src");
        }
}

/*
************************************************************************************
Description: Show/Hide Tech Popups for Model Content Pages
Author: Bao Dang
Date: 06/22/05
************************************************************************************
*/

//shows popup on tooltip on click
var layeropen = "";      //     id   ,     flagit
function showModelLayerPopup(eventObj, currentElement) {

	hideLayers();
	
	if (document.layers) document.layers[''+currentElement+''].visibility = "show"
	else if (document.all) document.all[''+currentElement+''].style.visibility = "visible"
	else if (document.getElementById) document.getElementById(''+currentElement+'').style.visibility = "visible"
}

// hide layers
function hideLayers() {
	for (i=0;i<document.getElementsByTagName("div").length; i++) {
			if (document.getElementsByTagName("div").item(i).className == "techpop1"){
				document.getElementsByTagName("div").item(i).style.visibility = "hidden";
			}
		}
}
	

/*
************************************************************************************
Description: Show/Hide Layer for MyFolder
Author: Bao Dang
************************************************************************************
*/

function getMyFolder(id,flagit) {

var MyFolderLeft = document.body.offsetWidth - 186;

	if (flagit=="1"){
		if (document.layers) document.layers[''+id+''].visibility = "show"
			else if (document.all) {
				document.all[''+id+''].style.visibility = "visible";
				//document.all[''+id+''].style.position = "absolute";
				document.all[''+id+''].style.left = MyFolderLeft;
				//alert('IE');
			}
			else if (document.getElementById) {
			 	document.getElementById(''+id+'').style.visibility = "visible"
				document.getElementById(''+id+'').style.left = MyFolderLeft + 21;
				document.getElementById(''+id+'').style.top = 220;
				//alert('FIREFOX');
			 }
		}
	else
	if (flagit=="0"){
		if (document.layers) document.layers[''+id+''].visibility = "hide"
			else if (document.all) document.all[''+id+''].style.visibility = "hidden"
			else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
	}
}


//used in bookmarks section
function showMenu(currentElement){
	if (ie){ 
		document.all[currentElement].style.visibility = 'visible';
	}
	else if (ntsp){ 
		document.layers[currentElement].visibility = 'show';
	}
}
	
// Hides layer when off
// Code Modifed for Firefox compatibility
// Modified: 06/22/050
function reHide(currentElement){
	
	if (document.layers) {
		document.layers[''+currentElement+''].visibility = "hide";
	} 
	
	else if (document.all) {
		document.all[''+currentElement+''].style.visibility = "hidden";
	} 
	
	else if(document.getElementById) {
		document.getElementById(''+currentElement+'').style.visibility = "hidden"
	}
	
	/* removed BD - 06/22
	if (ie){ 
		document.all[currentElement].style.visibility = "hidden";
	}
	else{ 
		document.layers[currentElement].visibility = "hide";
	}
	*/
}

// NSX Enthusiast fullscreen popup
function nsxpopup(file,name){
	nsxenthuse = window.open(file,name,"fullscreen=yes, scrollbars=auto");
	nsxenthuse.focus();
	
}

/*
Description: updated  to center on any browser/platform
Author: by MSallave 06/05/02
Notes: use this function with all popups within the site.
---
		parameters settings:
		file = name of URL
		name = name of window
		w = width
		h = height
		m = menubar
		s = scrollbars
		t = toolbar
		r = resizable
---
*/

function WinPop(file,name,w,h,m,s,t,r,l){
	

				LPos = (screen.width) ? (screen.width-w)/2 : 0;
				TPos = (screen.height) ? (screen.height-h)/2 : 0;
				options = "width=" + w + ",height=" + h + ",top=" +TPos + " ,left=" + LPos + ",menubar=" + m + ",scrollbars=" + s + ",toolbar=" + t + ",resizable=" + r + ",location=" + l;
				PopWallpaper = window.open(file,name,options);
				PopWallpaper.focus();
				}
			



/*
Description: updated  to center on any browser/platform
Author: by MSallave 08/27/03
Notes: used to popup a fullscreen on Acura
*/

function fullScreenPop(file){
	//alert(file);
		window.open(file,'AcuraFullScreen','fullscreen=yes');
	}

	
function popWin(url,height,width,toolbar,menubar,locationbar,scroll,resize,status,name) {
			var Browser;
			var spec;
			spec = "status="+status+",toolbar="+toolbar+",menubar="+menubar+",location="+locationbar+",scrollbars="+scroll+",resizable="+resize+",height="+height+",width="+width;
			remote = window.open(url, name, spec);
			remote.focus();
			remote.location.href = url;
			}

function nsxbrochure(file,name){
	nsxbroch = window.open(file,name,"width=500,height=450,toolbar=no,location=no,directories=no,status=0,menubar=no,scrollbars=auto,menu=no,resizable=no,top=100,left=100");
	nsxbroch.focus();
}

//types brochure
function TypesBrochure(file) {
     params = "toolbar=no,location=no,directories=no,status=0,menubar=no,scrollbars=no,menu=no,resizable=no,width=500,height=360";
     Brochure = window.open(file,"tbrochure",params);
     Brochure.focus();
}

//Resizes window
function PageReSize(sWidth,sHeight,sSize){
	if (mac){
		if (ie){
			window.resizeTo(sWidth,sHeight);
			window.focus();
		}
		else{
			window.resizeTo(sWidth,sHeight);
			window.focus();
		}
	}
	else {
		if (ie){
			window.resizeTo(sWidth,sHeight);
			window.focus();
		}
		else{
			window.resizeTo(sWidth,sHeight);
			window.focus();
		}
	}
}

//loads info to parent window and closes
function load(sURL) {
	window.opener.parent.location = sURL;
	self.close();
}
// used for modeloverview page
function load2(sURL) {
	top.window.opener.parent.location = sURL;
	top.self.close();
}


function setCheckBox( chkBox ){
	/*
	 * Description: Sets the checkbox to the default setting (state when first written to screen)
	 * Author: Allan L. Chan, Genex
	 * Date: 05/30/02
	 */
	if (chkBox.checked != chkBox.defaultChecked){
		chkBox.checked = chkBox.defaultChecked;
	}
}

//used for deletion of bookmarks
function ConfirmMsg(sUrl, sItemDesc){
	bDelete = window.confirm("Are you sure you want to delete this " + sItemDesc + "?");
	if (bDelete){
	location = sUrl;
	}
}
	
// My Folder buttons
function ViewOn(imgname){
imgname.src = "/images/myfolder/myfolder_viewbtn_on.gif";
}
function ViewOff(imgname){
imgname.src = "/images/myfolder/myfolder_viewbtn_off.gif";
}

function DeleteOn(imgname){
imgname.src = "/images/myfolder/myfolder_deletebtn_on.gif";
}
function DeleteOff(imgname){
imgname.src = "/images/myfolder/myfolder_deletebtn_off.gif";
}

//function for drop downs on purchasing section
function requestquote(){
	if (document.purchaseform.choices.selectedIndex > 0 ){
		location = document.purchaseform.choices.options[document.purchaseform.choices.selectedIndex].value;
	}
	else if (document.purchaseform.choices.selectedIndex > 0){
		alert('Please choose a model.');
	}
}

/*
	Description: Redirects page to correct cost calculator, but if not selected prompts error.
	Author: Allan L. Chan, Genex
	Date: 07/05/02
*/
function CostCalcNew(){
	if (document.purchaseform3.choices3.selectedIndex > 0){
		location=document.purchaseform3.choices3.options[document.purchaseform3.choices3.selectedIndex].value;
	}
	else{
		alert('Please choose a new vehicle cost calculator.');
	}
}

function CostCalcPre(){
	if (document.purchaseform4.choices4.selectedIndex > 0){
		location=document.purchaseform4.choices4.options[document.purchaseform4.choices4.selectedIndex].value;
	}
	else{
		alert('Please choose a pre-owned vehicle cost calculator.');
	}
}

/*
Description: used for popupwindow that need to close and relocate the main window
*/
function relocate(location){
parent.window.location.href=location;
self.close();
}

function FrameOut(){
	if (self!= top){ 
	top.location.href = window.location.href;
	}
}

function WinClose(){
	self.close();
}

/*
*--- Author: Maurice Sallave
*--- Description: To Alert user coming from Kiosk mode
*--- Date: 06/13/2003
*/
function kioskCookie(){
var allcookies = document.cookie; // gets cookie string
	var pos = allcookies.indexOf("kiosk="); //finds location of cookie
	var sCookieStart  = pos + 6;
	var sCookieEnd = allcookies.indexOf(";", sCookieStart);
		if (sCookieEnd == -1){
			sCookieEnd = allcookies.length;
		}
	var value = allcookies.substring(sCookieStart,sCookieEnd);
	var bValue = unescape(value);
	var bCookievalue = (bValue == "true")? true:false;
	var sMessage = "You are trying to open the acura.com website while the\r Acura Customer Information Center (CIC) application is still open.\n\nThis will cause the acura.com website to open with some\r features missing.  Please close the CIC application first,\n before opening acura.com.";
	
	if (bCookievalue){ //kiosk mode
				confirm(sMessage);
	} 
}

/*
*--- Description: CIC Tracking Object
*--- Date: 08/26/2003
*/

function CICTrackingObject(sMode,sDealerNumber,sType,sID) {
	this.mode=escape(sMode);
	this.page=escape(self.location.href);
	this.type=escape(sType);
	this.dealer=escape(sDealerNumber);
	this.id=escape(sID);
	
	var iRandom=Math.random()+"";
	var iNoCache=iRandom* 10000000000000;
	
	this.src='/tracking.asp?m='+this.mode+'&p='+this.page+'&d='+this.dealer+'&t='+this.type+'&i='+this.id+'&nc='+iNoCache;
		
	var oWebBeacon= new Image();
	oWebBeacon.src=	this.src;
	
	return this;
}

/*
*--- Author: Bao Dang
*--- Description: Launch Brand Promotion based on Screen Resolution
*--- Date: 05/07/2004
*/
function getBrandPromo() {

var resolutiontwidth = 1024
var resolutionheight = 768
var brandpromoURL = '/brandpromo/index.asp'

	if ((screen.width >= resolutiontwidth) && (screen.height >= resolutionheight))
	{
		window.location= "/brandpromo/index.asp?popup=false" ;
	}
	else
	{
		WinPop('/brandpromo/index.asp?popup=true','brandpromo',720,600,'no',0,0,'no','no','no');
	}
}


/*
*--- Author: Bao Dang
*--- Description: Launch Verisign Certificate
*--- Date: 12/13/2004
*/

function PopUpVerisign() {
	// Revised 11/22/2005; adapted code per Verisign's template
	surl = "https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=WWW.ACURA.COM&lang=en";
	params = "location=yes,status=yes,resizable=yes,scrollbars=yes,width=560,height=500";
	verisignWindow = window.open(surl, "verisign", params);
	verisignWindow.focus();
}

function vrsn_splash() {
	// This redirect function is required for Verisign's pre-programmed flash js call to "vrsn_splash()"
	PopUpVerisign();
}

/*
*--- Description: Resize Popup windows for Interactive Showrooms
*--- Date: 9/21/2005
*/

function resizeShowroom(sWidth,sHeight) {
		
	if (mac){
		if (ie){
			window.resizeTo(sWidth,sHeight );
			window.focus();
		}
		else{
			window.resizeTo(sWidth,sHeight - 50);
			window.focus();
		}
	}

		if (ie){
			window.resizeTo(sWidth,sHeight);
			window.focus();
		}
		else{
			window.resizeTo(sWidth,sHeight);
			window.focus();
		}
	}


function tracking(x,y,z){
}

//moved from main.aspx 

function centerContent() {
	// Keep flash div centered
	var contentDiv = document.getElementById("mainContainer");
	//contentDiv.style.left = 0+'px';//Math.max( (document.body.clientWidth-contentDiv.offsetWidth)/2 , -115 ) + 'px';
	contentDiv.style.left = Math.max( (document.body.clientWidth-contentDiv.offsetWidth)/2 , -115 ) +'px';	
	//contentDiv.style.left = (document.body.clientWidth-contentDiv.offsetWidth)/2;
	contentDiv.style.top = 0 + 'px';
}

function displayShowroom(open) {
	// Coordinate div and window resizes
	if(open) {
		sizeDiv(1010,650);
		resizeShowroom(1010,709);
		resizeShowroom(1010,710);
	} else {
		sizeDiv(1010,550);
		resizeShowroom(1010,610);
	}
}

function sizeDiv(datoX,datoY) {
	// Resize the div to allow flash to expand
	if(document.all && !document.getElementById) {
 		document.all['mainContainer'].style.pixelWidth = datoX;
 		document.all['mainContainer'].style.pixelHeight = datoY;
	} else {
		document.getElementById('mainContainer').style.width = datoX;
		document.getElementById('mainContainer').style.height = datoY;
	}
}

function bookmark(url, title) {
	window.external.AddFavorite(url, title);
}

//moved from index.aspx

var siteWin = '';

function init() {
	centerContent();
	var winWidth = Math.max( 880, document.body.clientWidth );
	var winHeight = Math.max( 660, document.body.clientHeight );
	resizeWindow(winWidth, winHeight);
	//popUp('./main.html');

}

//function centerContent() {
	//window.moveTo( (screen.width-document.body.clientWidth)/2 , (screen.height-document.body.clientHeight)/2 -10);
	//window.moveTo(0,0);
//	var contentDiv = document.getElementById("mainContainer");
//	contentDiv.style.center = (document.body.clientWidth-contentDiv.offsetWidth) + 'px';
	//contentDiv.style.top = (document.body.clientHeight-contentDiv.offsetHeight)/2 + 'px';
	//alert(document.getElementById("mainContainer").style.left);
//}

//function popUp(URL,fromClick) {
function popUp(URL,fromClick) {
	//var width = (screen.width > 1024) ? 1010 : Math.round(0.9*screen.width);
	var width = (screen.width > 1024) ? 1010 : screen.width;
	//var height = Math.round(0.9*screen.height);
	//var width = 800;
	var height = 550;
	var left = (screen.width - width)/2;
	var top = (screen.height - height)/2 - 10;
	//
	if(!fromClick) {
		var initPath = parent.location.href;
		if(initPath.indexOf("initPath=") != -1) {
			URL += "?initPath="+initPath.substring(initPath.lastIndexOf("=")+1,initPath.length);
		}	
	}
	//
	siteWin = window.open(URL, 'siteWin', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height+',left='+left+',top='+top);
}
function imgSwap(img) {
	var imgID = document.getElementById("btn");
	imgID.src = img;
}

function resizeWindow(x,y) {
	window.resizeTo(x,y);
}

function launchSite(URL) {
	if(!siteWin.closed && siteWin.location) {
		siteWin.focus();
	} else {
		//popUp('./main.html',true);
		popUp(URL);
	}
}

function trackDART(dartID) {
	var axel = Math.random() * 10000000000000;
	var pix = new Image();
	var rep = 'RANDOM';
	var dartURL = dartID.replace(rep, (Math.random() * 10000000000000));
	//alert(axel);
	//alert(dartURL);
	pix.src=(dartURL);
}

