﻿//<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
//======================
//去掉链接虚线框
$(document).ready(function(){
	$("a").focus(function(){ this.blur();});	
	
	$("#btn_search").hover(
		function(){$(this).addClass("btn_search_on");},
		function(){$(this).removeClass("btn_search_on");} 
	); 
	return stuHover();
});

//检测搜索表单
function checkform(){
	var str, con;
	str = /\S/;
	con = $("#search_keyword");
	
	if((!con.value)||(con.value=='')){
		alert("请输入查询关键词 !");
		con.focus();
		return false;
	}	
}

//子站跳转
function jupm_to(obj){	
	if(obj.options[obj.selectedIndex].value!="0"){
		location.href=obj.options[obj.selectedIndex].value;
	}
}

//加入收藏(支持FF)
function add_bookmark(){
	var title=document.title
	var url=document.location.href
	if(window.sidebar){
		window.sidebar.addPanel(title,url,"");
	}else if(window.opera && window.print){
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',title);
		mbm.click();
	}else if( document.all ){
		window.external.AddFavorite(url,title);
	}
}
	
//隐藏子分类
function stuHover() {
	var cssRule;
	var newSelector;
	for (var i=0; i< document.styleSheets.length; i++)
		for (var x=0; x< document.styleSheets[i].rules.length; x++)
			{
			cssRule = document.styleSheets[i].rules[x];
			if (cssRule.selectorText.indexOf("LI:hover") >= 0)
			{
				 newSelector = cssRule.selectorText.replace(/LI:hover/gi, "LI.iehover");
				document.styleSheets[i].addRule(newSelector , cssRule.style.cssText);
			}
		}
	var getElm = $("#cat_nav li")//.getElementsByTagName("LI");
	for (var i=0; i<getElm.length; i++) {
		getElm[i].onmouseover=function() {
			this.className+=" iehover";
		}
		getElm[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
	
	var B= $("img");
	for(var i=0;i<B.length;i++){
		if (B[i].init){
			var cache=B[i].init.split("|");
			if (CInt(cache[0])>0 && CInt(cache[1])>0){
				if (B[i].width>CInt(cache[0]) || B[i].height>CInt(cache[1])){
					if (B[i].width/CInt(cache[0]) >= B[i].height/CInt(cache[1])){B[i].width=CInt(cache[0])}else{B[i].height=CInt(cache[1])}
				}
			}
			
			B[i].onload=function(){
				var cache=this.init.split("|");
			    if (CInt(cache[0])>0 && CInt(cache[1])>0){
				    if (this.width>CInt(cache[0]) || this.height>CInt(cache[1])){
					if (this.width/CInt(cache[0]) >= this.height/CInt(cache[1])){this.width=CInt(cache[0])}else{this.height=CInt(cache[1])}
				    }
			    }
			}
		}
	}	
}

function initImage(){
	var o= $("img");
	for(var i=0;i<o.length;i++){
		if (o.onInit){
			var cache=o.init.split("|");
			if (CInt(cache[0])>0 && CInt(cache[1])>0){
				if (o.width>CInt(cache[0]) || o.height>CInt(cache[1])){
					if (o.width/CInt(cache[0]) >= o.height/CInt(cache[1])){o.width=CInt(cache[0])}else{o.height=CInt(cache[1])}
				}
			}
		}
	}
}
function CInt(value){
    if (isNaN(parseInt(value))){
	  return 0;
	}else{
	  return parseInt(value);
	}
  }
  
//在指定位置显示大图
var FilterString="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)"

function ReturnImgCode(ImgPath){
	if(ImgPath=="") return false;
	var imghtml="";
	imghtml='<a href="'+ImgPath+'" class="highslide" onclick="return hs.expand(this)"><img src="'+ImgPath+'" alt="" /></a>'	
	return imghtml	
}

function ShowImg(ImgPath){
	if (document.getElementById){
		var ImgObj=document.getElementById("img_big");
		if (ImgObj.filters && window.createPopup)
			if (ImgObj.filters && window.createPopup){
				ImgObj.style.filter=FilterString;
				ImgObj.filters[0].Apply();
			}
		ImgObj.innerHTML=ReturnImgCode(ImgPath);
		ImgObj.filters[0].Play();
		return false;
	}
}
