/*	

	created by away@zenta.cn
	version 
	version.2.0 200808
	version 1.1 200708
	

	version 1.0 200707 
*/
function toolHidden()
{
 
	document.getElementById("Tool").className = "ToolHidden";


}
function changeStyleById(id,styleclass)
{
 
	document.getElementById(id).className = styleclass;


}


/*data */
function exportExcel(atblData,TabName)
{
	var temStr;
	 if (typeof(EXPORT_OBJECT)!="object"){ 
	   divtem.insertAdjacentHTML("afterBegin","<OBJECT style=¡¯display:none¡¯ classid=clsid:0002E510-0000-0000-C000-000000000046 id=EXPORT_OBJECT></Object>"); 
	 } 
	 with (EXPORT_OBJECT){ 
		DataType = "HTMLData"; 
		HTMLData = atblData.outerHTML;
		try{ 
		  ActiveSheet.Export(TabName+".xls", 0); 
		  alert("The file is exported"); 
		} 
		catch (e){ 
		  alert("Error,Confirm if you have installed microsoft Excel"); 
		}  
	  } 
}
/*front*/
function setStyle(myid,myclass)
{
//alert (class);
	document.getElementById(myid).className=myclass;

}
function viewImage(objectid,url)
{
	objectid.innerHTML="<img src='"+url+"'>";
}
function setNull(objectid)
{
	objectid.innerHTML=" ";
}
function Do()
{
	alert(mceAdvImage.loaction);

}


function htmlMessage(HtmlId,ErrorMsg)
{
	
	document.getElementById(HtmlId).innerHTML="<img src='../img/infor.gif'>&nbsp;&nbsp;" + ErrorMsg;
	document.getElementById(HtmlId).className = "Alert";
	/**/
	//alert(errormsg);
}
function selectItem(HtmlId,idlist)
{
	//alert(document.getElementById(HtmlId).value);
	if(document.getElementById(HtmlId).checked)
	{   if (document.getElementById(idlist).value.length==0)
		{
		document.getElementById(idlist).value=",";
		}
		document.getElementById(idlist).value+=document.getElementById(HtmlId).value+',';
		}
	else
	{
		str=","+document.getElementById(HtmlId).value+",";
 
		document.getElementById(idlist).value=document.getElementById(idlist).value.replace(str,",");
		}

}
 
function confirmGo(Msg,Url)
{
   if (confirm(Msg)==true)
   {
        window.location.replace(Url);
   }
   else
   {
   }  
}
function goUrl(Url)

{

   window.location.replace(Url);

}
function confirmCloseWindow(Msg)
{
   if (confirm(Msg)==true)
   {
        window.close();
   }
   else
   {
   }  
}
//str='resizable=yes,width=250,height=320'
function windowOpen(Url,Str)
{
	window.open(Url,'SaveData',Str);
}
function hiddenTag(Tags)
{
   if (Tags.style.display=='none')
   {
     Tags.style.display='inline';
   }
   else
   {
     Tags.style.display='none';	 
   }  
}
function disableTag(Tags)
{


	if (Tags.disabled==false)
   {
     Tags.disabled=true;
   }
   else
   {
     Tags.disabled=false;	 
   }  
}

 

// press only int 
function pressSpInt() 
{
	var iCode=event.keyCode;
	if((iCode>95&&iCode<106)||(iCode>47&&iCode<59)||(iCode==8)||(iCode==190)||(iCode==46)||(iCode==37)||(iCode==39)||(iCode==9)){
		event.returnValue=true;
	}
	else{
		event.returnValue=false;
	}
}
function pressString(CharType) 
{ if (CharType=="int") 
  {
	var iCode=event.keyCode;
	if((iCode>95&&iCode<106)||(iCode>47&&iCode<59)||(iCode==8)||(iCode==190)||(iCode==46)||(iCode==37)||(iCode==39)||(iCode==9)){
		event.returnValue=true;
	}
	else{
		event.returnValue=false;
	}
	}
	if (CharType=="char") 
  {
	var iCode=event.keyCode;
	if((iCode>95&&iCode<106)||(iCode>47&&iCode<59)||(iCode==8)||(iCode==190)||(iCode==46)||(iCode==37)||(iCode==39)||(iCode==9)){
		event.returnValue=true;
	}
	else{
		event.returnValue=false;
	}
	}

}

