﻿// JavaScript Document

jQuery.noConflict(); //将变量$的控制权让给JsCOM.js 

function dc_get(id){
   return document.getElementById(id);
}
/**
* 加入收藏夹
* <a onclick="AddFavorite(window.location,document.title)" href="javascript:void(0);">
*/
function AddFavorite(sURL, sTitle) {   
    try {   
        window.external.addFavorite(sURL, sTitle);   
    } catch (e) {   
        try {   
            window.sidebar.addPanel(sTitle, sURL, "");   
        } catch (e) {   
            alert("加入收藏失败，请使用Ctrl+D进行添加"); 
			//alert("Favorite fails, use Ctrl + D to add");
        }   
    }   
}   
/**   
 * 设为首页   
 * @param {} obj 当前对象，一般是使用this引用。   
 * @param {} vrl 主页URL 
 * <a onClick="SetHome(this,window.location)" href="javascript:void(0);">
 */   
function SetHome(obj, vrl) {   
    try {   
        obj.style.behavior = 'url(#default#homepage)';   
        obj.setHomePage(vrl);   
    } catch (e) {   
        if (window.netscape) {   
            try {   
                netscape.security.PrivilegeManager   
                        .enablePrivilege("UniversalXPConnect");   
            } catch (e) {   
                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");   
            }   
            var prefs = Components.classes['@mozilla.org/preferences-service;1']   
                    .getService(Components.interfaces.nsIPrefBranch);   
            prefs.setCharPref('browser.startup.homepage', vrl);   
        }   
    }   
} 

/**
* 控制产品数量函数
* 用法：onKeyUp="this.value=get_num(this.value);"
*/
function get_num(strers)
{
  if (isNaN(strers) || strers == "" || strers==0)
  {
    return 1;
  }
  else
  {
    return parseInt(strers);
  }
}

/**
* 窗口最大化
*/
//self.moveTo(0,0);
//self.resizeTo(screen.availWidth,screen.availHeight);

/**
* 禁止后退
*/
//javascript:window.history.forward(1); 

function LoadFlash(url,wmode,width,Height)
{ 
	document.write(
	  '<embed src="' + url + '" wmode=' + wmode +
	  ' quality="high" pluginspage=http://www.macromedia.com/go/getflashplayer type="application/x-shockwave-flash" width="' + width + 
	  '" height="' + Height + '"></embed>');   
}

//首页滑动切花
function nTabs(thisObj,Num){
if(thisObj.className == "active")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i <tabList.length; i++)
{
  if (i == Num)
  {
   thisObj.className = "active"; 
      document.getElementById(tabObj+"_Content"+i).style.display = "block";
  }else{
   tabList[i].className = "normal"; 
   document.getElementById(tabObj+"_Content"+i).style.display = "none";
  }
} 
}

//<![CDATA[//加载默认样式
jQuery(function($){
    var cookie_v = $.cookie( "MyView");
	var $li =$("#view img");
	
	$li.click(function(){
	    var cookie_v = $.cookie( "MyView");//	这里读取很关键
		
		if(cookie_v=='view_1'){
			switchSkin( 'view_2' );
		}else if(cookie_v=='view_2'){
			switchSkin( 'view_1' );	
		}else{
			if (screen.width>=1280){switchSkin( 'view_1' )}else{switchSkin( 'view_2' );alert("您是"+screen.width+"x"+screen.height+"分辨率，建议使用小尺寸。");}
		}
	});
	
	//控制小图标	
	if(cookie_v=='view_1'){
		$("#view img").attr("src","images/view_1.gif");	
	}else if(cookie_v=='view_2'){
		$("#view img").attr("src","images/view_2.gif");	
	}else{
        if (screen.width>=1280){$("#view img").attr("src","images/view_2.gif")};
	}
	
});

//保存当前样式
function switchSkin(vid){
        var ali =jQuery("#view img");
		//jQuery("#cssfile").attr("href","style/"+ vid +".css"); //设置不同皮肤
		jQuery.cookie( "MyView" ,  vid , { path: '/', expires: 1000000 });
		ali.attr("src","images/"+vid+".gif");	
}
//]]>


