﻿// JScript File

/*
 * This function highlights an image
 *
 * @param	image - the name of the image to be flipped
 * @param	dir - path to image dir (ex: "../images/nav/")
 * @param	imgName - optional, if name attribute is different from the image file name
 */
function over(image, dir, imgName) { 
	if (document.images) {
		var img = (imgName) ? findObject(imgName) : findObject(image);
		// store reference to old image for the out function
		img.rsrc = img.src;
		img.src = dir + image + "_on.jpg";
	}
}

/**
 * This function restores an image
 *
 * @param	image - the name of the image to be flopped
 * @param	imgName - optional, if name attribute is different from the image file name
 */
function out(image) {
	if (document.images) {
		var img = findObject(image);
		// set source to stored reference to the old image
		img.src = img.rsrc;
	}
}

// adapted from MM_findObj
function findObject(name, doc) {

	// get document, if it hasn't been passed
	if (!doc) doc = document;

	// declare object reference
	var obj = null;

	// check document and document.all collections	
	if (!(obj = doc[name]) && doc.all) {
		obj = doc.all[name];
	}
	
	// check document.layers collection
	if (!obj && document.layers) {
		for (var i = 0; !obj && i < doc.layers.length; i++) {	
			obj = findObject(name, doc.layers[i].document);
		}
	}
		
	if (!obj && doc.getElementById) {
		obj = doc.getElementById(name);
	}
	
	return obj;
}

/**
 * This function opens a new popup window to display vehicle features
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */

function popupVehicleFeatures(url)
{
    var newWindow;
	newWindow=window.open(url,'name','width=950,height=800,left=50,top=50, screenX=50,screenY=50,status=no,scrollbars=yes, resize=yes');
	if (window.focus) {newWindow.focus()}
	
}
/**
 * This function opens a new popup window to display penske truck features
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */

function popupTruckFeatures(url)
{
    var newWindow;
	newWindow=window.open(url,'name','width=640,height=430,left=50,top=50, screenX=50,screenY=50,status=no,scrollbars=yes, resize=yes');
	if (window.focus) {newWindow.focus()}
	
}
/**
 * This function opens a new popup window to display cars in different colors
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function popupColors(url)
{
    var newWindow;
	newWindow=window.open(url,'name','width=850,height=600,left=50,top=50, screenX=50,screenY=50,status=no,scrollbars=yes, resize=yes');
	if (window.focus) {newWindow.focus()}
	
}
/**
 * This function opens a new popup window to launch the webcam
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function popupWebCam(url) 
{
        var newWindow;
		newWindow=window.open(url,'name','height=600,width=900, top=50, left=50,screenX=50,screenY=50,status=no,scrollbars=yes,resize=no');
		if (window.focus) {newWindow.focus()}
	
}
/**
 * This function opens a new popup window to display tire specials and service coupons
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function popupSpecials(url)
{
        var newWindow;
		newWindow=window.open(url,'name','height=620,width=920, top=50, left=50,screenX=50,screenY=50,status=no,scrollbars=yes,resize=no');
		if (window.focus) {newWindow.focus()}
	
}
/**
 * This function opens a new popup window to display auto loan calculator
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function popupAutoLoanCalculator(url)
{
        var newWindow;
		newWindow=window.open(url,'name','height=350,width=275, top=50, left=50,screenX=50,screenY=50,status=no,scrollbars=no,resize=no');
		if (window.focus) {newWindow.focus()}
}

/**
 * This function opens a new popup window to display mileage intervals menu
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function popupMileageIntervals(url)
{
        var newWindow;
		newWindow=window.open(url,'name','height=400,width=750, top=50, left=50,screenX=50,screenY=50,status=no,scrollbars=yes,resize=no');
		if (window.focus) {newWindow.focus()}
}

/**
 * This function opens a new popup window to display mileage intervals menu
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function popupServiceCenterSlideShow(url)
{
        var newWindow;
		newWindow=window.open(url,'name','toolbar=no,menubar=no,directories=no,location=no,width=530,height=420,left=50,top=50, screenX=50,screenY=50,status=no,scrollbars=no, resize=no');
		if (window.focus) {newWindow.focus()}
}

/**
 * This function opens a new popup window to QuickTime video (Kia site)
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function popupVideo(url)
{
        var newWindow;
		newWindow=window.open(url,'Video','toolbar=no,menubar=no,directories=no,location=no,width=350,height=250,left=50,top=50, screenX=50,screenY=50,status=no,scrollbars=no, resize=no');
		if (window.focus) {newWindow.focus()}
}

/**
 * This function opens a new popup window to display a resizable popup
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function openResizablePopup(url)
{
        var newWindow;
		newWindow=window.open(url,'name','height=620,width=920, top=50, left=50,screenX=50,screenY=50,status=no,scrollbars=yes,resizable=yes');
		if (window.focus) {newWindow.focus()}
	
}

/**
 * This function opens a new popup window to display a coupon
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function popupCoupon(url)
{
        var newWindow;
		newWindow=window.open(url,'name','toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=0,resizable=0,width=530,height=180');
		if (window.focus) {newWindow.focus()}
	
}

/**
 * This function opens a new popup window to display Service Maintenance coupon
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function popupServiceMaintenanceCoupon(url)
{
        var newWindow;
		newWindow=window.open(url,'name','toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=0,resizable=0,width=530,height=270');
		if (window.focus) {newWindow.focus()}
	
}

/**
 * This function opens a new popup window to display Internet Offer Coupon
 *
 * @newWindow - the name of the popup window to be opened
 * 
 */
