$(document).ready(function() {

	$(document).pngFix();

	if($(".sub_img #FlashID").html()!=null){
		$(".sub_img:first").html("").append('<div id="SubBannerBox"><div class="PNGFix" style="position:absolute;width:336px;height:83px;background:transparent url(/images/sub-overlay_logo.png) 0 0 no-repeat;margin-top:22px;z-index:10;"><!-- --></div><ul><li class="SubBanner1 active"><img src="/images/image1.jpg" width=960 height=529></li><li class="SubBanner2"><img src="/images/image2.jpg" width=960 height=529></li><li class="SubBanner3"><img src="/images/image3.jpg" width=960 height=529></li></ul></div>');
		SubBannerTimer = setTimeout("SubBanner(0)",1000);
		$(document).pngFix();
		//$(function(){$('div.PNGFix').pngFix();});
	}

	//menu part
/*
		$(".gnav_li").mouseenter(function(){
			//alert($(this).children("a").html());
			if($(this).children("a").hasClass("menu_active")==false){
				//$(this).children("a").css( "backgroundImage","url(images/bg_nav_.png)");
				$(this).children("a").stop().fadeTo(500,0.1);
				$("ul.gnav_sub_ul",this).css("display","block");
				//$("div.menu_sub_div",this).stop().fadeIn(300,function(){$(this).css("opacity","").css("display","block");});
			}
		});
		$(".gnav_li").mouseleave(function(){
			if($(this).children("a").hasClass("menu_active")==false){
				//$(this).children("a").css( "backgroundImage","url(images/bg_nav.png)");
				$(this).children("a").stop().fadeTo(200,1);
				$("ul.gnav_sub_ul",this).stop().fadeOut(200,function(){$(this).css("opacity","");});
			}
		});
*/
    if ($("#ajaxImage").html() != "") {
//        $("#ajaxImage").scrollable({ size: 1, loop: true, clickable: false, next: ".btnNext", prev: ".btnPrevious" }).circular().autoscroll({ interval: 5000 });
    }

/*m_brand1 /images/m_brand_1.jpg*/
	$("li.m_brand1").mouseenter(function(){
			if($("li.m_brand1 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:188px;height:147px;background:url(/images/m_brand_1.jpg) center bottom no-repeat;'><a href='/hansa' style='background:none;' title='Find out more about hansa products:mixer tap,showers,bath spout,sink mixers,valves'>&nbsp;</a></div>");
			}
			$("li.m_brand1 div").stop().fadeIn(300);
	});
	$("li.m_brand1").mouseleave(function(){
			$("li.m_brand1 div").stop().fadeOut(100);
	});
	$("li.m_brand2").mouseenter(function(){
			if($("li.m_brand2 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:128px;height:147px;background:url(/images/m_brand_2.jpg) center bottom no-repeat;'><a href='/kwc' style='background:none;' title='Find out more about kwc products: mixer tap,sink mixers,bath spout'>&nbsp;</a></div>");
			}
			$("li.m_brand2 div").stop().fadeIn(300);
	});
	$("li.m_brand2").mouseleave(function(){
			$("li.m_brand2 div").stop().fadeOut(100);
	});
	$("li.m_brand3").mouseenter(function(){
			if($("li.m_brand3 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:131px;height:147px;background:url(/images/m_brand_3.jpg) center bottom no-repeat;'><a href='/emco' style='background:none;' title='Find out more about emco products:towel rail,towel rings'>&nbsp;</a></div>");
			}
			$("li.m_brand3 div").stop().fadeIn(300);
	});
	$("li.m_brand3").mouseleave(function(){
			$("li.m_brand3 div").stop().fadeOut(100);
	});
	$("li.m_brand4").mouseenter(function(){
			if($("li.m_brand4 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:158px;height:147px;background:url(/images/m_brand_4.jpg) center bottom no-repeat;'><a href='/schell' style='background:none;' title='Find out more about schell products:mixer tap'>&nbsp;</a></div>");
			}
			$("li.m_brand4 div").stop().fadeIn(300);
	});
	$("li.m_brand4").mouseleave(function(){
			$("li.m_brand4 div").stop().fadeOut(100);
	});
	$("li.m_brand5").mouseenter(function(){
			if($("li.m_brand5 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:146px;height:147px;background:url(/images/m_brand_5.jpg) center bottom no-repeat;'><a href='/virtu' style='background:none;' title='Find out more about virtu products: towel rail,towel rings,bath spout'>&nbsp;</a></div>");
			}
			$("li.m_brand5 div").stop().fadeIn(300);
	});
	$("li.m_brand5").mouseleave(function(){
			$("li.m_brand5 div").stop().fadeOut(100);
	});
	$("li.m_brand6").mouseenter(function(){
			if($("li.m_brand6 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:171px;height:147px;background:url(/images/m_brand_6.jpg) center bottom no-repeat;'><a href='/sanitron' style='background:none;' title='Find out more about sanitron products: sensor taps, flush valve'>&nbsp;</a></div>");
			}
			$("li.m_brand6 div").stop().fadeIn(300);
	});
	$("li.m_brand6").mouseleave(function(){
			$("li.m_brand6 div").stop().fadeOut(100);
	});



	$("#gnav ul.lev1 li.lev1").mouseenter(function(){
		if( $("ul",this).html() !=null ){
			$("ul",this).css("display","block");
		}
	});

	$("#gnav ul.lev1 li.lev1").mouseleave(function(){
		if( $("ul",this).html() !=null ){
			$("ul",this).css("display","none");
		}
	});

/*
	$("#gnav li.gnav1").mouseenter(function(){
			if($("#gnav li.gnav1 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:203px;height:43px;background:url(/images/gnav_1.jpg) center bottom no-repeat;'><a href='/home' style='background:none;'>&nbsp;</a></div>");
			}
			$("#gnav li.gnav1 div").stop().fadeIn(300,function(){$(this).css("opacity","");})
	});
	$("#gnav li.gnav1").mouseleave(function(){
			$("#gnav li.gnav1 div").stop().fadeOut(100,function(){$(this).css("opacity","");});
	});
	$("#gnav li.gnav2").mouseenter(function(){
			if($("#gnav li.gnav2 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:146px;height:43px;background:url(/images/gnav_2.jpg) center bottom no-repeat;'><a href='/about-us' style='background:none;'>&nbsp;</a></div>");
			}
			$("#gnav li.gnav2 div").stop().fadeIn(300,function(){$(this).css("opacity","");});
	});
	$("#gnav li.gnav2").mouseleave(function(){
			$("#gnav li.gnav2 div").stop().fadeOut(100,function(){$(this).css("opacity","");});
	});
	$("#gnav li.gnav3").mouseenter(function(){
			if($("#gnav li.gnav3 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:152px;height:43px;background:url(/images/gnav_3.jpg) center bottom no-repeat;'><a href='/consumers/brands' style='background:none;'>&nbsp;</a></div>");
			}
			$("#gnav li.gnav3 div").stop().fadeIn(300,function(){$(this).css("opacity","");});
	});
	$("#gnav li.gnav3").mouseleave(function(){
			$("#gnav li.gnav3 div").stop().fadeOut(100,function(){$(this).css("opacity","");});
	});
	$("#gnav li.gnav4").mouseenter(function(){
			if($("#gnav li.gnav4 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:128px;height:43px;background:url(/images/gnav_4.jpg) center bottom no-repeat;'><a href='/news' style='background:none;'>&nbsp;</a></div>");
			}
			$("#gnav li.gnav4 div").stop().fadeIn(300,function(){$(this).css("opacity","");});
	});
	$("#gnav li.gnav4").mouseleave(function(){
			$("#gnav li.gnav4 div").stop().fadeOut(100,function(){$(this).css("opacity","");});
	});
	$("#gnav li.gnav5").mouseenter(function(){
			if($("#gnav li.gnav5 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:153px;height:43px;background:url(/images/gnav_5.jpg) center bottom no-repeat;'><a href='/specifiers' style='background:none;'>&nbsp;</a></div>");
			}
			$("#gnav li.gnav5 div").stop().fadeIn(300,function(){$(this).css("opacity","");});
	});
	$("#gnav li.gnav5").mouseleave(function(){
			$("#gnav li.gnav5 div").stop().fadeOut(100,function(){$(this).css("opacity","");});
	});
	$("#gnav li.gnav6").mouseenter(function(){
			if($("#gnav li.gnav6 div").html()==null){
				$(this).prepend("<div style='position:absolute;display:none;width:178px;height:43px;background:url(/images/gnav_6.jpg) center bottom no-repeat;'><a href='/contactus' style='background:none;'>&nbsp;</a></div>");
			}
			$("#gnav li.gnav6 div").stop().fadeIn(300,function(){$(this).css("opacity","");});
	});
	$("#gnav li.gnav6").mouseleave(function(){
			$("#gnav li.gnav6 div").stop().fadeOut(100,function(){$(this).css("opacity","");});
	});

*/


	/*$("#taps_nav li a").click(function(){
		$("#taps_nav li a").attr("class","");
		//$(this).parent().attr("class").;
		//alert(tmp.html());
		if($(this).attr("class")=="active"){
			$(this).attr("class","");
		}else{
			$(this).attr("class","active");
		}
	});*/




    $("#sp_1_val").focus(function() {
        if ($(this).val() == "Name / Product No.") {
            $(this).val("");
        }
    });

    $("#sp_1_val").blur(function() {
        if ($(this).val() == "") {
            $(this).val("Name / Product No.");
        }
    });

    // clean form

	$("input[name$='txtSearch']").val("");
    if ($("input[name$='txtBrand']").val() != 0) {
        $("input[name$='txtBrand']").val(0);
    }
    if ($("input[name$='txtCategory']").val() != 0) {
        $("input[name$='txtCategory']").val(0);
    }
    if ($("input[name$='txtRange']").val() != 0) {
        $("input[name$='txtRange']").val(0);
    }

    $("#sp_1_val").change(function() {
    $("input[name$='txtSearch']").val($("#sp_1_val").val());
        
    });

    $("div.sp_2 div.sp_btn").click(function() {
		//alert("Hello0");
        $("div.sp_sub2 ul").html($("div.sp_brand").html());
        $("div.sp_sub2").toggle();
        $("div.sp_sub3").hide();
        $("div.sp_sub4").hide();
        $("div.sp_sub2 ul li").click(function() {

            brand = $(this).html();
            idx = $(this).attr("idx");
            cid = $(this).attr("cid");
            $("#search_product_brand").val(brand);

            $("input[name$='txtBrand']").val(cid); //find and change.
                

            $("#sp_2_val").val(cid);
            $("div.sp_sub2").hide();
            //alert(cid);
            //alert($("div[cid='"+cid+"']").innerHTML);
            /*			
            tmp_html="";
            for(i=0;i<$("div.sp_range").size();i++){
            if(cid==$("div.sp_range")[i].attr("cid")){
            tmp_html=$("div.sp_range")[i].innerHTML;
            }
            }
            */
            $("div.sp_sub3 ul").html($("div." + cid)[0].innerHTML);
            //$("div.sp_sub4 ul").html($("div.sp_type")[idx].innerHTML);

            $("#search_product_category").val("Category");
            $("#sp_3_val").val("");
			 $("input[name$='txtCategory']").val(0);
            $("#search_product_range").val("Range");
            $("#sp_4_val").val("");
			 $("input[name$='txtRange']").val(0);
			click_subs();
///////////////////////////////
		//	category = $(this).html();
			//idx = $(this).attr("idx");
		//	cid = $(this).attr("cid");
		//	 $("#search_product_category").val(category);
			//$("#plc_lt_zoneContent_pageplaceholder_pageplaceholder_lt_zoneMain_ProductSearchBox_txtCategory").val(cid);
			// $("#sp_3_val").val(cid);
	
			$("#search_product_range").val("Range");
			$("#sp_4_val").val("");
			$("div.sp_sub4 ul").html($("div.allcat." + cid)[0].innerHTML);

			$("div.sp_sub3").hide();
			li_over();
			$("div.sp_sub4 ul li").click(function() {
				subtype = $(this).html();
				idx = $(this).attr("idx");
				cid = $(this).attr("cid");
				 $("#search_product_range").val(subtype);
				 $("input[name$='txtRange']").val(cid);
				$("#sp_4_val").val(cid);
				 $("div.sp_sub4").hide();
			});








//////////////////////////////

            //click_subs();
        });
        li_over();
    });
    $("div.sp_3 div.sp_btn").click(function() {
        $("div.sp_sub3").toggle();
        $("div.sp_sub2").hide();
        $("div.sp_sub4").hide();
        li_over();
    });
    $("div.sp_4 div.sp_btn").click(function() {
        $("div.sp_sub4").toggle();
        $("div.sp_sub2").hide();
        $("div.sp_sub3").hide();
        li_over();
    });








    $("div.sp_btn").mouseover(function() {
        $(this).css("background-color", "#f0f0f0");
    });
    $("div.sp_btn").mouseout(function() {
        $(this).css("background-color", "#ffffff");
    });


});



