$(document).ready(function() {
	if (jQuery.browser.msie) { // PNG support for IE6
	  if(parseInt(jQuery.browser.version) == 6) {
		$('#home_productselect, .raquo i, .stitle b, .icon i, .icon em').ifixpng();
		$('.slider_frame_nav a').attr("href","#c");
	  }	
	}
	/*if ( $('.page_heading .heading_box').attr("id") != "service_Wireless") {
		 $('.page_heading .heading_box').addClass("hb_transpblue").ifixpng();
	}
	$('#service_Fibre').removeClass('hb_transpblue');
	$('#service_Wireless').removeClass('hb_transpblue').addClass('hb_transpblue2');
	*/
		if ( $('.subnav').text() == 0 ) {
			$('.subnav_wrap').css("display","none");
			$('.main_content').css("width","100%");
		}

	// slider
	$('.client_logos a img').attr({width: "150",height: "100"});
	$('.client_logos a:nth-child(4n)').css("marginRight","0");
	var $holder = $('#slider_frame_holder');
	var $trigger = $('.slider_frame_nav li a');
	$selected = $(".slider_frame_nav li:first");
	$selected.addClass("slider_sel");	
	
	/*$('.service_slider a').each(function(e) {
		var c = e+1;
		$(this)
            .attr({'class': 'cross-link','href': '#'+c })
            .wrapInner('<strong><i><span></span></i></strong>');
	 });
	 $('.panel').each(function(e) {
	 	var c = e+1;
	 	$(this).attr('title','Panel '+c);
	 });
	 */
	$holder.cached_top=-1;
	$trigger.each(function() {
		$(this).click(function() {
            clearTimeout(tim);
			$(this).blur();
			$selected.parent('ul').find('li.slider_sel').removeClass("slider_sel");
			$selected = $(this).parent();
			$selected.addClass("slider_sel");			
			
			var top=-1;
			if ($(this).attr("id") == 'show_frame1') {
				top=-1;
			} else if ($(this).attr("id") == 'show_frame2') {
				top=-351;
			} else if ($(this).attr("id") == 'show_frame3') {
				top=-701;
			} else if ($(this).attr("id") == 'show_frame4') {
				top=-1051;
			} else if ($(this).attr("id") == 'show_frame5') {
				top=-1401;
			} else if ($(this).attr("id") == 'show_frame6') {
				top=-1751;
			} else if ($(this).attr("id") == 'show_frame7') {
				top=-2101;
			} else if ($(this).attr("id") == 'show_frame8') {
				top=-2451;
			} else if ($(this).attr("id") == 'show_frame9') {
				top=-2801;
			}					

			if(Math.abs(top-$holder.cached_top)>400){
			    $holder.fadeOut(function(){
				    $holder.css({"top": top+"px"});
				    $holder.fadeIn();
				});
			}else{
				$holder.animate({"top": top+"px"});
			}

			$holder.cached_top=top;
		});
	});

    var t=1; var tim;

    sliderNext=function (){
        $trigger.eq(t++).click();
        if(t>=$trigger.length)t=0;
        tim=setTimeout('sliderNext()',10000);
    }
    if($trigger.eq(0).attr('id')=='show_frame1'){
        tim=setTimeout('sliderNext()', 10000);
    }else{
        $trigger.eq(0).click();
    }
    
	
// Rotating logos

logo_down=function(n){
	if(n<2){
		$('.clients_logos a').css({backgroundPosition:'0% 0%'});
	}
	if(n>0){
		$('.clients_logos a').each(function(){ $(this).animate({'backgroundPosition': '(0% -'+(70*n)+')'},300+Math.floor(Math.random()*500));});
	}

	if(n>2)n=0;



	lt=setTimeout('logo_down('+(n+1)+')',7000);
};


logo_down(0);
});
