$(function(){
		   
		 	//Highlight current page in navigation
	function ht_current(){
	$("#nav_cnr li").eq(pg).addClass("active");
	}
	
		   
	//creating box1 layout
	$(".box1").wrapInner('<div class="bx_in"></div>');
	$(".box1").prepend('<div class="cor1"></div><div class="cor2"></div><div class="shd"></div>');
	$(".box1 .bx_in").append('<div class="cb"></div>');
	
	//creating box2,box4,box5,box6,box9,box10 layout
	$(".box2").wrapInner('<div class="bx2_in"></div>');
	$(".box4").wrapInner('<div class="bx_in"></div>');
	$(".box5").wrapInner('<div class="bx_in"></div>');
	$(".box6").wrapInner('<div class="bx_in"></div>');
	$(".box9").wrapInner('<div class="bx_in"></div>');
	$(".box10").wrapInner('<div class="bx_in"></div>');
	
	//creating box8 layout
	$(".box8 .cnt").wrapInner('<div class="bbg"><div class="top"><div class="btm"><div class="cnt2"></div></div></div></div>');
	$(".box8 .cnt2").prepend('<img src="/wp-content/themes/his-v1.0/images/qt3.png" class="ig1" alt="" /><img src="/wp-content/themes/his-v1.0/images/i9.png" class="ig2" alt="" />');
	
	//creating box10 layout
	$(".box10").prepend('<img src="/wp-content/themes/his-v1.0/images/shd_lft.png" class="slft" alt="" /><img src="/wp-content/themes/his-v1.0/images/shd_rgt.png" class="srgt" alt="" />');
	
	//creating box11 layout
	$(".box11").wrapInner('<div class="ext"><div class="mid"><div class="top"><div class="btm"></div></div></div></div>');
	
	//off-box layout creating
	$(".off_box").wrapInner('<div class="mid"><div class="top"><div class="btm"><div class="cnt"></div></div></div></div>');
	$(".off_box .mid").prepend(' <img src="/wp-content/themes/his-v1.0/images/i12.png" alt="" class="ig" />');
	
	//creating bnr2 layout
	$(".bnr2 .in").wrapInner('<div class="cnt"><div class="cnt2">');
	$(".bnr2 .cnt2").prepend('<div class="cor1"></div><div class="cor2"></div>');
	
	//creating testi layout for quote
	$(".testi").prepend('<div class="qt1"></div><div class="qt2"></div>');
	
	
	//clearing elements
	$("#b_in").append('<div class="cb"></div>');
	
	//pg1 bd shadow (created Manually)
	//$("#pg1 #b_in").after('<div class="bsbtm"></div>');
	
	// pg2 fixes
	$(".bnr .in").append('<img src="/wp-content/themes/his-v1.0/images/shd_lft.png" alt="" class="slft" /><img src="/wp-content/themes/his-v1.0/images/shd_rgt.png" alt="" class="srgt" />');
	$("#pg2 #b_in").wrapInner('<div class="bin"></div>');
	
	
	//Scroller
	function scr1Loaded(){
	bx_size = 276;
	scl_length = 1-$(".scroller .scroll .col").length;
	cl=0;
	$(".scroller .bbak").animate({opacity:0.5});
	
	
	$(".scroller .bbak").click(function(){
			moveLeft();
    });
	
	$(".scroller .bnxt").click(function(){
			moveRight();
    });
	
	tout=setTimeout(moveAuto, 4200);
	
	//bugfix in IE7/8
	$(".bnxt").animate({opacity:0});
	$(".bnxt").animate({opacity:1});
	}
	
	function moveLeft(){
		if(cl<0){
		cl++;
		$(".scroller .scroll").animate({marginLeft : (bx_size*cl)+"px"},"slow","swing" );
		$(".scroller .bnxt").animate({opacity:1});
		clearTimeout(tout);
		tout=setTimeout(moveAuto, 4200);
		}
		if(!(cl<0)){
			$(".scroller .bbak").animate({opacity:0.5});
		}
	}
	
	function moveRight(){
		if(cl>scl_length){
		cl--;
		$(".scroller .scroll").animate({marginLeft : (bx_size*cl)+"px"},"slow","swing" );		
		$(".scroller .bbak").animate({opacity:1});
		clearTimeout(tout);
		tout=setTimeout(moveAuto, 4200);
		}
		if(!(cl>scl_length)){
			$(".scroller .bnxt").animate({opacity:0.5});
		}
	}
	function moveFirst(){
		$(".scroller .scroll").animate({marginLeft : 0+"px"},"slow","swing" );
		$(".scroller .bnxt").animate({opacity:1});
		$(".scroller .bbak").animate({opacity:0.5});
		cl = 0;
		clearTimeout(tout);
		tout=setTimeout(moveAuto, 4200);
	}
	function moveAuto(){
		if(cl>scl_length){
		 moveRight();
		}
		else{
			moveFirst();
		}
	}	
	//End Scroller
	
	
	//Scroller2
	function scr1Loaded2(){
	bx_size2 = 630;
	scl_length2 = 1-$(".scroller2 .scroll .col").length;
	cl2=0;
	$(".scroller2 .bbak").animate({opacity:0.5});
	
	
	$(".scroller2 .bbak").click(function(){
			moveLeft2();
    });
	
	$(".scroller2 .bnxt").click(function(){
			moveRight2();
    });
	
	tout2=setTimeout(moveAuto2, 4200);
	
	
	//bugfix in IE7/8
	$(".bnxt").animate({opacity:0});
	$(".bnxt").animate({opacity:1});
	}
	
	function moveLeft2(){
		if(cl2<0){
		cl2++;
		$(".scroller2 .scroll").animate({marginLeft : (bx_size2*cl2)+"px"},"slow","swing" );
		$(".scroller2 .bnxt").animate({opacity:1});
		clearTimeout(tout2);
		tout2=setTimeout(moveAuto2, 4200);
		$(".scroller2 .tabs li").removeClass("active");
		$(".scroller2 .tabs li").eq(-cl2).addClass("active");
		}
		if(!(cl2<0)){
			$(".scroller2 .bbak").animate({opacity:0.5});
		}
	}
	
	function moveRight2(){
		if(cl2>scl_length2){
		cl2--;
		$(".scroller2 .scroll").animate({marginLeft : (bx_size2*cl2)+"px"},"slow","swing" );		
		$(".scroller2 .bbak").animate({opacity:1});
		clearTimeout(tout2);
		tout2=setTimeout(moveAuto2, 4200);
		$(".scroller2 .tabs li").removeClass("active");
		$(".scroller2 .tabs li").eq(-cl2).addClass("active");
		}
		if(!(cl2>scl_length2)){
			$(".scroller2 .bnxt").animate({opacity:0.5});
		}
	}
	function moveFirst2(){
		$(".scroller2 .scroll").animate({marginLeft : 0+"px"},"slow","swing" );
		$(".scroller2 .bnxt").animate({opacity:1});
		$(".scroller2 .bbak").animate({opacity:0.5});
		cl2 = 0;
		clearTimeout(tout2);
		tout2=setTimeout(moveAuto2, 4200);
		$(".scroller2 .tabs li").removeClass("active");
		$(".scroller2 .tabs li").eq(-cl2).addClass("active");
	}
	function moveAuto2(){
		if(cl2>scl_length2){
		 moveRight2();
		}
		else{
			moveFirst2();
		}
	}	
	
	function moveTo2(pr){
		cl2 = -pr+1;
		clearTimeout(tout2);
		moveAuto2();
		if(cl2>scl_length2){
			$(".scroller2 .bnxt").animate({opacity:1});
		}
		if(!(cl2<0)){
			$(".scroller2 .bbak").animate({opacity:0.5});
		}
	}
	
	$(".scroller2 .tabs li").click(function(){
			moveTo2($(".scroller2 .tabs li").index(this));
	});
	//End Scroller2
	
		   
});

//adjustng 4 home page boxes gor same height
function correctBox(){
	var h1 = 0;
	for(i=0; i<4; i++){
		h1 = h1>$(".box2 .cnt").eq(i).height()?h1:$(".box2 .cnt").eq(i).height();;
	}	
	$(".box2 .cnt").height(h1);
}

function createUnderConstructionPage(){
	$("body").addClass("uc");
	$(".bnr .in").append('<img src="images/shd_lft.png" alt="" class="slft" /><img src="images/shd_rgt.png" alt="" class="srgt" />');
	$("#b_in").append('<img src="images/under-construction.jpg" alt="Please Pardon Our Dust. We are Currently Under Construction. Please Check Back Soon" />');
}