String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,"")} 
var pop=null;

function showalert(str,swidth,sheight)
{
	swidth    = swidth || '340';
	sheight   = sheight || '80';
	pop=new Popup({ contentType:4,isReloadOnClose:false,width:swidth,height:sheight});
	pop.setContent("title","信息提示:");
	pop.setContent("alertCon",str);
	pop.build();
	pop.show();
}
function showiframe(url,title,swidth,sheight)
{
	swidth    = swidth || '700';
	sheight   = sheight || '420';
	title     = title || '修改操作:';
	pop=new Popup({ contentType:1,isReloadOnClose:false,width:swidth,height:sheight});
	pop.setContent("contentUrl",url);
	pop.setContent("title",title);
	pop.build();
	pop.show();
}
function showhtml(str,title,swidth,sheight)
{
	swidth    = swidth || '340';
	sheight   = sheight || '120';
	title     = title || '管理操作:';
	var strHtml = "<table border=0 style='width:90%; text-align:center;'><tr style='height:40px'><td>"+str+"</td></tr></table>";
	var pop=new Popup({ contentType:2,isReloadOnClose:false,width:swidth,height:sheight});
	pop.setContent("contentHtml",strHtml);
	pop.setContent("title",title);
	pop.build();
	pop.show();
}
function popclose()
{
	pop.close();
}
function showaction(form,title,disbutton,swidth,sheight)
{
	swidth    = swidth || '340';
	sheight   = sheight || '80';
	disbutton = disbutton || 'btsub';
	title     = title || '信息提示:';
	form      = form || 'form';

	pop=new Popup({ contentType:1,isReloadOnClose:false,width:swidth,height:sheight});
	pop.setContent("title",title);
	pop.setContent("someDisabledBtn",disbutton);
	pop.build();
	G(form).target=pop.iframeIdName;
	pop.show();

}
function loading()
{
	if(typeof(document.frames[pop.iframeIdName])=='object')
	{
		document.frames[pop.iframeIdName].document.body.innerHTML='<div style="font-size: 14px;">正在请求中请勿关闭。。。</div>';
	}
}
function locationto(url)
{
	url = url|| 'http://post.cnfol.com'
	window.location.href=url;
}
function getutf8strlen(str)
{
	str = str.trim();
	return   parseInt(str.replace(/[^\x00-\xff]/g,"**").length);
} 


function setCookie(name, value) 
{
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime() + 24*60*60*1000);
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString();
}

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 ("");
		}
	} else {
		return ("");
	}
}
function pagegoto(url)
{
	page=document.getElementById('inputpage').value;
	var parten = /[0-9]/; 
	if(parten.exec(page)){ 
		window.location.href=url+page+'.html';
	}else{ 
		showalert("您输入的页码错误!"); 
	}
}
function getradiovalue(field)
{ 
    if (field && field.length)
	{ 
        for (var i = 0; i < field.length; i++)
		{ 
            if (field[i].checked){  
                return field[i].value;
            } 
        } 
    }
	else
	{ 
        return '';     
    } 
}
function isnumeric(a)
{
	var parten = /[0-9]/; 
	if(parten.exec(a)){ 
		return false;
	}
	return true;
}
function selectall(form,name,check)
{
	if(typeof(check)=='undefined')
	{
		check = true;
	}
	else
	{
		check = false;
	}
	var e = document.getElementById(form).elements[name];
	if(typeof(e)!='undefined')
	{

		if(undefined == e.length)
		{
			e.checked=check;
		}
		else
		{
			for(i = 0; i < e.length; i ++)
			{
				e[i].checked = check;
			}
		}
	}
}
function selectcheck(form,name,idvalue)
{
	var e = document.getElementById(form).elements[name];
	if(typeof(e)!='undefined')
	{

		if(undefined == e.length)
		{
			e.checked=false;
			if(e.value==idvalue)
			{
				e.checked = true;
			}
		}
		else
		{
			for(i = 0; i < e.length; i ++)
			{
				e[i].checked = false;
				if(e[i].value==idvalue)
				{
					e[i].checked = true;
				}
			}
		}
	}
}
function checkselect(form,name)
{
	var e = document.getElementById(form).elements[name];
	if(typeof(e)!='undefined')
	{

		if(e&&e.length>0)
		{
			for(i = 0; i < e.length; i ++)
			{
				if(e[i].checked==true)
				{
					return true;
				}
			}
			showalert('请选择您要执行操作的记录！');
			return false;
		}else if(e.checked!=true)
		{
			showalert('请选择您要执行操作的记录！');
			return false;
		}else
		{
			return true;
		}
	}
}
function divinnermod(id,inner,others)
{
	this.id = id;		
	this.inner = inner;	
	this.others = others;
}