//延迟加载图片
jQuery(function($) {
    $("img").lazyload({placeholder : "images/grey.gif"});
});

//案例展开
jQuery(function($){
    var Mysubway = $.cookie( "Mysubway");
	var $li = $("#oneway");
	var $sli = $("#subway");	
	
	$li.click(function(){
		if($sli.hasClass("none")){
			jQuery.cookie( "Mysubway" ,  "block" , { path: '/', expires: 1000000 });
			$sli.removeClass("none");
            $sli.addClass("block");
			$li.html("<img src='images/block.gif'>关闭");
		}else{
			jQuery.cookie( "Mysubway" ,  "none" , { path: '/', expires: 1000000 });
			$sli.removeClass("block");
            $sli.addClass("none");
			$li.html("<img src='images/none.gif'>展开");
		}
	
	});
	
	if(Mysubway=='none'){
		$sli.removeClass("block");
		$sli.addClass("none");
		$li.html("<img src='images/none.gif'>展开");
	}else if(Mysubway=='block'){
		$sli.removeClass("none");
		$sli.addClass("block");
		$li.html("<img src='images/block.gif'>关闭");
	}else{

	}
	
});

//收藏展开
jQuery(function($){
    var Mysubway2 = $.cookie( "Mysubway2");
	var $li = $("#oneway2");
	var $sli = $("#subway2");	
	
	$li.click(function(){
		if($sli.hasClass("none")){
			jQuery.cookie( "Mysubway2" ,  "block" , { path: '/', expires: 1000000 });
			$sli.removeClass("none");
            $sli.addClass("block");
			$li.html("<img src='images/block.gif'>关闭");
		}else{
			jQuery.cookie( "Mysubway2" ,  "none" , { path: '/', expires: 1000000 });
			$sli.removeClass("block");
            $sli.addClass("none");
			$li.html("<img src='images/none.gif'>展开");
		}
	
	});
	
	if(Mysubway2=='none'){
		$sli.removeClass("block");
		$sli.addClass("none");
		$li.html("<img src='images/none.gif'>展开");
	}else if(Mysubway2=='block'){
		$sli.removeClass("none");
		$sli.addClass("block");
		$li.html("<img src='images/block.gif'>关闭");
	}else{

	}
	
});

//概述
jQuery(function($){
    var Mysubway3 = $.cookie( "Mysubway3");
	var $li = $("#oneway3");
	var $sli = $("#subway3");	
	
	$li.click(function(){
		if($sli.hasClass("none")){
			$sli.removeClass("none");
            $sli.addClass("block");
			$("#oneway3 span").html("<img src='images/block3.gif'>关闭");
		}else{
			$sli.removeClass("block");
            $sli.addClass("none");
			$("#oneway3 span").html("<img src='images/none3.gif'>展开");
		}
	
	});
	
});

