/* NewCn Terrace WebSite v2008 For Main Standard JavaScript
 * --------------------------------------
 * Copyright by XieRongsong in 2008-09-14
 * QQ:258374291 E-mail:xierongsong@hotmail.com
 * http://www.nc21.cn
 * --------------------------------------
 */
//comman event
function $(s){return document.getElementById(s);}

//Inisize NewCnTerrace public paras.
var newcnTerrace = new Object();
//true delegate debug mode.
newcnTerrace.isDebug = false;

//Checked and Inisize the Browers Infomations
sAgent = navigator.userAgent.toLowerCase();
newcnTerrace.IsIE			= sAgent.indexOf("msie") != -1 ;
newcnTerrace.IsGecko		= !newcnTerrace.IsIE ;
newcnTerrace.IsNetscape	= sAgent.indexOf("netscape") != -1 ;
if ( newcnTerrace.IsIE )
{
	newcnTerrace.MajorVer = navigator.appVersion.match(/MSIE (.)/)[1] ;
	newcnTerrace.MinorVer = navigator.appVersion.match(/MSIE .\.(.)/)[1] ;
}
else
{
	// Other browsers
	newcnTerrace.MajorVer = 0 ;
	newcnTerrace.MinorVer = 0 ;
}

var imgNum=0; //imgNum用于验证是否加载完图片
//图片预加载函数
function MM_preloadImages() {
	var d=document;
	//imgNum=0;
	if(d.images){
		if(!d.MM_p) d.MM_p=new Array();
		var i;
		var j=d.MM_p.length;
		var a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++){
			d.MM_p[j]=new Image;
			d.MM_p[j++].src=a[i];
			d.MM_p[j-1].onload=function(){imgNum++}; //如果加载完一个图片,则图片总量加1
		}
	}
}

//inisize images event
function preloadimg(str){
	//alert(newcnTerrace.preloadpics);
	MM_preloadImages(str);
	alert(imgNum);
}

//input event
function IFocus(it){
   it.style.background='url(redb.gif) bottom right no-repeat';
}
function IBlur(it){
   it.style.background='url(blueb.gif) bottom right no-repeat';
}
//tr list mourse evernt
function mOvr(src,clrOver){
	src.style.cursor = 'pointer';
	src.style.backgroundColor = clrOver;
}
function mOut(src,clrIn){
	src.style.cursor = 'default';
	src.style.backgroundColor = clrIn;
}

//checked and submit myform
function submitform(){
	if(document.myform.AdminName.value=="")
	{
		alert("请输入您的管理帐号！");
		document.myform.AdminName.focus();
		return false;
	}
	if(document.myform.PassWord.value == "")
	{
		alert("请输入您的密码！");
		document.myform.PassWord.focus();
		return false;
	}
	if (document.myform.verifycode.value==""){
       alert ("请输入您的图形验证码！");
       document.myform.verifycode.focus();
       return(false);
    }
	document.myform.submit();
}

//standard opendialog function
openDialog = function(stitle, url, width, height){
	if (newcnTerrace.IsIE){
		if(stitle!="modalless"){
			top.showModalDialog( url, 'NewCn2008-' + stitle, "dialogwidth:" + width + "px;dialogheight:" + height + "px;help:no;location:no;scrollbars:yes;status:no;");
		}else{
			top.showModelessDialog( url, 'NewCn2008-' + stitle, "dialogwidth:" + width + "px;dialogheight:" + height + "px;help:no;location:no;scrollbars:yes;status:no;");
		}
	}else{
		var iTop  = (screen.height - height) / 2 ;
		var iLeft = (screen.width  - width)  / 2 ;
		var sOption  = "location=no,menubar=no,resizable=no,toolbar=no,dependent=yes,dialog=yes,minimizable=no,modal=yes,scrollbars=yes,alwaysRaised=yes" +
						",width="  + width +
						",height=" + height +
						",top="  + iTop +
						",left=" + iLeft ;
		var oWindow = top.open( '', 'NewCn2008-' + stitle, sOption, true ) ;
		oWindow.moveTo( iLeft, iTop ) ;
		oWindow.resizeTo( width, height ) ;
		oWindow.focus() ;
		oWindow.location.href = url;	
		oWindow.dialogArguments = 'NewCn Terrace 2008' ;
		this.Window = oWindow ;
	}
}