function setdivinner(a)
{
	a = a||divinner;
	var mods;
	if(a && a.length>0)
	{
		for(var i=0; i<divinner.length; i++)
		{
			mods = divinner[i];
            if(document.getElementById(mods.id))
			document.getElementById(mods.id).innerHTML = mods.inner;
			
		}
	}
	
}
function loadingjs(file)
{
	var votecomplate = '';
	var scriptTag = document.getElementById('loadingjs');
	var head = document.getElementsByTagName('head').item(0)
	if(scriptTag)
	{
		head.removeChild(scriptTag);
	}
	script = document.createElement('script');
	script.src = file;
	script.type = 'text/javascript';
	script.id = 'loadingjs';
	head.appendChild(script);
	checkload(votecomplate);

}
function checkload(ready)
{
	var timeid = '';
	if(!ready)
	{
		clearTimeout(timeid);
		timeid = setTimeout("checkload();", 100);
	}
	else
	{
		clearTimeout(timeid);
	}
	
}

function checkspecialchar(va)
{

	 var iu, iuu, regArray=new Array("#","%","&","*","?","/"); 

	 iuu=regArray.length;

	 for(iu=0;iu<=iuu;iu++)
	 {

		if (va.indexOf(regArray[iu])!=-1)
		{
			   return true;
		}

	 }

	return false;              

}
function setHomePage(rul)
{
	if (document.all)
	{
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(rul);

	}
	else if(navigator.userAgent.indexOf("Firefox")>0)
	{
			try
			{ 
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
			    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
			    prefs.setCharPref('browser.startup.homepage',rul);
				showalert("恭喜您设置首页成功！");
			} 
			catch (e) 
			{ 
				showalert( "操作被您的浏览器拒绝,如果想启用该功能,请在地址栏内输入about:config,然后将项 signed.applets.codebase_principal_support 值设为true",450,50); 
			}

	  }

}

function funajaxupdate(url,div,par)
{    
	 par = ''||par;
     var myAjax = new Ajax.Request(url,{method:'get',parameters:par,onComplete:updatediv(div)});   
}
function updatediv(div)
{
	return function(httpRequest){
		$(div).innerHTML=httpRequest.responseText;
	}; 
}
function makesmallpic(obj,w,h)
{
	var srcImage = new Image();
	srcImage.src=obj.src;
	var srcW=srcImage.width;		
	var srcH=srcImage.height;

	if (srcW==0)
	{
		obj.src=srcImage.src;
		srcImage.src=obj.src;
		var srcW=srcImage.width;		
		var srcH=srcImage.height;
	}
	if (srcH==0)
	{
		obj.src=srcImage.src;
		srcImage.src=obj.src;
		var srcW=srcImage.width;		
		var srcH=srcImage.height;
	}

	if(srcW>srcH){
		if(srcW>w){
			obj.width=newW=w;
			obj.height=newH=(w/srcW)*srcH;
		}else{
			obj.width=newW=srcW;
			obj.height=newH=srcH;
		}
	}else{
		if(srcH>h){
			obj.height=newH=h;
			obj.width=newW=(h/srcH)*srcW;
		}else{
			obj.width=newW=srcW;
			obj.height=newH=srcH;
		}
	}
	if(newW>w){
		obj.width=w;
		obj.height=newH*(w/newW);
	}else if(newH>h){
		obj.height=h;
		obj.width=newW*(h/newH);
	}
}
