﻿/***********************************************
* Dynamic Countdown script- &copy; Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
ddaccordion.init({
	headerclass : "submenuheader",
	contentclass : "submenu",
	revealtype: "click",
	mouseoverdelay: 200,
	collapseprev: false,
	defaultexpanded: [],
	onemustopen: false,
	animatedefault: false,
	persiststate: true,
	toggleclass: ["", ""],
	togglehtml: ["none", "", ""],
	animatespeed: "normal",
	oninit: function(headers, expandedindices) { },
	onopenclose: function(header, index, state, isuseractivated) { }
});

ddaccordion.init({
	headerclass : "submenuheader2",
	contentclass : "submenu2",
	revealtype: "click",
	mouseoverdelay: 200,
	collapseprev: false,
	defaultexpanded: [],
	onemustopen: false,
	animatedefault: false,
	persiststate: true,
	toggleclass: ["", ""],
	togglehtml: ["none", "", ""],
	animatespeed: "normal",
	oninit: function(headers, expandedindices) { },
	onopenclose: function(header, index, state, isuseractivated) {
		insertDiv(header,index, state);
	}
});

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }
}

function ChangeLanguage(ddlLanguage)
{
    if (ddlLanguage.selectedIndex > 0)
    {
        var shortName = ddlLanguage.options[ddlLanguage.selectedIndex].value;
        if (shortName != "uk")
            location.href = "/" + shortName + "/";
        else
            location.href = "/";
    }
}

jQuery(function($) {
	correctPNG();
	/**
	 * Homepage Carousel
	 */
	if($("#categorySelector").length){
		var nextHTML = "<b id='nxt'>Next</b>";
		var prevHTML = "<b id='prv'>Previous</b>";
		$("#arrows").prepend(nextHTML).prepend(prevHTML);
		$("#productCarousel").jCarouselLite({
			btnNext: "#nxt",
			btnPrev: "#prv",
			scroll: 3,
			speed: 800
		});
	}
	
	$("body").addClass("hasJS");
	
    $("a[name^='faq-']").each(function() {
        $(this).click(function() {
            if ($("#" + this.name).is(':hidden')) {
                $("#" + this.name).fadeIn('slow');
            } else {
                $("#" + this.name).fadeOut('slow');
            }
            return false;
        });
    });
});	

function processCMSForm(){
	var obj;
	var url = ""+window.location; // convert location to a string
	var url_parts = url.split("?");
	if(url_parts[0]){
		url = url_parts[0];
	}
	obj = $('form').serialize();
	window.location = url + "?" + obj;
}

function prepareContactForm() {
    var $holder = $("#ps_results2");

    if ($holder.length == 0) return;
    
    var $p = $holder.find("p.contact_title");
    var height = $p.outerHeight(true);
    var target_height = $holder.height();
    var $links = $("a.form_open");

    $holder.height(height);

    $links.click(function(e) {
        e.preventDefault();
        $holder.animate({ height: target_height }, 500, "easeInOutQuart");
    });
}

function hideFlashBanner() {
    $banner = $("#content").find(".dv_stoneridge_banner");
    $banner.animate({ height:0, paddingBottom:0 }, 500, "easeInOutQuart", function() {
        $banner.empty();
    });
}

function main() {
    prepareContactForm();
}

$(document).ready(main);


    
    