//This function was re-written form DreamWeaver v4.01 by .
//
//var oAddCondition = getObjByID("AddCondition");
function getObjByID(n) {
	var p,i,x;
	var d=document; 
	if(!(x=d[n])&&d.all) x=d.all[n];
	for(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=getObjByID(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); 
	return x;
}

 

/* */
function checkSubmit(object,message)
{
	if(object.value=='1') 
	{
		alert(message); 
		//object.focus(); 
		return false;  
	}
	return true;
}
function setSubmit(object,myvalue)
{
	if(object.value=='1') 
	{
		object.value=myvalue
		//object.focus(); 
		//return false;  
	}
	return true;
}
function checkCortrolNull(object,message)
{
	if(object.value=='') 
	{
		alert(message); 
		object.focus(); 
		return false;  
	}
	return true;
}
function checkCortrolNum(object,message)
{
	if((isNaN(object.value))||(object.value=='')) 
	{
		alert(message); 
		object.focus(); 
		return false; 
	}
return true;
}
function checkCortrolNumRang(object,message,Max,Min)
{
	if((isNaN(object.value))||(object.value=='')||parseFloat(object.value)>Min||parseFloat(object.value)<Max) 
	{
		alert(message); 
		object.focus(); 
		return false;  
	}
}
function checkNum(control)
{
	  if((isNaN(control.value))||(control.value=='')) 
	{
		
		alert('Error! Input is not numeric '); 
		control.value='0'; 
		control.focus(); 
		return false;
	}

}

function submitForm(formname,action,message)
{
	//alert("---");
   if (confirm(message)==true)
   {
		formname.action=action;
		formname.submit();
   }
   else
   {
		return false;
	}
   

	

}

/*form check end*/
 
var loadImg = new Image();
loadImg.src="../image/loading.gif";
function setDomain()
{
     document.domain="zenta.cn";
}

function ChannelAction(obj,cssName){if($(obj).className!="Channel_On"){$(obj).className=cssName;}}
function ThisChannelClass(btnID){$(btnID).className="Channel_On";}
function MenuAction(obj,cssName){$(obj).className=cssName;}

function mouseAction(obj,arrayid,_flag){
    var overbg = new Array("#ffeeee");
    var outbg = new Array("#fafafa");
    if(_flag=="1"){
       obj.style.backgroundColor = overbg[arrayid];
    }
    else{
       obj.style.backgroundColor = outbg[arrayid];
    }
}

function getPageScroll(){
  var yScroll;
  if (self.pageYOffset) {
    yScroll = self.pageYOffset;
  } else if (document.documentElement && document.documentElement.scrollTop){   // Explorer 6 Strict
    yScroll = document.documentElement.scrollTop;
  } else if (document.body) {// all other Explorers
    yScroll = document.body.scrollTop;
  }

  arrayPageScroll = new Array('',yScroll) 
  return arrayPageScroll;
}

function getPageSize(){
  var xScroll, yScroll;  
  if (window.innerHeight && window.scrollMaxY) {
    xScroll = document.body.scrollWidth;
    yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    xScroll = document.body.scrollWidth;
    yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    xScroll = document.body.offsetWidth;
    yScroll = document.body.offsetHeight;
  }

  var windowWidth, windowHeight;
  if (self.innerHeight) {  // all except Explorer
    windowWidth = self.innerWidth;
    windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }  
  
  // for small pages with total height less then height of the viewport
  if(yScroll < windowHeight){
    pageHeight = windowHeight;
  } else { 
    pageHeight = yScroll;
  }

  if(xScroll < windowWidth){  
    pageWidth = windowWidth;
  } else {
    pageWidth = xScroll;
  }

  arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
  return arrayPageSize;
} 

function doScrollPage(scrolltop){
  if (self.pageYOffset) {
    self.pageYOffset=scrolltop;
  } else if (document.documentElement && document.documentElement.scrollTop){   // Explorer 6 Strict
    document.documentElement.scrollTop=scrolltop;
  } else if (document.body) {// all other Explorers
    document.body.scrollTop=scrolltop;
  }
}

function showLoading(_id,_content){
     if($(_id)==null){var loadDivObj = document.createElement("div");loadDivObj.className = "loadingdiv";loadDivObj.id = _id;loadDivObj.EventInit = false;document.body.appendChild(loadDivObj);}else{var loadDivObj = $(_id);}if (_content){loadDivObj.innerHTML = "<div  class=\"loadingtext\" style=\"padding-top:5px;\"><img src=\"../image/loading.gif\"></div><div class=\"loadingtext\">"+_content+"</div>";}else{loadDivObj.innerHTML = "<div  class=\"loadingtext\" style=\"padding-top:5px;\"><img src=\"../image/loading.gif\"></div><div class=\"loadingtext\">Loading.....</div>";}
}
function showInputErr(inputid,_id,_content,pointx,pointy){
     if($(_id)==null){var errorDivObj = document.createElement("div");errorDivObj.className = "errordiv";errorDivObj.id = _id;errorDivObj.EventInit = false;document.body.appendChild(errorDivObj);}else{var errorDivObj = $(_id);}if (_content){errorDivObj.innerHTML = _content;}else{errorDivObj.innerHTML = "Error input";}
     showPositionDiv($(inputid),_id,pointx,pointy);
}
function hideInputErr(_id){
  if($(_id))Element.hide(_id)
}
function showCover(){
    if($("divPageCover")==null){
      var coverDivObj = document.createElement("div");coverDivObj.className = "pagecover";coverDivObj.id = "divPageCover";coverDivObj.EventInit = false;document.body.appendChild(coverDivObj);
    }
    var objst = $("divPageCover").style;
    objst.display="none";
    objst.width = "100%";
    objst.height = getPageSize()[1].toString()+"px";
    objst.filter = "alpha(opacity=70)";objst.opacity = 70/100;objst.MozOpacity = 70/100;
    Element.show("divPageCover");
}

function pageClear(){
  var allselect = document.getElementsByTagName("select");
  for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "hidden";
}

function pageUnClear(){
    if($("divPageCover") && $("divPageCover").style.display!="none"){
       Effect.toggle("divPageCover",'appear',{duration:0.3});
    }
    var objselect = document.getElementsByTagName("select");
    for (var i=0; i<objselect.length; i++) objselect[i].style.visibility = "visible";
}

function showDialog(ihtml,wt,ht,ptx,pty){
    if($("divPageDialog")==null){
       var dialogDivObj = document.createElement("div");dialogDivObj.className = "pagedialog";dialogDivObj.id = "divPageDialog";dialogDivObj.EventInit = false;document.body.appendChild(dialogDivObj);
    }
    var objst = $("divPageDialog").style;
    var psize = getPageSize();
    var ssize = getPageScroll();
    objst.display="none";
    objst.height="auto";
    objst.width = wt.toString()+"px";
    objst.top = ((parseInt(psize[3].toString())-ht)/2+parseInt(ssize[1].toString())+pty).toString() + "px";
    objst.left = ((parseInt(psize[2].toString())-wt)/2+ptx).toString() + "px";
    $("divPageDialog").innerHTML = ihtml;
    Effect.toggle("divPageDialog",'appear',{duration:0.3});
    pageClear();
}

function hideDialog(){
   if($("divPageDialog"))Effect.toggle("divPageDialog",'appear',{duration:0.3})
   pageUnClear();
}

function zoomMenu(_menudiv,_btnid){
  Effect.toggle(_menudiv,'blind',{duration:0.5});
  if($(_menudiv).opened){
    $(_btnid).src='../image/closed2.gif';
    $(_menudiv).opened=false;
  }
  else{
    $(_btnid).src='../image/opened2.gif';
    $(_menudiv).opened=true;
  }
  return false;
}

function shutMenu(clickobj,divid,pointx,pointy){
   Position.clone(clickobj, divid,{offsetTop:pointy,offsetLeft:pointx,setWidth:false,setHeight:false});
//   Effect.toggle(divid,'blind',{duration:0.3})
   Element.show(divid);
}

//show specifically layer£¬X¡¢Y mouse move
function showPositionDiv(clickobj,divid,pointx,pointy)
{
    Element.hide(divid);
    Position.clone(clickobj, divid,{offsetTop:pointy,offsetLeft:pointx,setWidth:false,setHeight:false});
    Element.show(divid);
}

//show upload
function showUpload(clickobj,ownerid,divupload,pointx,pointy,_width,imgwidth,imgfor,actionfor,divshow){
	var iniimg = "";
	var ref= document.location.href.toLowerCase();
	
    var el = $(divshow);
    if($A(el.childNodes)!="" && $A(el.childNodes)[0].src!=undefined){
	  iniimg = $A(el.childNodes)[0].src.toLowerCase();  
	  if(iniimg.toLowerCase().indexOf("upload")>-1){
	    //iniimg = "../"+iniimg.replace(ref.substring(0,ref.indexOf("member")),"");
	    iniimg = "../"+iniimg.substring(iniimg.toLowerCase().indexOf("upload"))
	  }
	}
	$(divupload).innerHTML = "<iframe id=\"iframeUploader\" src=\"../Member/UploadAndSave.aspx?ownerid="+ownerid+"&imgfor="+imgfor+"&actionfor="+actionfor+"&width="+_width+"&imgwidth="+imgwidth+"&divshow="+divshow+"&divupload="+divupload+"&iniimg="+iniimg+"\" width=\"100%\" height=\"22\" frameborder=0 scrolling=no></iframe>";
	showPositionDiv(clickobj,divupload,pointx,pointy)
}
//zoom picture
function photoZoom(clickobj,divid,pointx,pointy,src)
{
   Position.clone(clickobj, divid,{offsetTop:pointy,offsetLeft:pointx,setWidth:false,setHeight:false});
   $(divid).innerHTML = "<img src='"+src+"' width=120  GALLERYIMG='false'>";
   Effect.toggle(divid,'appear',{duration:0.5})
   return false;
}

//picture zoom 
var imgzoomflag=false; 
function drawImage(ImgD,allowWidth,allowHeight){ 
 if(ImgD.src==null){
   ImgD.src="../images/nophoto.gifx.jpg";
 }
 var image=new Image(); 
 var iwidth = allowWidth;  // 
 var iheight = allowHeight;  // 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
 imgzoomflag=true; 
 if(image.width/image.height>= iwidth/iheight){ 
  if(image.width>iwidth){   
  ImgD.width=iwidth; 
  ImgD.height=(image.height*iwidth)/image.width; 
  }else{ 
  ImgD.width=image.width;   
  ImgD.height=image.height; 
  } 
  ImgD.alt=image.width+"¡Á"+image.height; 
  } 
 else{ 
  if(image.height>iheight){   
  ImgD.height=iheight; 
  ImgD.width=(image.width*iheight)/image.height;   
  }else{ 
  ImgD.width=image.width;   
  ImgD.height=image.height; 
  } 
  ImgD.alt=image.width+"¡Á"+image.height; 
  } 
 } 
}  