//hide or show id's style
function toggle(s){
	$(s).style.display=$(s).style.display=="none"?"":"none";
}
function show(s){
    $(s).style.display="";
}
function hide(s){
    $(s).style.display="none";
}

//inilize the divbody height
initDivBody = function(){
	//top.('divbody').style.height=screen.height;//-(36+85+65) ;
	//alert($('mBody').clientwidth);
}

//Refresh pages by bodyid
Refresh = function(){
	document.location.reload();
}

//SelectOnchange Click Event Function
function selectClass(id,action){
	self.location.href=action+id;
}

//Ctrl Enter From
function CtrlEnter() {
	if(event.ctrlKey && window.event.keyCode==13) {
		this.document.myform.submit();
	}	
}

// Reset The Content Font Size
function doZoom(size){
	$('Zoom').style.fontSize=size+'px'
}

//setColor
function setColor(color_val) {
	$('textBody').style.backgroundColor = color_val;
	$('textBody').style.backgroundColor = color_val;
	writeCookie("bgColor_cookie", color_val, 24);
}
//getColor
function getColor() {
	  textBody.style.backgroundColor = "#FFFFFF";
	var bg_color = readCookie("bgColor_cookie");
	if (bg_color != null) {
		textBody.style.backgroundColor = bg_color;
	//alert(bg_color);
	}
}
// writeCookie
function writeCookie(name, value, expires)
{
  var expire = "";
  if(expires != null)
  {
	expire = new Date((new Date()).getTime() + expires * 3600000);
	expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

//go link Url by javascript
goto = function(url,target){
	cancelUp();
	if(target==0){
		top.location.href=url;
	}else{
		window.open(url);
	}
}

//Cancel the upTag Event
cancelUp = function(){
	if(newcnTerrace.IsIE){
		window.event.cancelBubble = true;
	}
}

//resetPlay Embed Player Url
play = function(id,url)
{
	self.$(id).src=url;
}

function openfull(url,w,h){
   var newwin=window.open(url + '&w=' + w + '&amp;hei=' + h,"NewCn","top="+(screen.availheight-h)/2+",left="+(screen.availwidth-w)/2+",width="+w+",height="+h+",scrollbars=yes,toolbar=n,location=no,directories=no,status=no,menubar=no,resizable=0");
   newwin.focus();
   return(newwin);
}

function setIndexPage(sid,url){
	var strhref="/NewCnTerrace/window.location.href";
	sid.style.behavior='url(#default#homepage)';
	sid.setHomePage(url); 
}

function addFavo(url,title){
	window.external.AddFavorite(url,title);
}

//input Help Focus Function Pioneer 20081028
function HelpFocus(targetid){
   var nc=document.getElementById(targetid);
   nc.style.border = '1px solid #00A8FF';
   nc.style.background = '#f5f5f5 url(/isj2008/msg_warning.gif) 4px 4px no-repeat';
   nc.style.color = '#000';
   nc.style.padding = '3px 3px 3px 23px';
}
function HelpBlur(targetid){
   var nc=document.getElementById(targetid);
   nc.style.border = 'none';
   nc.style.background = 'none';
   nc.style.color = '#999';
   nc.style.padding = '4px 4px 4px 24px';
}

function RefreshCodeImg(){
	$('checkcode').src='/NewCnTerrace/inc/getcode.asp';
}

function loadingAdv(){
	//alert("OK@!");
	setTimeout("showContAdv('contentAdv')",1000);  
}

showContAdv = function(id){
	$(id).style.display = '';
}

//forbid right content menu
//document.oncontextmenu = function(e){return false;}
/*
if(!newcnTerrace.IsIE)
{
	initDivBody();
}
*/