function li_over(){
	$("div.sp_div ul li").mouseover(function(){
		$(this).css("background-color","#f0f0f0");
	});
	$("div.sp_div ul li").mouseout(function(){
		$(this).css("background-color","#ffffff");
	});

}

function click_subs() {
    $("div.sp_sub3 ul li").click(function() {
        category = $(this).html();
        idx = $(this).attr("idx");
        cid = $(this).attr("cid");
		catid = $("input[name$='txtBrand']").val();
		
	
        $("#search_product_category").val(category);
        $("input[name$='txtCategory']").val(cid);
        $("#sp_3_val").val(cid);

        $("#search_product_range").val("Range");
        $("#sp_4_val").val("");
		$("input[name$='txtRange']").val(0);
        $("div.sp_sub4 ul").html($("div.subcat." + cid + ".cat" + catid)[0].innerHTML);

        $("div.sp_sub3").hide();
        li_over();
        $("div.sp_sub4 ul li").click(function() {
            subtype = $(this).html();
            idx = $(this).attr("idx");
            cid = $(this).attr("cid");
            $("#search_product_range").val(subtype);
	        $("input[name$='txtRange']").val(cid);
            $("#sp_4_val").val(cid);
            $("div.sp_sub4").hide();
        });
    });
    /*
    category = $(this).html();
    idx = $(this).attr("idx");
    cid = $(this).attr("cid");
    */
}

			$("#BTNMAP").click(function(){
				$("#map").css("display","none");
				$("#CCSlideBox").css("display","none");
				$("#map2").css("display","block");
				$("a.map_close").css("display","block");

				if( CCmap_flag==false){
					CCmap_flag=true;
					map2 = new GMap2(document.getElementById("map2"));
					map2.setCenter(point, 8);
					map2.addOverlay(marker);
					marker.openInfoWindowHtml(s);
					map2.addControl(new GOverviewMapControl());
					map2.addControl(new GLargeMapControl());
					$("#map2").before("<a class='map_close'>[CLOSE] &nbsp;&nbsp;</a>");
				}

				$("a.map_close").click(function(){
					$(this).css("display","none");
					$("#map2").css("display","none");
					$("#map").css("display","block");
					$("#CCSlideBox").css("display","block");
				});

			});


var SubBannerNum=0;
var SubBannerTimer;

function SubBanner(num){
	SubBannerNum = numConvert(num);

	$("#SubBannerBox ul li:eq("+SubBannerNum+")").css("zIndex",2).animate({"marginTop":-370},4000,function(){

	});

	$("#SubBannerBox ul li:eq("+SubBannerNum+")").animate({"marginTop":-370},1000,function(){
		$(this).fadeOut(1000,function(){
			$(this).attr("style","");
			SubBanner(SubBannerNum+1);
		});
	});

	$("#SubBannerBox ul li:eq("+numConvert(SubBannerNum+1)+")").fadeIn(1);

}

function numConvert(num){
	if(num>2){
		return 0;
	}else{
		return num;
	}
}
























/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.2, 09.03.2009
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    09.03.2009 Version 1.2
 *    - Update for jQuery 1.3.x, removed @ from selectors
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		/*
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';

			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});
*/
		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				if(jQuery(this).attr("class")=="PNGFix"){
					var iebg = bgIMG.split('url("')[1].split('")')[0];
					jQuery(this).css('background-image', 'none');
					jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
				}
			}
		});
/*
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
*/
	}
	
	return jQuery;

};

})(jQuery);
