
/* -----------------------------------------------------------------------------------------------------*/
/*  NEW scripts for Car & Parts Div */
/* -----------------------------------------------------------------------------------------------------*/

/* Create Car & Parts Div */
function getDivPos(divID)	{
var winW;
var winH;
var divOne='leftCar';
var divTwo='rightParts';
	if (divID == divOne)	{	
		if (window.innerWidth)	{ //if browser supports window.innerWidth Firefox NS6
			winW=window.pageXOffset+110;  //180
			winH=window.pageYOffset+20;  //11
			}
		else if (document.all)	{ // IE 4+
			winW=document.body.scrollLeft+110; //180
			winH=document.body.scrollTop+20; //12
			}
			// alert("partsWidth is "+winW);
		document.write('<div id=\"leftCarDiv\" Style=\"position:absolute; left:'+winW+'px; top:'+winH+'px; width:280px; height:122px; visibility:visible; z-index:11; border:0px;\">');
	}
	else if (divID == divTwo)	{	
		if (window.innerWidth)	{ //if browser supports window.innerWidth Firefox NS6
			winW=innerWidth-325; //1110
			winH=window.pageYOffset+14; //11
			}
		else if (document.all)	{ // IE 4+
			winW=document.body.clientWidth-300;
			winH=document.body.scrollTop+14;
			}
			// alert("Width is "+winW);
		document.write('<div id=\"rightPartsDiv\" Style=\"position:absolute; left:'+winW+'px; top:'+winH+'px; width:296px; height:110px; visibility:visible; z-index:12; border:0px;\">');
	}
}

/* Clost Car & Parts Divs */
function completeDiv()	{
document.write('</div>');
}

/* Auto Adjust Car & Parts Divs on Resize of Window */
var currheight = window.innerHeight; // Firefox NS6
var currheightIE = document.documentElement.clientHeight; // IE 4+
window.onresize = function()	{
	if(currheight != window.innerWidth)	{
	window.location.replace(window.location.href);
	}
	else if(currheightIE != document.documentElement.clientHeight)	{
	window.location.reload();
	}
	else return;
}

/* -----------------------------------------------------------------------------------------------------*/
/*  NEW Slideshow scripts for Car & Parts Div */
/* -----------------------------------------------------------------------------------------------------*/

//Random Transitions Slideshow- By JavaScript Kit (http://www.javascriptkit.com)
//Created: Nov 3rd, 2008

var global_transitions=[ //array of IE transition strings
	//"progid:DXImageTransform.Microsoft.Barn()",
	//"progid:DXImageTransform.Microsoft.Blinds()",
	//"progid:DXImageTransform.Microsoft.CheckerBoard()",
	//"progid:DXImageTransform.Microsoft.Fade()",
	"progid:DXImageTransform.Microsoft.GradientWipe()",
	//"progid:DXImageTransform.Microsoft.Inset()",
	//"progid:DXImageTransform.Microsoft.Iris()",
	//"progid:DXImageTransform.Microsoft.Pixelate(maxSquare=15)",
	//"progid:DXImageTransform.Microsoft.RadialWipe()",
	//"progid:DXImageTransform.Microsoft.RandomBars()",
	//"progid:DXImageTransform.Microsoft.RandomDissolve()",
	//"progid:DXImageTransform.Microsoft.Slide()",
	//"progid:DXImageTransform.Microsoft.Spiral()",
	//"progid:DXImageTransform.Microsoft.Stretch()",
	//"progid:DXImageTransform.Microsoft.Strips()",
	//"progid:DXImageTransform.Microsoft.Wheel()",
	//"progid:DXImageTransform.Microsoft.Zigzag()"
]

function flashyslideshow(setting){
	this.wrapperid=setting.wrapperid
	this.imagearray=setting.imagearray
	this.pause=setting.pause
	this.transduration=setting.transduration/1000 //convert from miliseconds to seconds unit to pass into el.filters.play()
	this.currentimg=0
	var preloadimages=[] //temp array to preload images
	for (var i=0; i<this.imagearray.length; i++){
		preloadimages[i]=new Image()
		preloadimages[i].src=this.imagearray[i][0]
	}
	document.write('<div id="'+this.wrapperid+'" class="'+setting.wrapperclass+'"><div id="'+this.wrapperid+'_inner" style="width:100%">'+this.getSlideHTML(this.currentimg)+'</div></div>')
	//var effectindex=Math.floor(Math.random()*global_transitions.length) //randomly pick a transition to utilize
	//var effectindex="progid:DXImageTransform.Microsoft.GradientWipe()";
	var contentdiv=document.getElementById(this.wrapperid+"_inner");
	if (contentdiv.filters){ //if the filters[] collection is defined on element (only in IE)
		contentdiv.style.filter="progid:DXImageTransform.Microsoft.GradientWipe()";
		//contentdiv.style.filter=global_transitions[effectindex] //define transition on element
		this.pause+=setting.transduration //add transition time to pause
	}
	this.filtersupport=(contentdiv.filters && contentdiv.filters.length>0)? true : false //test if element supports transitions/has one defined
	var slideshow=this
	flashyslideshow.addEvent(contentdiv, function(){slideshow.isMouseover=1}, "mouseover")
	flashyslideshow.addEvent(contentdiv, function(){slideshow.isMouseover=0}, "mouseout")
	setInterval(function(){slideshow.rotate()}, this.pause)
}

flashyslideshow.addEvent=function(target, functionref, tasktype){
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false);
	else if (target.attachEvent)
		target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});
},

