/*
	// ------------------------------------------------------------------------------
	// CLASS:
	// DS2.includes.scripts.redline.redline
	//
	// PURPOSE:
	// Consolidata javascript functions
	//
	// COPYRIGHT:
	// Copyright (c) 2008 Dealerskins, Inc. All Rights Reserved.
	//
	// REVISION HISTORY:
	//
	// ******************************************************************************
	// User: ADM  Date:10/1/2008
	// Initial creation
	// ******************************************************************************
	// ------------------------------------------------------------------------------
*/

// Handle all the FSCommand messages in a Flash movie.

function redline_DoFSCommand(command, args) {
	var redlineObj = isInternetExplorer ? document.all.redline : document.redlineEmb;
	// Safari/Mac? get "FSCommand:" prepended to 'command' parameter
	switch (command){
		case "resize": case "FSCommand:resize":
			redlineObj.css('height',args);
			break;
		case "resizeAndReset": case "FSCommand:resizeAndReset":
			redlineObj.css('height',args);
			window.scrollTo(0,findPosY(document.getElementById('redlineDiv')));
			break;
		case "scroll": case "FSCommand:scroll":
			window.scrollBy(0,args);
			break;
		case "status": case "FSCommand:status":
			window.status = args;
			break;
		case "startHistory": case "FSCommand:startHistory":
			//startHistory();
			break;
	}
}

function trackMakes(make){
	var ref = $('img#cmTrackImg');
	var pre = "http://b.collective-media.net/seg/cm/auto_ds";
	var mName = undefined;
	
	if (ref.length == 0){
		$(document.body).append('<img src="http://b.collective-media.net/seg/cm/auto_de" id="cmTrackImg" width="1" height="1" style="display:none;" />');
		ref = $('img#cmTrackImg');
	}
	
	if (make !== undefined && make !== ""){
		switch (make.toLowerCase()){
			case "cadillac":
				mName = "cad";
				break;
			case "chevrolet":
				mName = "che";
				break;
			case "chrysler":
				mName = "cry";
				break;
			case "dodge":
				mName = "d";
				break;
			case "ford":
				mName = "f";
				break;
			case "gmc":
				mName = "g";
				break;
			case "pontiac":
				mName = 'p';
				break;
		}
	}
	
	if (mName){
		pre += mName;
		ref.attr('src',pre);
	}
}


/* this is the code that makes the inventory_DoFSCommand function work for IE. Comment it back in to get IE working. */
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && 
navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub redline_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call redline_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}


function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y){
		curtop += obj.y;
	}
	return curtop;
}

function openEvox360(mediapath) {
	evox360 = window.open(mediapath, 'evox360window', 'width=350,height=300,left=250,top=250,scrollbars=no')
	evox360.focus();
}

function newSize(datoY){
	document.getElementById('redLineDiv').style.height = datoY+'px';
}

function openPrintWindow(BASEREQ,IMAGEPATH,OPTIONINVOICE,OPTIONMSRP,PACKAGEINVOICE,PACKAGEMSRP,SELECTEDDEALEROPTIONS,SELECTEDEXTCOLOR,SELECTEDINTTRIM,SELECTEDOPTIONS,SELECTEDPACKAGES,SITEID,TOTALINVOICE,TOTALMSRP,TRIMID,DESTCHARGE,NUFlag,VPPRICE,VPPRICENAME,VPCOMPANY)
{
	document.printform.BASEREQ.value = BASEREQ;
	document.printform.IMAGEPATH.value = IMAGEPATH;
	document.printform.OPTIONINVOICE.value = OPTIONINVOICE;
	document.printform.OPTIONMSRP.value = OPTIONMSRP;
	document.printform.PACKAGEINVOICE.value = PACKAGEINVOICE;
	document.printform.PACKAGEMSRP.value = PACKAGEMSRP;
	document.printform.SELECTEDDEALEROPTIONS.value = SELECTEDDEALEROPTIONS;
	document.printform.SELECTEDEXTCOLOR.value = SELECTEDEXTCOLOR;
	document.printform.SELECTEDINTTRIM.value = SELECTEDINTTRIM;
	document.printform.SELECTEDOPTIONS.value = SELECTEDOPTIONS;
	document.printform.SELECTEDPACKAGES.value = SELECTEDPACKAGES;
	document.printform.SITEID.value = SITEID;
	document.printform.TOTALINVOICE.value = TOTALINVOICE;
	document.printform.TOTALMSRP.value = TOTALMSRP;
	document.printform.TRIMID.value = TRIMID;
	document.printform.DESTCHARGE.value = DESTCHARGE;
	document.printform.NUFlag.value = NUFlag;
	document.printform.VPPRICE.value = VPPRICE;
	document.printform.VPPRICENAME.value = VPPRICENAME;
	document.printform.VPCOMPANY.value = VPCOMPANY;
	document.printform.submit();
}
