﻿

	function PBYJTP()
	{
		var clickmessage="请通过“下载到电脑”下载！";

		function disableclick(e) {
		if (document.all) {
		if (event.button==2||event.button==3) {
		if (event.srcElement.tagName=="IMG"){
		alert(clickmessage);
		return false;
		}
		}
		}
		else if (document.layers) {
		if (e.which == 3) {
		alert(clickmessage);
		return false;
		}
		}
		else if (document.getElementById){
		if (e.which==3&&e.target.tagName=="IMG"){
		alert(clickmessage)
		return false
		}
		}
		}

		function associateimages(){
		for(i=0;i<document.images.length;i++)
		document.images.onmousedown=disableclick;
		}

		if (document.all||document.getElementById)
		document.onmousedown=disableclick
		else if (document.layers)
		associateimages();

	}	

	function HappyNiuYear()
	{
		//window.open('card.htm', 'newwindow', 'height=452, width=573, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
		if (parseInt(document.getElementById("cool_newyear").offsetHeight)<452)
		{
			document.getElementById("cool_newyear").style.height = parseInt(document.getElementById("cool_newyear").offsetHeight)+4+"px";
			setTimeout('HappyNiuYear()',10);
		}
		else
		{
			setTimeout('HappyNiuYearC()',5000);
		}

	}
	function HappyNiuYearC()
	{
		if (parseInt(document.getElementById("cool_newyear").offsetHeight)>8)
		{
			document.getElementById("cool_newyear").style.height = parseInt(document.getElementById("cool_newyear").offsetHeight)-8+"px";
			setTimeout('HappyNiuYearC()',10);
		}
		else
		{
			document.getElementById("cool_newyear").style.height = 0+"px";
		}

	}
	function AddFirend(Name,Url,Title,Type,Logo,Root)
	{
		if (document.getElementById(Name).value.trim()=="")
		{
			alert("网站名称不能为空！");
			document.getElementById(Name).focus();
			return;
		}
		
		if (document.getElementById(Url).value.trim()==""||document.getElementById(Url).value.trim()=="http://")
		{
			alert("网站地址不能为空！");
			document.getElementById(Name).focus();
			return;
		}
		
		var myRequestt = new ajaxRequest();
		myRequestt.url = Root+"JSCPU.aspx?Type=AddFirends&Name="+URLEncode(document.getElementById(Name).value.trim())+"&Url="+URLEncode(document.getElementById(Url).value.trim())+"&Title="+URLEncode(document.getElementById(Title).value.trim())+"&TypeList="+URLEncode(document.getElementById(Type).value.trim())+"&Logo="+URLEncode(document.getElementById(Logo).value.trim());
		myRequestt.send();
		alert("信息提交成功，我们将尽快审核！");
		document.getElementById(Name).value = "";
		document.getElementById(Url).value = "http://";
		document.getElementById(Title).value = "";
		document.getElementById(Logo).value = "";
		
	}
	
	function SearchRangs(Type,Name)
	{
		if (document.getElementById(Name).value.trim()=="")
		{
			alert("请输入您要搜索的手机铃声！");
			document.getElementById(Mes).focus();
			return
		}
		location.href="/RangsSearch.aspx?"+document.getElementById(Type).value+"="+URLEncode(document.getElementById(Name).value);
	}

	function DownLine(Type,File)
	{
		this.location.href=Type+File;
	}

	function DownLine(Type,File)
	{
		this.location.href=Type+File;
	}
	
	function AddFavorite(sURL, sTitle)
    {
        try
        {
            window.external.addFavorite(sURL, sTitle);
        }
        catch (e)
        {
            try
            {
                window.sidebar.addPanel(sTitle, sURL, "");
            }
            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);
			}
        }
    }
    
	function SendRes(SendMes)
	{
		var mWidth=520; 
		var mHeight=390;
		var mTop=(window.screen.height-mHeight)/2;
		var mLeft=(window.screen.width-mWidth)/2;
		window.open(SendMes,"","height=371,width=549,status=yes,toolbar=no,menubar=no,location=no"); 
	}
	
	function LookRes(Root,Table,ID)
	{
		var myRequest = new ajaxRequest();
		myRequest.url = Root+"JSCPU.aspx?Type=LookRes&Table="+Table+"&ID="+ID;
		myRequest.send();
	}
	
	function DownRes(Root,Table,ID)
	{
		var myRequest = new ajaxRequest();
		myRequest.url = Root+"JSCPU.aspx?Type=DownRes&Table="+Table+"&ID="+ID;
		myRequest.send();
	}

	function SendComment(Root,Table,Mes,Name,ID)
	{
		var cookieVal=getCookie("coolComments"+"-"+Table+"-"+ID);
		if (cookieVal!=undefined)
		{
			alert("发表失败，对不起您已发表过评论！");
			return false;			
		}
		if (!CheckVal(document.getElementById(Mes), "", "评语不能为空！", true))
			return;
			
		if (document.getElementById(Mes).value.length>255)
		{
			alert("评语超出系统规定的255字，请适当删减！");
			return false;			
		}
		
		var myRequest = new ajaxRequest();
		myRequest.url = Root+"JSCPU.aspx?Type=PostComments&Table="+Table+"&ID="+ID+"&Mes="+URLEncode(document.getElementById(Mes).value)+"&Name="+URLEncode(document.getElementById(Name).value);
		myRequest.send();
		document.getElementById(Mes).value="";
		setCookie("coolComments"+"-"+Table+"-"+ID,"True",1);
		alert("感谢您的宝贵评论！");
	}
	function SearchRes(Mes,Brand,Type,Open,OtherMes)
	{
		if (document.getElementById(Mes).value=="型号|名称")
		{
			alert("请输入您要搜索的手机资源！");
			document.getElementById(Mes).focus();
			return
		}
		if (document.getElementById(Mes).value.trim()=="")
		{
			alert("请输入您要搜索的手机资源！");
			document.getElementById(Mes).focus();
			return
		}
		if (document.getElementById(Type).value=="请选择")
		{
			alert("请输入您要搜索的资源类型！");
			document.getElementById(Type).focus();
			return;
		}
		
		var TTMes = document.getElementById(Mes).value.split("|");
		var TModel = "";
		var TMes="";
		if (TTMes.length>1)
		{
			if (TTMes[0]!="型号")
				TModel = "&Model="+URLEncode(TTMes[0]);
			if (TTMes[1]!="名称"&&TTMes[1]!="")
				TMes = "KeyWord="+URLEncode(TTMes[1]);
		}
		else
		{
			TMes = "KeyWordATModel="+URLEncode(TTMes[0]);
		}
			
		var TBrand = document.getElementById(Brand).value;
		var TType = document.getElementById(Type).value;
		var TOTM = document.getElementById(OtherMes).value.split("*");
		var TRoot = TOTM[1];
		var TOtherMes = TOTM[0].split(",");
		var GoMes = "";
		for (i=0; i<TOtherMes.length; i++)
		{
			var TOtherMesList = TOtherMes[i].split("|");
			if (TOtherMesList[0]==TType)
			{
				if ((TOtherMesList[1]=="WallPaperSearch") || (TOtherMesList[1]=="RangsSearch") || (TOtherMesList[1]=="FictionSearch") || (TOtherMesList[1]=="ArticleSearch")) 
				{
					GoMes = TMes;
				}
				else
				{
					if (document.getElementById(Brand).value=="请选择")
					{
						alert("请选择您要搜索的手机品牌！");
						document.getElementById(Brand).focus();
						return;
					}
					GoMes = TMes+"&Brand="+URLEncode(TBrand)+TModel;
				}
				
				if (Open=="blank")
				{ 
					window.open(TRoot+TOtherMesList[1]+".aspx?"+GoMes);
				}
				else
				{
					location.href=TRoot+TOtherMesList[1]+".aspx?"+GoMes;
				}
				return;
			}
		}
	}

	function TryListen(Path,spanobj)
	{
		if (document.getElementById(spanobj).innerText == "停止：")
		{
			document.all.coolx8Listen.src = "";
			document.getElementById(spanobj).innerText = "试听：";
		}
		else
		{
			document.all.coolx8Listen.src = "http://www.phbell.com"+Path;
			document.getElementById(spanobj).innerText = "停止：";
		}
	}
		
	function SelHot(SelBut,OtherBut,SelMes,OtherMes)
	{
		document.getElementById(SelMes).style.display = "block";
		
		var ValSelMes = OtherMes.split(",");
		for (i=0; i<ValSelMes.length; i++)
		{
			document.getElementById(ValSelMes[i]).style.display = "none";
			
		}
		
		document.getElementById(SelBut).className = "coolAImg02";
		var ValSelBut = OtherBut.split(",");
		for (i=0; i<ValSelBut.length; i++)
		{
			document.getElementById(ValSelBut[i]).className = "coolAImg01";
		}
	}
	function SelHot1(SelBut,OtherBut,SelMes,OtherMes)
	{
		document.getElementById(SelMes).style.display = "block";
		document.getElementById(SelMes+"_AMore").style.display = "block";
		var ValSelMes = OtherMes.split(",");
		for (i=0; i<ValSelMes.length; i++)
		{
			if (document.getElementById(ValSelMes[i])!=null)
				document.getElementById(ValSelMes[i]).style.display = "none";
			if (document.getElementById(ValSelMes[i]+"_AMore")!=null)
				document.getElementById(ValSelMes[i]+"_AMore").style.display = "none";
		}
		
		document.getElementById(SelBut).className = "coolAImg02";
		var ValSelBut = OtherBut.split(",");
		for (i=0; i<ValSelBut.length; i++)
		{
			if (document.getElementById(ValSelBut[i])!=null)
				document.getElementById(ValSelBut[i]).className = "coolAImg01";
		}
	}
	function CheckVal(TObj,Mes,alMes,IsSet)
	{
		if (TObj.value==Mes)
		{
			if (IsSet)
				TObj.focus();
			alert(alMes);
			return false;			
		}
		return true;
	}
	
	function CheckValRex(TObj,Mes,alMes,IsSet)
	{
		var filter=Mes;	
		if (!filter.test(TObj.value))
		{
			alert(alMes);
			if (IsSet)
				TObj.focus();
			return false;							
		}
		return true;
	}
	
	function CheckValUpLoad(TObj,Mes,alMes)
	{
		if (TObj.value!="")
		{
			var PicMes = TObj.value.toLowerCase();
			var TempVal = Mes.toLowerCase().split(",");
			for (i=0; i<TempVal.length; i++)
			{
				if (PicMes.indexOf(TempVal[i])>=0)
					return true;
			}
			alert(alMes);
			return false;
		}
		else
			return true;
	}
	
	function CheckValUpLoadF(TObj,Mes,alMes)
	{
		if (TObj.value!="")
		{
			var PicMes = TObj.value.toLowerCase();
			var TempVal = Mes.toLowerCase().split(",");
			for (i=0; i<TempVal.length; i++)
			{
				if (PicMes.indexOf(TempVal[i])>=0)
				{
					alert(alMes);
					return false;
				}
			}
			return true;
		}
		else
			return true;
	}
	
	function PicChange(TObj,TObjBut,TempPic,Value,TWidth,THeight)
	{
		if(TempPic.length <= 0)
		{
			TempPic = TObj.src;
			TObjBut.disabled = null;
		}

		if(Value.length > 0)
		{
			TObj.src=Value;
		}
		TObj.width=TWidth;
		TObj.height=THeight;
	}

	function ResetPic(TObj,TObjUpLoad,TempPic,PicSrc)
	{
		TObjUpLoad.select();
		document.execCommand('Delete');
		if(TempPic.length > 0)
			TObj.src=TempPic;
		else
			TObj.src=PicSrc;
	}
	
	function CheckKey() 
	{ 
		return ((event.keyCode >= 48) && (event.keyCode <= 57)); 
	}
	
	function LoadMoveFlash(TPics,TPlinks,TTexts)
	{
		var focus_width=236
		var focus_height=320
		var text_height=20
		var swf_height = focus_height+text_height

		var pics=TPics;;
		var plinks=TPlinks;
		var texts=TTexts;

		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="js/pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value="red">');
		document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
		document.write('<param name="FlashVars" value="pics='+pics+'&links='+plinks+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
		document.write('<embed src="js/pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+plinks+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="LightGrey" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
	}
	
	function URLEncode(strInput)
	{
		strTmp = encodeURI(strInput);
		strTmp = strTmp.replace(/\ /g, '+');
		strTmp = strTmp.replace(/\@/g, '%40');
		strTmp = strTmp.replace(/\#/g, '%23');
		strTmp = strTmp.replace(/\$/g, '%24');
		strTmp = strTmp.replace(/\&/g, '%26');
		strTmp = strTmp.replace(/\+/g, '%2B');
		strTmp = strTmp.replace(/\=/g, '%3D');
		strTmp = strTmp.replace(/\;/g, '%3B');
		strTmp = strTmp.replace(/\:/g, '%3A');
		strTmp = strTmp.replace(/\//g, '%2F');
		strTmp = strTmp.replace(/\?/g, '%3F');
		strTmp = strTmp.replace(/\,/g, '%2C');
		return strTmp;
	}
	
	function setCaret(textObj)
	{   
		if (textObj.createTextRange)
		{   
			textObj.caretPos   =   document.selection.createRange().duplicate();   
		}   
	}   
	function insertAtCaret(textObj, textFeildValue)   
	{   
		if(document.all)
		{     
			if (textObj.createTextRange && textObj.caretPos)   
			{   
				var caretPos = textObj.caretPos;   
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?textFeildValue + ' ':textFeildValue;   
			}
			else
			{   
				textObj.value = textFeildValue;   
			}   
		}
		else
		{   
			if(textObj.setSelectionRange)
			{   
				var rangeStart = textObj.selectionStart;   
				var rangeEnd = textObj.selectionEnd;   
				var tempStr1 = textObj.value.substring(0,rangeStart);   
				var tempStr2 = textObj.value.substring(rangeEnd);   
				textObj.value = tempStr1 + textFeildValue + tempStr2;   
			}
			else
			{   
				alert("This   version   of   Mozilla   based   browser   does   not   support   setSelectionRange");   
			}   
		}   
	}  


	// 获取对象
	function $(id) {
		return document.getElementById(id);
	}
	// 绑定事件
	function AttachEvent() {
		var obj = arguments[0];
		if( isIE() ) {
			if( obj==null ) {
				window.attachEvent(arguments[1], arguments[2]);
			}
			else {
				obj.attachEvent(arguments[1], arguments[2]);
			}
		}
		else {
			if( obj==null ) {
				window.addEventListener(arguments[1].substring(2), arguments[2], arguments[3]);
			}
			else {
				obj.addEventListener(arguments[1].substring(2), arguments[2], arguments[3]);
			}
		}
	}
	// 清除字符左右空白符
	String.prototype.trim= function() {
		return this.replace(/(^\s*)|(\s*$)/g, ""); 
	}
	// 全角转半角
	String.prototype.half = function() {
		var i;
		var result = '';
		for (i = 0; i < this.length; i++) {
			code = this.charCodeAt(i);
			if (code >= 65281 && code < 65373) {
				result += String.fromCharCode(this.charCodeAt(i) - 65248);
			}
			else {
				result += this.charAt(i);
			}
		}
		return result;
	}
	// 是否IE浏览器
	function isIE() {
		if(navigator.appName.indexOf("Explorer") > -1){//ie		
			return true;
		} 
		else{//for ff		
			return false;
		}
	}
	// 通用AJAX请求类
	function ajaxRequest() {
		var xmlObj = false;	
		var CBfunc,ObjSelf;	
		ObjSelf=this;	
		try { xmlObj=new XMLHttpRequest; }
		catch(e) {
			try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
			catch(e2) {
				try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
				catch(e3) { xmlObj=false; }
			}
		}	
		if (!xmlObj) return false;	
		this.method="GET";	
		this.url;	
		this.async="true";	
		this.content="";	
		this.callback=function(cbobj) {return;}	
		this.send=function() {	
			if(!this.method||!this.url) return false;		
			xmlObj.open (this.method, this.url, this.async);		
			if(this.method=="POST") xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
			xmlObj.onreadystatechange=function() {		
				if(xmlObj.readyState==4) {			
					if(xmlObj.status==200) {				
						ObjSelf.callback(xmlObj);					
					}
				}
			}		
			if(this.method=="POST") xmlObj.send(this.content);		
			else xmlObj.send(null);
		}
	}
	// 数组操作属性
	Array.prototype.insertAt = function(index, value) {
		var begin = this.slice(0, index);
		var end = this.slice(index);
		begin.push(value);
		return begin.concat(end);
	}
	Array.prototype.removeAt = function(index) {
		var begin = this.slice(0, index);
		var end = this.slice(index);
		begin.pop();
		return begin.concat(end);
	}
	//设置cookie
	function setCookie(name, value, expr)
	{
		try{
    		var argv = setCookie.arguments;
			var argc = setCookie.arguments.length;
			var expires = (argc > 2) ? argv[2] : null;
			if(expires!=null)
			{
				var LargeExpDate = new Date ();
				LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));
			}
     		document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString()));
     		return true;
		}
		catch(e){
			return false;
		}
	}
	//读取cookie
	function getCookie(Name)
	{
		var search = Name + "="
		if(document.cookie.length > 0) 
		{
			offset = document.cookie.indexOf(search)
			if(offset != -1) 
			{
				offset += search.length
				end = document.cookie.indexOf(";", offset)
				if(end == -1) end = document.cookie.length
				{
					return unescape(document.cookie.substring(offset, end))
				}
			}
			else
			{
				return;
			}
		}
	}
	
	function getXMLR()
	{ 
		var xmlhttp,alerted; 
		try 
		{ 
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP") 
		} 
		catch (e) 
		{ 
			try 
			{ 
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP") 
			} 
			catch (E) 
			{ 
				alert("请安装Microsofts XML parsers") 
			} 
		} 
		if (!xmlhttp && !alerted) 
		{ 
			try 
			{ 
				xmlhttp = new XMLHttpRequest(); 
			} 
			catch (e) 
			{ 
				alert("你的浏览器不支持XMLHttpRequest对象，请升级"); 
			} 
		} 
		return xmlhttp; 
	} 