//窗口框架
function show_select_user(Obj) {
//show_select_user('标题','网址','0为窗口1为内容','总宽','总高','是否显示滚动条','标题最小高度','标题样式','边框样式','背景透明度','背景颜色','是否关闭','作用域')
var posX;var posY;var e_w,e_h;var title=Obj.title?Obj.title:'新建新窗口';var url=Obj.url?Obj.url:'about:blank';var url_type=Obj.url_type?Obj.url_type:0;var w=Obj.width?Obj.width:310;var h=Obj.height?Obj.height:150;var s=Obj.scrolling?Obj.scrolling:'auto';var t_h=Obj.title_height?Obj.title_height:24;var t_c=Obj.title_css?Obj.title_css:'';var b_c=Obj.border_css?Obj.border_css:'';var bg_a=Obj.bg_alpha?Obj.bg_alpha:0.5;var bg_c=Obj.bg_color?Obj.bg_color:'#cccccc';var closes=Obj.closes?Obj.closes:1;var target_str=Obj.target_str?Obj.target_str:self;

with(target_str) {var b_w,b_h;if(document.all){b_w=document.documentElement.clientWidth;b_h=document.documentElement.clientHeight}else{b_w=innerWidth;b_h=innerHeight}var window_scroll_top=document.documentElement.scrollTop||document.body.scrollTop;if(w>1){e_w=(w>b_w)?b_w:w;e_w=(w<200)?200:w;e_w+="px"}else{if(w==0){e_w=(b_w*0.997)+"px"}else{e_w=(b_w*w)+"px"}}if(h>1){e_h=(h>b_h)?b_h:h;e_h=(h<50)?50:h;e_h+="px"}else{if(h==0){e_h=(b_h*0.997)+"px"}else{e_h=(h*b_h)+"px"}};var div;var tmp_str="";

if(!dc_get("maps")){div=document.createElement("div");tmp_str+="<div id='maps' title='点击关闭' style='position:absolute; cursor:pointer; left:0px; top:0px; width:0px; height:0px; z-index:100; ";tmp_str+="filter: Alpha(Opacity="+parseFloat(bg_a)*100+");opacity:"+bg_a+"; background-color:"+bg_c+";";tmp_str+="'></div>";div.innerHTML=tmp_str;document.body.appendChild(div)};

if(!dc_get("msg_box")){div=document.createElement("div");tmp_str="";tmp_str+="<div id='msg_box'  class='msg_box'  style='position:absolute;z-index:1000;background-color: #ffffff; display: none; border:blue 1px solid;"+b_c+"'>";tmp_str+="   <div   id='msg_box_title' class='msg_box_title'  style='height:auto; width:100%; border-bottom:1px solid  #FFFFFF; clear:both;; background-color:blue; color:#fff; "+t_c+"'>";tmp_str+="    <div  style='display: block;float: left;width: 93%;text-align: center;;' id='msg_box_title_text'></div>";tmp_str+="     <div  style='display: block; float: right; width: 22px; text-align: center; padding: 0px; margin-top: 2px;' id='msg_box_title_exit'>";tmp_str+="  <input type='button'   title='关闭' value='×'  style='border: 1px solid #ffffcc;color: #000000; background-color: #FFFFFF;font-weight: bolder;width:18px;text-align:center;line-height:18px;height:18px;margin:0px;padding:0px;' onmouseover=\"this.style.backgroundColor='#ffffcc'\" onmouseout=\"this.style.backgroundColor=''\"  id='msg_box_title_close'>";tmp_str+="</div>";tmp_str+="<div>";tmp_str+="  <div id='box_url_div'  style='width: 100%; display: block;color:#000000;float:none;clear:both;'>";tmp_str+="<div id='box_url_div_text' style='display:none;'></div>";tmp_str+="<iframe width='100%' height='100%' name='box_url' id='box_url' frameborder='no' border='0'  scrolling='"+s+"' marginwidth='0' marginheight='0'  src=''  style='display:block'></iframe>";tmp_str+="  </div>";tmp_str+="</div>";div.innerHTML=tmp_str;document.body.appendChild(div)};

dc_get("maps").style.width=b_w+"px";dc_get("maps").style.height=(b_h+window_scroll_top)+"px";dc_get("msg_box").style.width=e_w;dc_get("msg_box").style.height=e_h;dc_get("msg_box_title").style.height=t_h+"px";dc_get("msg_box_title_text").style.lineHeight=t_h+"px";dc_get("msg_box_title_text").innerHTML=title;if(url_type!=1){dc_get("box_url").style.display="block";dc_get("box_url_div_text").style.display="none"}else{dc_get("box_url").style.display="none";dc_get("box_url_div_text").style.display="block";dc_get("box_url_div_text").style.height=(parseInt(e_h)-t_h)+"px"}

if (closes==1) {dc_get("msg_box_title_close").onclick = function() {if (dc_get("maps")) {dc_get("maps").style.display = "none";}if (dc_get("msg_box")) {dc_get("msg_box").style.display = "none";}if (dc_get("box_url")) {dc_get("box_url").src = "about:blank";}if (dc_get("box_url_div_text")) {dc_get("box_url_div_text").innerHTML = "";}}
dc_get("maps").onclick = function() {if (dc_get("maps")) {dc_get("maps").style.display = "none";}if (dc_get("msg_box")) {dc_get("msg_box").style.display = "none";}if (dc_get("box_url")) {dc_get("box_url").src = "about:blank";}if (dc_get("box_url_div_text")) {dc_get("box_url_div_text").innerHTML = "";}}}
			
var msg_box_h = parseInt(dc_get("msg_box").style.height);var msg_box_w = parseInt(dc_get("msg_box").style.width);var msg_box_t_h = parseInt(dc_get("msg_box_title").style.height);var window_scroll_top = document.documentElement.scrollTop || document.body.scrollTop;dc_get("box_url_div").style.height = (msg_box_h - msg_box_t_h) + "px";if (w != 0) {dc_get("msg_box").style.left = (b_w - msg_box_w) / 2 + "px"} else {dc_get("msg_box").style.left = "0px"}if (h != 0) {
dc_get("msg_box").style.top = ((b_h - msg_box_h) / 2 + window_scroll_top) + "px"} else {dc_get("msg_box").style.top = "0px"}dc_get("msg_box").style.display = "block";dc_get("maps").style.display = "block"; if (url_type == 1) {dc_get("box_url_div_text").innerHTML = url} else {if (document.all) {dc_get("box_url").contentWindow.document.write("<br><center><img src='/images/loading.gif'    /><BR><BR>正在加载相关页面,请稍等...</center>")} else {dc_get("box_url").contentDocument.body.innerHTML = "<br><center><img src='/images/loading.gif'    /><BR>正在加载相关页面,请稍等...</center>"}dc_get("box_url").src = encodeURI(url)}

//dc_get("msg_box_title_text").onmousedown = function(e) {if (!e) e = window.event;if (e.button == 0 || e.button == 1) {posX = e.clientX - parseInt(dc_get("msg_box").style.left);posY = e.clientY - parseInt(dc_get("msg_box").style.top);document.onmousemove = function(e) {if (e == null) e = window.event;dc_get("msg_box").style.left = (e.clientX - posX) + "px";dc_get("msg_box").style.top = (e.clientY - posY) + "px";}} else {document.onmousemove = null;}}
//dc_get("msg_box_title_text").onmouseup = function() {var m_t = dc_get("msg_box").style.top;var m_l = dc_get("msg_box").style.left;if (parseInt(m_t) < 0) {dc_get("msg_box").style.top = "0px"}if (parseInt(m_l) < 0) {dc_get("msg_box").style.left = "0px"}document.onmousemove = null;}
}}
//window.onload=show_select_user();


