
function stripHTML(){
	var re = /(<([^>]+)>)/gi;
	for (i=0; i<arguments.length; i++)
		arguments[i].value=arguments[i].value.replace(re, "")
}

jQuery(document).ready(function(){
								
								
	jQuery(".shadowed").each(function(){
		$stuff = jQuery(this);
		var imgheight = $stuff.find(".img-img").outerHeight();
		var imgwidth = $stuff.find(".img-img").outerWidth(); 
		$stuff.find(".img-shadow").css({
			width: imgwidth+"px",
			height: imgheight+"px",
			position: "absolute",
			opacity: "0.25"
		});
		imgwidth = imgwidth+2;
		imgheight = imgheight+2;
		$stuff.find(".img-shadow2").css({
			width: imgwidth+"px",
			height: imgheight+"px",
			position: "absolute",
			opacity: "0.1"
		});
	});
      /* Markup for Browser Fixes */
        jQuery('#sub-right').wrapInner('<div class="wrap-lb"></div>');
	   jQuery('#sub-right:first-child').addClass('first');

                      
    /* Initialize Tabs and Accordions */                  
        jQuery('#car-search > ul ').tabs(); 
	   jQuery('#horizontal-feature > ul').tabs();
	   jQuery('#car-search-tab').tabs(); 
        jQuery('.ui-accordion-container').accordion();  
	   

        
 
        
      /* Coupon stuff */
	  // prepare the form when the DOM is ready 

	  
        // form submit stuff
		// prepare the form when the DOM is ready 
		// bind form using ajaxForm 
// prepare the form when the DOM is ready 
    // bind form using ajaxForm 
    jQuery('#contact').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#myForm', 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() { 
            jQuery('#coup').css("visibility", "hidden"); 
        } 
    }); 
	
	
    jQuery('#gornosurvey').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#exitsurvey', 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() {  
        } 
    }); 
    jQuery('#quick').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#quickto', 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() {  
        } 
    }); 
		
    jQuery('#imn').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#imnto', 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() {  
        } 
    }); 
	
    jQuery('#newsletter').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#newsto', 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() {  
        } 
    }); 
		function elementToString(n, useRefs) {
			var attr = "", nest = "", a = n.attributes;
			for (var i=0; a && i < a.length; i++)
				attr += ' ' + a[i].nodeName + '="' + a[i].nodeValue + '"';
		
			if (n.hasChildNodes == false)
				return "<" + n.nodeName + "\/>";
		
			for (var i=0; i < n.childNodes.length; i++) {
				var c = n.childNodes.item(i);
				if (c.nodeType == 1)       nest += elementToString(c);
				else if (c.nodeType == 2)  attr += " " + c.nodeName + "=\"" + c.nodeValue + "\" ";
				else if (c.nodeType == 3)  nest += c.nodeValue;
			}
			var s = "<" + n.nodeName + attr + ">" + nest + "<\/" + n.nodeName + ">";
			return useRefs ? s.replace(/</g,'&lt;').replace(/>/g,'&gt;') : s;
		};

      var oh = jQuery("#myForm").height()+30;
      var ow = jQuery("#myForm").width()+30; 
      var fow = jQuery("#everything").width();
      var foh = jQuery("#everything").outerHeight();
      var w = jQuery(window).height();
      var wd = jQuery(window).width();
      var h = (w / 2) - (oh /2); 
      var ww = (wd / 2) - (ow /2);
      
    jQuery("#overlay").css("visibility","hidden").css("width",fow+"px").css("height",foh+"px").css("opacity","0");
	jQuery('a').each(function() {
		if(this.getAttribute('href') && (this.getAttribute('rel') == 'lightbox')) {
			this.onclick = function(){
				jQuery.easing.def = "easeOutBounce";
				jQuery("#overlay").css("visibility", "visible").animate({ 
					opacity: 0.4
				}, 850, "easeInOutCirc" );
				jQuery("#graphic").animate({ 
					opacity: 1,
					top: '50%',
					left: '50%'
				}, 850, "easeInOutCirc" ).html('<img src="' + this.href +
					'" alt="' + this.getAttribute("title") +
					'" title="' + this.getAttribute("title") +
					'" />'); 
				return false;
			}
		}
	});

	
    jQuery("#go").click(function(){
	  jQuery.easing.def = "easeOutBounce";
      jQuery("#go").animate({ 
        opacity: 0
      }, 850, "easeInOutCirc" );
      jQuery("#overlay").css("visibility", "visible").animate({ 
        opacity: 0.4
      }, 850, "easeInOutCirc" );
      jQuery("#close").animate({ 
        opacity: 1
      }, 850, "easeInOutCirc" );
      jQuery("#myForm").animate({ 
        opacity: 1,
        top: h+'px',
        left: ww+'px'
      }, 850, "easeInOutCirc" ); 
    });
    
    jQuery("#close").click(function(){
    jQuery.easing.def = "easeInOutCirc";
      jQuery("#go").animate({ 
        opacity: 1
      }, 850 );
      jQuery("#overlay").animate({ 
        opacity: 0
      }, 850 ).css("visibility", "hidden");
      jQuery("#close").animate({ 
        opacity: 0
      }, 850 );
      jQuery("#myForm").animate({ 
        opacity: 0, 
        top: "0px",
        left: "-"+ow+"px"
      }, 375 );
    });
    
    jQuery("#overlay").click(function(){
    jQuery.easing.def = "easeInOutCirc"; 
      jQuery("#go").animate({ 
        opacity: 1
      }, 850 );
      jQuery("#overlay").animate({ 
        opacity: 0
      }, 850 ).css("visibility", "hidden");
      jQuery("#close").animate({ 
        opacity: 0
      }, 850 );
      jQuery("#myForm").animate({ 
        opacity: 0,
        top: "0px",
        left: "-"+ow+"px"
      }, 375 );
      jQuery("#graphic").animate({ 
        opacity: 0,
        top: "0px",
        left: "-1200px"
      }, 375 );
    });
});

function printpdf() {
	var x = document.getElementById("coupon");
	var objDoc = x;
	var objPrintParams = objDoc.getPrintParams();
	// Print the PDF using properties just set with printParams object
	objDoc.print(objPrintParams);
}

jQuery("img").lazyload();

/* 
*    JS Template for Gorno Ford
*/

function slideSwitch() {
    var $active = jQuery('#slideshowfe DIV.active');

    if ( $active.length == 0 ) $active = jQuery('#slideshowfe DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : jQuery('#slideshowfe DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

jQuery(function() {
    setInterval( "slideSwitch()", 7500 );
});