//tag add link
function getTagString(tags,tagtype)
{
    var temp = "";
    var arrTag = tags.split("&nbsp;");
    for (var i = 0; i < arrTag.length; i++)
    {
        if (i > 0) temp += "&nbsp;";
        temp += "<a href=\"../search/?tag=" + arrTag[i] + "&type=" + tagtype + "\" target=_blank>" + arrTag[i] + "</a>";
    }
    return temp;
}

// selecttext
function seltext(idstr){
  if($(idstr)!=null){
    return $(idstr).options[$(idstr).selectedIndex].text;
  }
  else{
    return "";
  }
}

// 
function phoneChk(obj){
     if(obj.value!=''){
      	if(!isTelphone(obj)){
      	   alert('telphone is only numeric \n 1234567890 - , blank');
      	   return false;
      	}
      }
}

function mobileChk(obj){
  if(obj.value!=''){
   if(!checkMobile(obj.value)){
    alert('Error phone number£¡');
    return false;
   }
  }
}

function isTelphone(pObj){
 var obj = eval(pObj);
 strRef = "1234567890 -,";
 for (i=0;i<obj.value.length;i++) {
  tempChar= obj.value.substring(i,i+1);
  if (strRef.indexOf(tempChar,0)==-1) {
   if(obj.type=="text") 
    obj.focus(); 
   return false; 
  }
 }
 return true;
}