// 换肤的js
function getObject(elementId) { 	//获取指定id的object
	if (document.getElementById) { 
		return document.getElementById(elementId); 
	} else if (document.all) { 
		return document.all[elementId]; 
	} else if (document.layers) { 
		return document.layers[elementId]; 
	} 
}
function setCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
//--- 获取cookie
function getCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
function changeStyle(id){	//切换样式
	var stylesheet=getObject("color").href="style/skin_"+id+".css";
	setCookie("sheet",id,30);	//写入Cookie
}
function initStyle(id){
        	//初始化样式，如果cookie存在样式，则加载cookie样式，否则加载默认样式
		if(getCookie('sheet')==null || getCookie('sheet')==""){
         changeStyle(id);
		}
		else{
		 changeStyle(getCookie("sheet"));
		}	
}

//视图控制
var cookie_v = jQuery.cookie( "MyView");//	这里读取很关键
if (screen.width>=1280){
	if(cookie_v=='view_1'){document.write("<style type='text/css'>#hd,#fl,#bd,#ft{ width:1000px; min-width:1000px; }body{ font:12px/1.8 arial,helvetica,clean,sans-serif; color:#000000; }</style>");}else{document.write("<style type='text/css'>#hd,#fl,#bd,#ft{ width:1200px; min-width:1000px; }body { font:14px/1.8 arial,helvetica,clean,sans-serif; color:#000000; }body a { font-size:14px;}body a:hover {} </style>");}	
}else{
   if (cookie_v=='view_2'){document.write("<style type='text/css'>#hd,#fl,#bd,#ft{ width:1200px; min-width:1000px; }body { font:14px/1.8 arial,helvetica,clean,sans-serif; color:#000000; }body a { font-size:14px;}body a:hover {} </style>");}else{document.write("<style type='text/css'>#hd,#fl,#bd,#ft{ width:1000px; min-width:1000px; }body{ font:12px/1.8 arial,helvetica,clean,sans-serif; color:#000000; }</style>");}
	
}
