// JavaScript Document
function mainNav(){
	if($(".mainNav").length>0){
		var mainNavbg = new Array;
		mainNavbg[0] = "url(images/nav01.gif) no-repeat left top";
		mainNavbg[1] = "url(images/nav02.gif) no-repeat left top";
		mainNavbg[2] = "url(images/nav03.gif) no-repeat left top";
		mainNavbg[3] = "url(images/nav04.gif) no-repeat left top";
		mainNavbg[4] = "url(images/nav05.gif) no-repeat left top";
		mainNavbg[5] = "url(images/nav06.gif) no-repeat left top";
		mainNavbg[6] = "url(images/nav07.gif) no-repeat left top";
		mainNavbg[7] = "url(images/nav08.gif) no-repeat left top";
		
		var a=$("input#pageNum").attr("value");
			$(".mainNav").css("background",mainNavbg[a]);
		
		$(".mainNav>li").each(function(i){
			   
			$(this).mouseover(function(){
				if($("select[name='menu']").length>0){
					if(i==3||i==4||i==5||i==6|i==7){
						$("select[name='menu']").css("visibility","hidden");
					}
					
				}
				$(".mainNav").css("background",mainNavbg[i]);
				if($(this).find("ul").length>0){
					$(this).find("ul").addClass("now");
				}else{
					//alert("bb");
				}
			});
			$(this).mouseout(function(){
				$(".mainNav").css("background",mainNavbg[a]);
				if($(this).find("ul").length>0){
					$(this).find("ul").removeClass("now");
				}	
				if($("select[name='menu']").length>0){
					$("select[name='menu']").css("visibility","visible");
				}
			})
		});
	}
}

function barHeight(){
	if($(".barCon").length>0 && $(".mainCon").length>0){
		if($(".barCon").height()>$(".mainCon").height()){
			$(".mainCon").height($(".barCon").height());									  
		}
	}
}

function blogHeight(){
	if($(".bar1").length>0 && $(".bar2").length>0 && $(".bar3").length>0){
		if($(".bar3").height()>$(".bar2").height()){
			$(".bar1").height($(".bar3").height());	
			$(".bar2").height($(".bar3").height());
		}
		if($(".bar3").height()>$(".bar1").height()){
			$(".bar1").height($(".bar3").height());
		}
		if($(".bar2").height()>$(".bar1").height()){
			$(".bar1").height($(".bar2").height());
		}
	}
}

function interlaced(){
	 $("ul.topList li:nth-child(odd)").addClass("singular");
}


var total;
var count = 0;
function modelShow(){
	if($(".imgShow").length >0){
		//alert("aa");
		total = $("ul.governmentImglist a").length;
		//var _width = 692;
		//$(".car_img img").hide();
		$(".imgShow img").load(function(){
			var origWidth = $(this).width();
			var origHeight = $(this).height();
			//alert(origWidth);
			//alert(origHeight);
			//$(this).width(_width);
			$(this).height(origHeight*origWidth/origWidth);
			//alert("aa");
			//$(".car_img img").show();
		});
		$("ul.governmentImglist a").each(function(i){
			$(this).click(function(){
				$(".imgShow img").width("auto");
				$(".imgShow img").height("auto");
				$(".imgShow img").attr("src",$(this).attr("rel"));
				$(".imgShow h3").text($(this).find("img").attr("alt"));
				count = i;
				return false;
			});
		});	
		var preBtn = $("a.previous");
		var nextBtn = $("a.next");
		preBtn.click(function(){
			if($("ul.governmentImglist a").eq(count-1).length>0){
				$(".imgShow img").width("auto");
				$(".imgShow img").height("auto");
				var _a = $("ul.governmentImglist a").eq(count-1);
				$(".imgShow img").attr("src",_a.attr("rel"));
				$(".imgShow h3").text(_a.find("img").attr("alt"));
				count -= 1;
			}
		});
		nextBtn.click(function(){
			if($("ul.governmentImglist a").eq(count+1).length>0){
				$(".imgShow img").width("auto");
				$(".imgShow img").height("auto");
				var _a = $("ul.governmentImglist a").eq(count+1);
				$(".imgShow img").attr("src",_a.attr("rel"));
				$(".imgShow h3").text(_a.find("img").attr("alt"));
				count += 1;
			}
		});
	}
}

function lighbox(){
	if($(".imgA").length>0){
	$(".imgA").lightBox();
	}
}


function click(){return false; }
function click1(){if(event.button!=1){return false;} }
function CtrlKeyDown(){if(event.ctrlKey){return false;} }

document.onkeydown=CtrlKeyDown;
document.onselectstart=click;
document.onmousedown=click1;


$(document).ready(mainNav);
$(document).ready(barHeight);
$(document).ready(blogHeight);
$(document).ready(interlaced);
$(document).ready(modelShow);
$(document).ready(lighbox);