function isNumber( s ){
    var regu = "^[0-9]+$";
    var re = new RegExp(regu);
    if (s.search(re) != -1) {
    return true;
    } else {
    return false;
    }
}

function checkMobile( s ){   
var regu =/^[1][3][0-9]{9}$/;
var re = new RegExp(regu);
if (re.test(s)) {
return true;
}else{
return false;
}
}

//format
 function textToHtml(chr) 
 { 
    if (chr == null) return ""; 
    chr = strReplace("<", "&lt;",chr); 
    chr = strReplace(">", "&gt;",chr); 
    chr = strReplace("\n", "<BR>",chr); 
    chr = strReplace(" ", "&nbsp;",chr); 
    chr = strReplace("'", "¡¯",chr);
    chr = strReplace("\"", "¡±",chr); 
    return chr; 
 }
 
  function htmlToText(chr) 
 { 
    if (chr == null) return ""; 
    chr = strReplace("<BR>","\n", chr); 
    chr = strReplace("<br>","\n", chr); 
    chr = strReplace("&lt;","<",chr); 
    chr = strReplace("&gt;",">", chr); 
    chr = strReplace("&nbsp;"," ",chr); 
    chr = strReplace("¡¯", "'",chr); 
    chr = strReplace("¡±", "\"",chr); 
    return chr; 
 }
 
 function jsFormat(chr){
   if (chr == null) return "";
   chr = strReplace("'","''",chr); 
   return chr
 }
 
 function jsReFormat(chr){
   if (chr == null) return "";
   chr = strReplace("''","'",chr); 
   return chr
 }
        
