﻿
var message="";

function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return true")





function print_preview() {

	
	var cancel_function_link = document.createElement('a');
    	cancel_function_link.onclick = function(){ cancel_print_preview(); return false; };
    	cancel_function_link.setAttribute('href', '#'); 
    	var cancel_function_link_text = document.createTextNode('Return to the existing page.');
    	cancel_function_link.appendChild(cancel_function_link_text);

	var returnStatement = "<a href='javascript:window.close();'>关闭.</a>&nbsp;&nbsp;&nbsp;<a href='javascript:window.print();'>列印</a><br/>";
    	var printwindow = window.open(window.location,"_blank");
	var loading = true;

	while (loading){
    		if (printwindow.document.getElementById('display')!=null){
        	loading = false;
        	printwindow.document.getElementById('display').style.display='none';
        	printwindow.document.getElementById('display').style.visibility='hidden';   
        	printwindow.document.getElementById('printer').innerHTML=returnStatement + "" + document.getElementById('printable').innerHTML + "";
        	printwindow.document.getElementById('printer').style.visibility='visible';
        	printwindow.document.getElementById('printer').style.display='';
		printwindow.document.body.style.backgroundImage="none";
        	printwindow.print();

    		}
	}
}

function cancel_print_preview() {
	document.getElementById('display').style.visibility='visible';	
	document.getElementById('printer').style.visibility='hidden';
	document.getElementById('printer').style.display='none';	
	document.getElementById('display').style.display='';
	document.body.style.backgroundImage="url(../images/wl_bg.jpg)";
}




var tgs = new Array( 'div','table','tr','td','th','strong','a','span','li','ul', 'p');
var startSz=getFontSize();

function getFontSize() {
	if (document.cookie.indexOf("fontSize") < 0) {
		return 1;
	} else {
		var startStr = document.cookie.indexOf("fontSize") + 9;
		var endStr = document.cookie.indexOf(";", startStr);
		if (endStr == -1) {
			endStr = document.cookie.length;
		}
		return unescape(document.cookie.substring(startStr, endStr));
	}
}
		
function restFontSize(trgt)
{	
	changeFontSize( trgt, 999, 0 );
}
		
function changeFontSize( trgt, inc, type ) {
	

	if (type == 1) {
		var szs = new Array('80%','100%','120%','140%','150%');
	} else {
		var szs = new Array('100%','110%','120%','130%','140%','150%');
		var smallSzs = '100%';
	}

	if (!document.getElementById) return
	
	var d = document,cEl = null,sz = eval(startSz),i,j,cTags;

	if (type == 0) {
		sz += inc;
	}

	if ( sz < 0 ) sz = 0;
	if ( sz > (szs.length-1) ) sz = (szs.length-1);
	if ( inc == 999) sz = 1; 
	startSz = sz;
	
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) {
			cTags[ j ].style.fontSize = smallSzs;
		}
	}
	if (type == 0) {
		setCookie("fontSize", sz, nd, cpath, cdomain);
	}
}



nd= new Date();
nd.setTime (nd.getTime()+(365*24*60*60*1000));

cdomain = (location.domain) ? location.domain : null;
cpath = "/";

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
function getCookie(NameOfCookie)
{



if (document.cookie.length > 0) 
{ 



begin = document.cookie.indexOf(NameOfCookie+"="); 
if (begin != -1) 
{ 



begin += NameOfCookie.length+1; 
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); } 
}
return null; 


}
 
 


function setPopCookie(NameOfCookie, value, expiredays) 
{



var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));



document.cookie = NameOfCookie + "=" + escape(value) + 
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}


function delCookie (NameOfCookie) 
{


if (getCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}


function getHost() {
	var url = window.location.href;
	var nohttp = url.split('//')[1];
	var hostPort = nohttp.split('/')[0]
	return hostPort;
}

function changeLanguage(from, to) {
	var url = window.location.href;
    	if (url.indexOf("#") >=0)
        	url = url.substring(0,url.indexOf("#"));
			
	var today = new Date();
    var expires = new Date();
    expires.setTime(today.getTime() + 1000*60*60*24*365)
	if (to.indexOf("hk") > -1)
          document.cookie = "CwsLanguage=Cn" + "; expires=" + expires.toGMTString() + "; path=/";
	else if (to.indexOf("cn") > -1)
          document.cookie = "CwsLanguage=Sc" + "; expires=" + expires.toGMTString() + "; path=/";
	else
          document.cookie = "CwsLanguage=En" + "; expires=" + expires.toGMTString() + "; path=/";
    	window.location.href = url.replace(from, to);
}