function popupInternetCoupon(url)
{
        var newWindow;
		newWindow=window.open(url,'name','toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=0,resizable=0,width=630,height=440');
		if (window.focus) {newWindow.focus()}
	
}

/**
 * This function launches a new window
 *
 * @newWindow - the name of the new window to be opened
 * 
 */
function openNewWindow(url)
{
        var newWindow;
		newWindow=window.open(url);
		if (window.focus) {newWindow.focus()}
}
/**
 * This function activates a flash control
 *
 * 
 * 
 */
function openNewWindow(url)
{
        var newWindow;
		newWindow=window.open(url);
		if (window.focus) {newWindow.focus()}
}


/**
 * The following functions are for Google map
 *
 */
// A function to create the marker and set up the event window
// Dont try to unroll this function. It has to be here for the function closure
// Each instance of the function preserves the contends of a different instance
// of the "marker" and "html" variables which will be needed later when the event triggers.    
function createMarker(point,html) {
    var marker = new GMarker(point);
	GEvent.addListener(marker, "click", function() {
	    marker.openInfoWindowHtml(html);
    });
	return marker;
}

function loadGoogleMap(centerLat, centerLng, locLat, locLng, dealershipImg, displayedAddress, submittedAddress) {
	if (GBrowserIsCompatible()) {
		// instantiat map
		var map = new GMap2(document.getElementById("map"));
			
		// add standard controls
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
			
		// center on location
		map.setCenter(new GLatLng(centerLat,centerLng), 12);
		var point = new GLatLng(locLat,locLng);
			
		var markerHTML = '<div id="mapOverlay">';
		markerHTML += '<p class="address">' + '<img class="dealer" src="' + dealershipImg + '" width="100" height="56" align="left" />';
		markerHTML += displayedAddress + '</p>';
		markerHTML += '<form action="http://maps.google.com/maps" method="get" target="_blank">';
		markerHTML += '<input class="text" type="text" size="38" maxlength="40" name="saddr" id="saddr" value="Enter your starting address" onclick="if(this.value==\'Enter your starting address\'){this.value=\'\'}" /><br />';
		markerHTML += '<input class="submit" value="Get Directions" type="submit">';
		markerHTML += '<input type="hidden" name="daddr" value="' + submittedAddress + '"/>';
		markerHTML += '</form></div>';
			
		var marker = createMarker(point, markerHTML);
		map.addOverlay(marker);
		marker.openInfoWindowHtml(markerHTML);
	}
}

function minor()
    {
        NewWindow=window.open('servicemenu/minor.aspx','newWin', 'width=494, height=355, left=100, top=100, toolbar=No, location=No, scrollbars=Yes, status=No, resizable=Yes, fullscreen=No');
        NewWindow.focus();
    } 
    function intermediate()
    {
        NewWindow= window.open('servicemenu/intermediate.aspx', 'newWin','width=494, height=650, left=100, top=100, toolbar=No, location=No,scrollbars=Yes,status=No,resizable=Yes,fullscreen=No');
        NewWindow.focus();
    } 
    function major()
    {
        NewWindow= window.open('servicemenu/major.aspx','newWin', 'width=494, height=600, left=100, top=100, toolbar=No, location=No,scrollbars=Yes,status=No,resizable=Yes,fullscreen=No');
        NewWindow.focus();
    }

    //scion master page
    
    function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
    }

    function changeImages() {
	    if (document.images && (preloadFlag == true)) {
		    for (var i=0; i<changeImages.arguments.length; i+=2) {
			    document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		    }
	    }
    }

    var preloadFlag = false;
    function preloadImages() {
        if (document.images) {
            Directions_over = newImage("../images/Directions-over.jpg");
            PurePrice_over = newImage("../images/PurePrice-over.jpg");
            xd_over = newImage("../images/xd-over.jpg");
            tc_over = newImage("../images/tc-over.jpg");
            xb_over = newImage("../images/xb-over.jpg");
            preloadFlag = true;
        }
    }
   