﻿$(document).ready(function(){
	correctPNG();	
	//二级菜单
	/*$('.main_nav').mouseover(function(){
		var id=this.id;
		var submenu=$("#sub"+id);
		var p=$('#submenu').position();
		var MenuTop=p.top+0;
		var MainMenuWidth=$('#'+id).width();
		var MaxWidth=$('#submenu').width();
		var SubMenuWidth=submenu.width();
		var pos = $(this).position();
		var MenuLeft=pos.left;
		$('.submenu_class').hide();
		submenu.show();
		MenuLeft=MenuLeft-5;
		submenu.offset({top:MenuTop,left:MenuLeft});
	});*/
	$('body').click(function(){
		$('.submenu_class').hide();	 
		$("#tel_th_select").hide();
	});	
	//在线客服Email,qq,msn切换
	$('.subservice_class').hide();
	$("#subservice_message").show();
	$curSer="service_message";
	$('.service_nav').click(function(){
		var id=this.id;
		var subservice=$("#sub"+id);
		$('.subservice_class').hide();
		subservice.show();
		if(id=="service_message"){
			$("#service_message").attr("src","/images/service_message.jpg");
			$("#service_qq").attr("src","images/service_qq2.jpg");	
			$("#service_msn").attr("src","images/service_msn2.jpg");
			$curSer="service_message";
		}else if(id=="service_qq"){
			$("#service_message").attr("src","/images/service_message2.jpg");
			$("#service_qq").attr("src","images/service_qq.jpg");	
			$("#service_msn").attr("src","images/service_msn2.jpg");
			$curSer="service_qq";
		}else if(id=="service_msn"){
			$curSer="service_msn";
			$("#service_message").attr("src","/images/service_message2.jpg");
			$("#service_qq").attr("src","images/service_qq2.jpg");	
			$("#service_msn").attr("src","images/service_msn.jpg");
		}			
	});
	$('.service_nav').mouseover(function(){
		var id=this.id;
		if(id!=$curSer){
			$("#"+id).attr("src","/images/"+id+".jpg");
		}			
	});
	$('.service_nav').mouseout(function(){
		var id=this.id;
		if(id!=$curSer){
			$("#"+id).attr("src","/images/"+id+"2.jpg");
		}			
	});		
	
	//案例并列显示与图文显示
	$('.subcase_class').hide();
	//$("#subcase_frame").show();	
	//$curCase="case_frame";
	$("#subcase_paratactic").show();	
	$curCase="case_paratactic";
	$('.case_nav').click(function(){
		var id=this.id;
		if(id=="case_paratactic"){
			$curCase="case_paratactic";
			$("#case_paratactic").attr("src","/images/"+id+".jpg");
			$("#case_frame").attr("src","images/case_frame2.jpg");			
		}else if(id=="case_frame"){
			$curCase="case_frame";
			$("#case_paratactic").attr("src","/images/case_paratactic2.jpg");
			$("#case_frame").attr("src","/images/"+id+".jpg");
		}		
	});	
	$('.case_nav').mouseover(function(){
		var id=this.id;
		if(id!=$curCase){
			$("#"+id).attr("src","/images/"+id+".jpg");
		}		
	});	
	$('.case_nav').mouseout(function(){
		var id=this.id;
		if(id!=$curCase){
			$("#"+id).attr("src","/images/"+id+"2.jpg");
		}		
	});	
	//新闻列表分级显示
	$('.subnews_class').hide();
	$("#subnews_2").show();
	$('.news_nav').mouseover(function(){
		var id=this.id;
		var subnews=$("#sub"+id);
		$('.subnews_class').hide();
		subnews.show();
	});	
	$("select#select_cate").jgdDropdown({
		clsLIExpand: false,
		selected: 'RS'
	});	
	$('.case_container').hover(
		function(){
			$(".case_title", this).stop().animate(
				{top:'100px'},
				{queue:false,duration:160}
			);
		},
		function(){
			$(".case_title", this).stop().animate(
				{top:'186px'},
				{queue:false,duration:160}
			);
	});
});

function img_auto_resize(p,w,h){
	var pw,ph;
	var c;
	pw = p.width;
	ph = p.height;
	if(w>0 && pw>w){ph=ph*(w/pw);pw=w;}
	if(h>0 && ph>h){pw=pw*(h/ph);ph=h;}
	p.width=pw;
	p.height=ph;
}

function mhHover(cls){
	event.srcElement.className = cls;
}

function checkNumber(par_val){
	if(par_val==""){
		return false;
	}else{
		for(i=0; i<par_val.length; i++){
			if (par_val.substring(i, i+1)!="."){
				if (par_val.substring(i, i+1)<"0" || par_val.substring(i, i+1)>"9"){
					return false;
				}
			}
		}
		return true;
	}
}

//使用 IE6.0 和 IE5.5 中的 PNG 格式的背景透明
// correctly handle PNG transparency in Win IE 5.5 & 6.0
function correctPNG(){
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if ((version < 7.0) && (document.body.filters)){
		for(var j=0; j<document.images.length; j++){
			var img = document.images[j];
			var imgName = img.src.toUpperCase();
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
				var imgID = (img.id) ? "id='" + img.id + "' " : "";
				var imgClass = (img.className) ? "class='" + img.className + "' " : "";
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				var imgStyle = "display:inline-block;" + img.style.cssText;
				if (img.align == "left") imgStyle = "float:left;" + imgStyle;
				if (img.align == "right") imgStyle = "float:right;" + imgStyle;
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
				var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
				img.outerHTML = strNewHTML;
				j = j-1;
			}
		}
	}
}

//刷新验证码
function reloadSecurityCode(obj){
	var strlink=$('#'+obj).attr('src');
	strlink+=strlink.indexOf('?')=='-1'?"?":"&";
	strlink+="thistime="+Math.random();
	$('#'+obj).attr("src",strlink);
}

//复制到剪贴板 并且提示
function CopyToClipBoard(content,tip){
	window.clipboardData.setData("Text",content);
	if(tip!='')alert(tip);
}

function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}

//设为首页
function setHomepage() {
	if (document.all) {
		document.body.style.behavior = 'url(#default#homepage)';
		document.body.setHomePage(document.URL);
	} else if (window.sidebar) {
		if (window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			} catch (e) {//火狐浏览器
				alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config, 然后将项 signed.applets.codebase_principal_support 值该为true");
			}
		}
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
		prefs.setCharPref('browser.startup.homepage', document.URL);
	}
}

