// JavaScript Document
/* ====== HOMEPAGE SPECIALS ===== */
$(function(){
	var dsAjax = new DS.SpecialsService(s);
	var usedSpecials = dsAjax.getUsed(3); 
	for (var i = 0; i<usedSpecials.length; i++){
		usedSpecials[i].header = "PRE-OWNED";	
	}
	var themeName = "<div class='special' title='View more details on the ${title}'><div class='spHeader' style='background-color:#${color3}'>"
    	+ "<div class='specialType'>${header}</div><div class='expDate'>Expires: ${expDate}</div></div>"
    	+ "<div class='spBody' style='background-color:#${color4}; border-bottom:1px solid #${color1}'><div class='spBodyLeft'>"
		+ "<img src='${imagePath}' alt='${title}' style='border:1px solid #${color1}' /></div><div class='spBodyRight'>"
        + "<h3 style='color:#${color1}'>${title}</h3><h4 style='color:#${color2}'>${line1}</h4><span class='spLine2'>${line2}</span></div>"
        + "<div style='clear: both'></div><div class='spLinkBox'><a href='${specialLink}' style='background-color:#${color3}'>${button1Text}</a></div></div></div>";
	var containerID = "hpSpecials";

	dsAjax.render(containerID,usedSpecials,themeName);

	/*===== IF THERE ARE SPECIALS, SHOW THE CONTAINER. OTHERWISE, THE SPECIALS CONTAINER WILL REMAIN HIDDEN. =====*/
	if (usedSpecials.length)
		$("#specialsBox").show();

	/*===== IF THERE IS NO IMAGE - SHOW NO IMAGE. =====*/
	$(".special img").error(function(){
		$(this).attr('src','http://sitespecific.dealerskins.com/ToyotaofGrandRapids/2011assets/no-vehicle-image-available.jpg');
	});

});

$(document).ready(function() {
   $('.slideshow ul').innerfade({speed: 500, timeout: 5000});

   $('.btn').hover(function(){
       $(".cover", this).stop().fadeTo(100, 0.0, function(){
           $(this).hide();
       });
   }, function() {
       $(".cover", this).stop().show(0, function(){
           $(this).fadeTo(100, 1.0);
       });
   });
	/*===== Make the special containing DIV clickable to the link within the special DIV ===== */
	$(".special").click(function(){
		window.location = $("a", this).attr("href");
	});
});

$.innerfade.next = function(elements, settings, current, last) {
	if (settings.animationtype == 'slide') {
		$(elements[last]).slideUp(settings.speed);
		$(elements[current]).slideDown(settings.speed);
	} else if (settings.animationtype == 'fade') {
		$(elements[last]).fadeOut(settings.speed);
		$(elements[current]).fadeIn(settings.speed, function() {
			removeFilter($(this)[0]);
		});
	} 
	else
		alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
	
	var a = $(elements[current]).find('a');
	if(a.length > 0) 
		$("#ssBorder").click(function(e){ document.location.href = a[0].href; }).css('cursor','pointer');
	else
		$("#ssBorder").unbind('click').css('cursor','default');
	
	if (settings.type == "sequence") {
		if ((current + 1) < elements.length) {
			current = current + 1;
			last = current - 1;
		} else {
			current = 0;
			last = elements.length - 1;
		}
	} else if (settings.type == "random") {
		last = current;
		while (current == last)
			current = Math.floor(Math.random() * elements.length);
	} else
		alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
	setTimeout((function() {
		$.innerfade.next(elements, settings, current, last);
	}), settings.timeout);
}

params_gusweiler = {menu:'false',allowscriptaccess:'always',wmode:'transparent'};
flashvars_gusweiler = {siteid:"2511",servername:"http://www.gusweilertoyota.com/"};
attributes_gusweiler = {};
swfobject.embedSWF("/sitespecific/GuswellerToyota/hpAssets2011/search.swf", "quoteForm", "250", "260", "8.0.0",false,flashvars_gusweiler,params_gusweiler,attributes_gusweiler);


