var originalSearchText;
google.setOnLoadCallback(function(){
	$(".external").attr("target", "_blank");
	
	$(".over-image").mouseover(function()
	{
		var overImage = $(this).find("img");
		if(overImage == null)
		{
			overImageOver(this);
		}
		else
		{
			overImageOver(overImage);
		}
	});
	$(".over-image").mouseout(function()
	{
		var overImage = $(this).find("img");
		if(overImage == null)
		{
			overImageOut(this);
		}
		else
		{
			overImageOut(overImage);
		}
	});
	var lightBoxes = $('a.light-box');
	if(lightBoxes.length)
	{
		$(lightBoxes).lightBox({
		imageLoading: '/app_plugins/jquery/jquery-lightbox/images/lightbox-ico-loading.gif',
		imageBtnClose: '/app_plugins/jquery/jquery-lightbox/images/lightbox-btn-close.gif',
		imageBtnPrev: '/app_plugins/jquery/jquery-lightbox/images/lightbox-btn-prev.gif',
		imageBtnNext: '/app_plugins/jquery/jquery-lightbox/images/lightbox-btn-next.gif'
	   });
   }
   var slides = $('.slide-show');
   if(slides != null && slides.length > 0)
   {
   	var slideCount = slides.length-1;	
   	setTimeout('showSlide(0,1,' + slideCount + ',8000)', 8000);
   }

   var dealerLocator = $(".master-dealer-locator");
   originalSearchText = $(dealerLocator).val(); 
   //$(".master-dealer-locator").click(function()
   //{
   //	 	current = $(dealerLocator).val();
	//	if(current == originalSearchText) $(dealerLocator).val("");
	//	$(dealerLocator).removeClass("inactive");
	//	$(dealerLocator).addClass("active");
   //});
   //$(".master-dealer-locator").blur(function()
   //{
   //		current = $(dealerLocator).val();
	//	if(current == "")
	//	{
	//	    $(dealerLocator).val(originalSearchText);
	//		$(dealerLocator).removeClass("active");
	//		$(dealerLocator).addClass("inactive");	
	//	}
   //});
});

function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
    alert('About to submit: \n\n' + queryString); 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
}
function showSlide(prevIndex,index,maxIndex,timeout)
{
	var slides = $('.slide-show');	
	if(index > maxIndex) index = 0;
	
	var lastSlide = slides[prevIndex];
	var slide = slides[index];
	$(lastSlide).hide(350, function(){		
			
	});
	$(slide).show(100);
	prevIndex = index;		
	index = index+ 1;	
	var del = 'showSlide(' + prevIndex + ',' + index + ',' + maxIndex + ',' + timeout + ')';	
	setTimeout(del, timeout);
	slides = null;
}
function overImageOver(obj)
{
	var src = $(obj).attr("src");
	if(src.indexOf('-msover') <=0)
	{
	src = src.replace('.png','-msover.png');
	$(obj).attr("src",src);
	}
}
function overImageOut(obj)
{
	var src = $(obj).attr("src");
	src = src.replace('-msover.png', '.png');
	$(obj).attr("src",src);
}
function loadPost(target, url)
{
	$(target).load(url);
}
//var regUS = new RegExp("^[0-9]{5}(-[0-9]{4})?$");
//var regCan = new RegExp("^[ABCEGHJKLMNPRSTVXY][0-9][A-Z]( )?[0-9][A-Z][0-9]$");