flashyslideshow.setopacity=function(el, degree){ //sets opacity of an element (FF and non IE browsers only)
	if (typeof el.style.opacity!="undefined")
		el.style.opacity=degree
	else
		el.style.MozOpacity=degree
	el.currentopacity=degree
},

flashyslideshow.prototype.getSlideHTML=function(index){
	var slideHTML=(this.imagearray[index][1])? '<a href="'+this.imagearray[index][1]+'" target="'+this.imagearray[index][2]+'">\n' : '' //hyperlink slide?
	slideHTML+='<img src="'+this.imagearray[index][0]+'" />'
	slideHTML+=(this.imagearray[index][1])? '</a><br />' : '<br />'
	slideHTML+=(this.imagearray[index][3])? this.imagearray[index][3] : '' //text description?
	return slideHTML //return HTML for the slide at the specified index
}

flashyslideshow.prototype.rotate=function(){
	var contentdiv=document.getElementById(this.wrapperid+"_inner")
	if (this.isMouseover){ //if mouse is over slideshow
		return
	}
	this.currentimg=(this.currentimg<this.imagearray.length-1)? this.currentimg+1 : 0
	if (this.filtersupport){
		contentdiv.filters[0].apply()
	}
	else{
		flashyslideshow.setopacity(contentdiv, 0)
	}
	contentdiv.innerHTML=this.getSlideHTML(this.currentimg)
	if (this.filtersupport){
		contentdiv.filters[0].play(this.transduration)
	}
	else{
		contentdiv.fadetimer=setInterval(function(){
			if (contentdiv.currentopacity<1)
				flashyslideshow.setopacity(contentdiv, contentdiv.currentopacity+0.1)
			else
				clearInterval(contentdiv.fadetimer)
		}, 50) //end setInterval
	}
}

/* NEW Header Slideshow */
function startCarShow()	{
// create Car Div and activate SlideshowOne
getDivPos('leftCar');
var flashyshow=new flashyslideshow({ 
	wrapperid: "myslideshowOne", //unique ID for this slideshow
	wrapperclass: "flashclassOne", //desired CSS class for this slideshow
	imagearray: [
	// image_path, optional_image_link, optional_link_target, optional_text_description
		["images/vette_1.jpg", "", "", ""],  
		["images/vette_2.jpg", "", "", ""],  
		["images/vette_4.jpg", "", "", ""], 
		["images/vette_3.jpg", "", "", ""],
		["images/vette_5.jpg", "", "", ""]
	],
	pause: 6000, //pause between content change (millisec)
	transduration: 2000 //duration of transition (affects only IE users)
})
completeDiv();

// create Parts Div and activate SlideshowTwo
getDivPos('rightParts');
var flashyshow=new flashyslideshow({ 
	wrapperid: "myslideshowTwo", 
	wrapperclass: "flashclassTwo", 
	imagearray: [
		["images/parts_1.jpg", "", "", ""],
		["images/parts_2.jpg", "", "", ""],
		["images/parts_4.jpg", "", "", ""],
		["images/parts_3.jpg", "", "", ""],
		["images/parts_5.jpg", "", "", ""]
	],
	pause: 6000, 
	transduration: 2000 
})
completeDiv();
}


/* -----------------------------------------------------------------------------------------------------*/
/*  Older Corvette site scripts */
/* -----------------------------------------------------------------------------------------------------*/

/* Popup Window send feature data */
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/* Popup Window set features */
function newWindow(theURL) { //v2.0
  	var features = 'width=650,height=500,scrollbars=0,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=250,top=250';
	var winName = 'Popup';
	window.open(theURL,winName,features);
}

function VerifyAction()	{
var action 
	for (var i=0; i<document.form1.action.length; i++)  { 
		if (document.form1.action[i].checked)  {
		action = document.form1.action[i].value 
		//set found_it equal to checked button's value
		} 
	}
	if (action==2) {
	return true;
	}
	else {
	document.formb.submit();
	return false;
	}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

/* Popup Window send feature data */
function newWindow(url, height, width) {
    nameW='feature'
 if (navigator.appVersion.indexOf('4') != -1) {
 // Vars for centering the new window on Version 4 Browsers
 xTop = screen.width/2 - (width/2);
 yTop = screen.height/2 - (height/2);
 window.open(url, nameW, 'height='+height+',width='+width+',scrollbars=0,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=' + xTop + ',top=' + yTop + '');
 } else {
 window.open(url, nameW, 'height='+height+',width='+width+',scrollbars=0,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=250,top=250');
 }
}

var newwindow = '';
function popitup(url) {
if (newwindow.location && !newwindow.closed) {
    newwindow.location.href = url; 
    newwindow.focus(); } 
else { 
    newwindow=window.open(url,'htmlname','width=519,height=443,resizable=0,left=250,top=25');} 
}


function popitup2(url) {
if (newwindow.location && !newwindow.closed) {
    newwindow.location.href = url; 
    newwindow.focus(); } 
else { 
    newwindow=window.open(url,'htmlname','width=620,height=338,resizable=0,left=150,top=150');} 
}


function popitup3(url) {
if (newwindow.location && !newwindow.closed) {
    newwindow.location.href = url; 
    newwindow.focus(); } 
else { 
    newwindow=window.open(url,'htmlname','width=630,height=483,resizable=0,left=90,top=100');} 
}


function popitup4(url) {
if (newwindow.location && !newwindow.closed) {
    newwindow.location.href = url; 
    newwindow.focus(); } 
else { 
    newwindow=window.open(url,'htmlname','width=720,height=330,resizable=0,left=90,top=100');} 
}

/* Close Popup Window onUnLoad to clear */
function tidy() {
if (newwindow.location && !newwindow.closed) { 
   newwindow.close(); } 
}