//×Ö·ûÌæ»»
function strReplace(search, replace, str){
 var regex = new RegExp(search, "g");
 return str.replace(regex, replace);
} 

function radvalue(_name){
  var _value = "";
  var obj = document.getElementsByName(_name);
  for(var i = 0 ; i< obj.length ; i++){
     if(obj[i].checked){
       _value = obj[i].value;
       break;
     }
  }
  return _value;
}

// selecttext
function seltext(idstr){
  if($(idstr)!=null && $(idstr)!=""){
    return $(idstr).options[$(idstr).selectedIndex].text;
  }
  else{
    return "";
  }
}

function pageLoad(){
  if($("PageMain")!=null){
    if(document.body.scrollHeight<550){
      $("PageMain").style.height = "300px";
    }
  }
}

function ANP_checkInput(bid,mv){var el=document.getElementById(bid);var r=new RegExp("^\\s*(\\d+)\\s*$");
if(r.test(el.value)){if(RegExp.$1<1||RegExp.$1>mv){alert("index out £¡");el.focus();el.select();return false;}
return true;}alert("not numeric£¡");el.focus();el.select();return false;}
function ANP_keydown(e,btnId){
var kcode;
if(window.event){kcode=e.keyCode;}
else if(e.which){kcode=e.which;}
var validKey=(kcode==8||kcode==46||kcode==37||kcode==39||(kcode>=48&&kcode<=57)||(kcode>=96&&kcode<=105));
if(!validKey){
if(kcode==13) document.getElementById(btnId).click();
if(e.preventDefault) e.preventDefault();event.returnValue=false;
}
}

function getElementTextNS(prefix, local, parentElem, index) {
    var result = "";
    if (prefix && isIE) {
        // IE/Windows way of handling namespaces
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    } else {
        // the namespace versions of this method 
        // (getElementsByTagNameNS()) operate
        // differently in Safari and Mozilla, but both
        // return value with just local name, provided 
        // there aren't conflicts with non-namespace element
        // names
        result = parentElem.getElementsByTagName(local)[index];
    }
    if (result) {
        // get text, accounting for possible
        // whitespace (carriage return) text nodes 
        if (result.childNodes.length > 1) {
            return result.childNodes[1].nodeValue;
        } else {
			if(result.childNodes.length < 1)
//				return "n/a";
                return "";
            return result.firstChild.nodeValue;    		
        }
		
    } else {
//        return "n/a";
          return "";
    }
}
 

function setCookie(name,value)
{
    var Days = 1; 
    var exp  = new Date();   
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}



function getCookies(name)        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return "";

}


function getCookie(name,valuename)
 {
	var arg = valuename + "=";
	var alen = arg.length;
	var arrayvalue = getCookies(name);
    var array_value = arrayvalue.split('&');
	var clen = array_value.length;
	var i=0;
	while(i<clen) 
	{
		var j=alen;
		var slen = array_value[i].length;
		if(array_value[i].substring(0,j)==arg)
		    return array_value[i].substring(j,slen);
		    
		i=i+1;
		
	
    }
    return "";
}


function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

function showFailure(){
     $("divloading").innerHTML = "<div style='margin-left:20px;color:#f30'>login false</div>";
     setTimeout("if($(\"divloading\"))Element.hide(\"divloading\");",1000);
}