﻿// JavaScript Document
String.prototype.Trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");}
String.prototype.isMobile = function(){return (/^(?:13\d|18\d|15[89])-?\d{5}(\d{3}|\*{3})$/.test(this.Trim()));}
String.prototype.isTel = function(){/*"兼容格式: 国家代码(2到3位)-区号(2到3位)-电话号码(7到8位)-分机号(3位)*/return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));}
String.prototype.isEmail = function(){return (/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(this.Trim()));}
function checkValue(controlName,checkType,minLen,maxLen,compareName){	/*controlName：控件名，checkType：检测类型，minLen：最小长度，maxLen：最大长度，compareName：比较控件名*/
	/*checkType:检测类型 -1-字符比较，0-长度，1-是否数字，2-是否邮件地址，3-是否电话*/
	var result,obj;
	result=false;
	obj=getObj(controlName);
	compareObj=getObj(compareName);
	if(!isNaN(checkType) && obj){
		if(isNaN(minLen))
			minLen=1;
		else
			minLen=parseInt(minLen);
		if(isNaN(maxLen))
			maxLen=999999;
		else
			maxLen=parseInt(maxLen);
		switch(parseInt(checkType)){
			case -1:if(obj.value.Trim()==compareObj.value.Trim()){result=true;}
				break;
			case 1:if(!isNaN(obj.value.Trim())){result=true;}
				break;
			case 2:if(obj.value.Trim().isEmail()){result=true;}
				break;
			case 3:if(obj.value.Trim().isTel()){return true;}
				break;
			case 4:if(obj.value.Trim().isMobile()){return true;}
				break;
			default:if(obj.value.Trim().length>=minLen && obj.value.Trim().length<=maxLen){result=true;}
				break;
		}
	}
	return result;
}
function getObj(id){
	var obj;
	obj=document.getElementById(id);
	return obj;
}
function setFocus(obj){
	obj.focus();
	obj.select();
}
function showErrors(obj,strError){
	if(obj==null)
		alert(strError);
	else{
		if(obj)
			obj.innerHTML=strError;
		else
			alert(strError);
	}
}
function $(id){return document.getElementById(id);}
function showFlash(pic,href,text,w,h,text_h){
	 if(pic.indexOf("|")>-1)pic=pic.substring(0,pic.length-1);
	 if(href.indexOf("|")>-1)href=href.substring(0,href.length-1);
	 if(text.indexOf("|")>-1)text=text.substring(0,text.length-1);
	 var focus_width=w;
	 var focus_height=h;
	 var text_height=text_h;
	 var swf_height = focus_height+text_height ;
	 document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
	 document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="../images/flash.swf"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="bgcolor" value="#F0F0F0">');
	 document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
	 document.write('<param name="FlashVars" value="pics='+pic+'&links='+href+'&texts='+text+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
	 document.write('<embed src="../images/flash.swf" wmode="opaque" FlashVars="pics='+pic+'&links='+href+'&texts='+text+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	 document.write('</object>');
}
function leftMarquee(speed,id,id1,id2){
	if(document.getElementById(id2).offsetLeft-document.getElementById(id).scrollLeft<=0)
		document.getElementById(id).scrollLeft-=document.getElementById(id1).offsetWidth;
	else
		document.getElementById(id).scrollLeft=document.getElementById(id).scrollLeft+speed;
}
function myAddPanel(title,url,desc) 
{ 
	if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))
	//Gecko 
	{ 
		//window.sidebar.addPanel(title,url,desc); 
		try
		{
			window.sidebar.addPanel(title, url, desc);
		}
		catch (e)
		{
			alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	} 
	else
	//IE 
	{ 
		try
		{
			window.external.AddFavorite(url,title); 
		}
		catch (e)
		{
			alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	} 
} 
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);
			 }
	}
}