﻿function fnAddToFavs( pageurl, pagetitle){
	window.external.AddFavorite( pageurl, pagetitle)
}

function setHomePage( obj, url){
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage( url);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

var flag=false; 
function DrawImage(ImgD, width_x, height_x){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
flag=true; 
if(image.width/image.height>= width_x/height_x){ 
if(image.width>width_x){ 
ImgD.width=width_x; 
ImgD.height=(image.height*width_x)/image.width; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
ImgD.alt=image.width+"x"+image.height; 
} 
else{ 
if(image.height>height_x){ 
ImgD.height=height_x; 
ImgD.width=(image.width*height_x)/image.height; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
ImgD.alt=image.width+"x"+image.height; 
} 
} 
} 

/*
函数功能：求得当然页面的文件名
参数说明：无参数
作者：盛天
日期：2003-11-17
返回值：当然文件名
*/
function GetCurrFileName(){
	var strURL =window.location.toString();
	var l;
	if (strURL.indexOf("?")==-1)
	{
		l = strURL.length;
	}
	else
	{
		l = strURL.indexOf("?");
	}
	
	return strURL.substring(strURL.lastIndexOf("/")+1,l);
}


//判断是否位空白
function isBlank( s ) {
	var len = s.length;
	for( i = 0; i < len; i ++ )
	{
		if( s.charAt(i) != " " )
		return false;
	}
	return true;
} 


function isInBag(s,bag){  
  var i;
  for (i = 0; i < s.length; i++){   
    var c = s.charAt(i);
    if (bag.indexOf(c) == -1){
      return false;
    }
  }
  return true;
}

//函数名：isInt
//功能介绍：检查是否为数字
//参数说明：要检查的数字
//返回值：1为是数字，0为不是数字
function isInt(str){
  if (isInBag(str,"0123456789")) return true;
  else return false;
}

//邮件有效性检查函数
function VerifyEmail(email) {
	var reg = /^([a-zA-Z0-9_\.-]+)@(([a-zA-Z0-9_-]+)\.)+[a-zA-Z]{2,3}$/;
	if( reg.test(email) ) {	return true;}
	return false;
}
//电话有效性检查函数
function VerifyTelephone(telephone) {
	var reg = /^((((\(|（){0,1}[0-9]{3,4}(\)|）|-| ){0,1}){0,1}[0-9]{7,8}((-| ){1}[0-9]+)*)|(0{0,1}13[0-9]{9})){1}$/;
	if( reg.test(telephone) ) {	return true;}
	return false;
}



//
var num = 20;
var notNullElements = new Array( num);
var isNumElements = new Array( num);
var isCharacterElements = new Array( num);
var notNullElements_p = 0;
var isNumElements_p = 0;
var isCharacterElements_p = 0;
var theform;
//------------------------------------------------------

function need( obj){
		 notNullElements[ notNullElements_p++] = obj;
		 return true;
}
function isNum( obj){
		 isNumElements[ isNumElements_p++] = obj;
		 return true;
}
//------------------------------------------------------


function ctrim(s){
	str=s;
	while (str.substr(str.length-1,1)==' '|| str.substr(str.length-1,1)=='　'){
	str=str.slice(0,str.length-1);
	}
	while (str.substr(0,1)==' '|| str.substr(0,1)=='　'){
	str=str.slice(1,str.length);
	}
	return str;
}

function check(){
	ret  = true;
	for ( i =0; i < notNullElements_p; i++) {
		if ( notNullElements[i].value == null) {
			alert("Please specify all blank marked with *.");
			notNullElements[i].focus();
			return false;
		}
		if ( ctrim(notNullElements[i].value) == "") {
			alert("Please specify all blank marked with *.");
			notNullElements[i].focus();
			return false;
		}
	}
	
	for ( i =0; i < isNumElements_p; i++) {
	 //if ( isNumericElements[i].value >= '1' && isNumericElements[i].value <= '0') {
	 floatValue=parseFloat(isNumElements[i].value)
	 if ( isNaN(floatValue)) {
		alert("请输入数值!");
		isNumElements[i].focus();
		return false;
	 }
	}
	return ret;
}

function validate( obj){
	  theform = obj;
	  if ( check() == true) {
	  	//theform.submit();
		return true;
	  }else{
	  	return false;
	  }
}




// 多语种的版本 ＝＝＝＝＝＝＝＝＝＝＝＝＝＝

function checklanv( lan_id){
	ret  = true;
	for ( i =0; i < notNullElements_p; i++) {
		if ( notNullElements[i].value == null) {
			if( lan_id == 0)
				alert("有\"*\"标记的项必须填写！");
			else
				alert("Please specify all blank marked with *.");
				
			notNullElements[i].focus();
			return false;
		}
		if ( ctrim(notNullElements[i].value) == "") {
			if( lan_id == 0)
				alert("有\"*\"标记的项必须填写！");
			else
				alert("Please specify all blank marked with *.");

notNullElements[i].focus();
			return false;
		}
	}
	
	for ( i =0; i < isNumElements_p; i++) {
	 floatValue=parseFloat(isNumElements[i].value)
	 if ( isNaN(floatValue)) {
			if( lan_id == 0)
				alert("请输入数值!");
			else
				alert("Please input a number.");
		
		isNumElements[i].focus();
		return false;
	 }
	}
	return ret;
}


function validatelanv( obj, lan_id){
	  theform = obj;
	  if ( checklanv( lan_id) == true) {
	  	//theform.submit();
		return true;
	  }else{
	  	return false;
	  }
}

function loadPage(cid, pageid, skins, lans){
	document.location.href = "?id=" + cid + "&page=" + pageid + "&skin=" + skins + "&lan=" + lans;
}



function showlayer( li, rcls) { //v2.0
	for (i = 0; i <=rcls; i++){
		if( i==li){
			c2_layer[i].style.display='inline';
			//document.getElementById("c2_layer").style.display = "inline";
		}
		else{
			c2_layer[i].style.display='none';
		}
	}

  return true;
}

function doreset(){
 setTimeout( 'document.forml.reset();',2000); 
}


function nTabs( n, divid) {
	var dividn = eval( divid);
	for( i=0; i < dividn.length; i++ ) {
		dividn[i].style.display='none';
	}
	dividn[n].style.display='block';
}

function resetborder( facade_imgl, n) {
	var facade_imgln = eval( facade_imgl);
	for( i=0; i < facade_imgln.length; i++ ) {
		facade_imgln[i].style.border='none';
	}
	facade_imgln[n].style.border='1px solid #333333';
  return true;
}

