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 toCustomPage(eventObj, currNo, totalNo,baseUrl){
	var pageNo = $($(eventObj).prev().find("input")[0]).val();
	if(
		!isNaN(pageNo) 
		&& pageNo!=currNo
		&& parseInt(pageNo)<=totalNo
		&& parseInt(pageNo)>=1
	 ) {
	 	//if(baseUrl) window.location=baseUrl+'&page.pageNo='+pageNo;
	 	//else jumpPage(pageNo);

	 	if(baseUrl){
	 		if(baseUrl.indexOf('?')<0) window.location=baseUrl+'-'+pageNo+".html";
	 		else  window.location=baseUrl+'&page.pageNo='+pageNo;
	 	}
	 	else jumpPage(pageNo);
	 }
	else{
		alert("输入的页号不能为非数字／当前页号／大于总页数");
	}
}

function _$(oname){
 	return (document.getElementById(oname));
}

try {
	document.execCommand('BackgroundImageCache', false, true);
}
catch(e) {}



function nowTime(){
	return new Date().getTime();
}


function colse(){
	window.opener=null;
	window.open("","_self");
	window.close(); 
}


function initImg(iptObj){
	if($(iptObj).attr("title")==''){
		return;
	}
	else{
		var imgSpan = $(iptObj).next()[0];
		$(iptObj).attr("title","");
		changeImg(imgSpan);
		$(imgSpan).show();
	}
}

function changeImg(imgSpan,type){
	if(!type || type==1){
    	$(imgSpan).html('<img onclick="changeImg(this.parentNode)" style="cursor: pointer;" width="65" height="20" src="/vcode.jpg?t=' + nowTime() + '" align="absmiddle" alt="点击换图" />');
	}
	else{
	    $(imgSpan).html(
	    	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="65" height="19" align="absmiddle">'
			+ '<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="vcode?t=' + rand + '" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" />'
			+ '<embed src="/vcode?t=' + nowTime() + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="65" height="19" align="absmiddle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'
	    ); 
	}
}   


function resetLoginImg(inputId,imgId){
    changeImg($(imgId)); 
	$("#l_userPass").val('');
	$("#_l_loginVCode").val('');
}

  
function checkVCode(vCodeId){
	var vcobj = document.getElementById(vCodeId);
	if(vcobj){
		var code = vcobj.value;
		if(code==''){
			alert("请输入验证码");
	        vcobj.focus();
			return false;
		}
		if(code.length != 4){
			alert("验证码不正确");
	        vcobj.focus();
			return false;
		}
		$.ajax({
			type:"post",   
			url:"vcodecheck",   
			data:"vc="+code+"&t="+nowTime(),
			success:function(msg){
	        	if(msg){
	        		alert(msg);
	        		vcobj.focus();
	        		return false;
	        	}
	        	return true;
	        }
		});
	}
	return false;
}   

function toRegister(returnPage){
	if(!returnPage) returnPage=window.location.href; 
	window.location.href="/register!input?returnPage="+returnPage; 
}
function elogin(returnPage){
	if(!returnPage) returnPage=window.location.href; 
	window.location.href="/elogin?returnPage="+returnPage; 
}
function forget(){
	window.location.href="/forget";
}

function login(){
	var userEmail = $("#l_userEmail").val();
	var userPass  = $("#l_userPass").val();
	var vc = $("#l_loginVCode").val();
	if(userEmail==''){
		alert("请输入登录邮箱！");
		$("#l_userEmail").focus();
		return false;
	}
	if(isEmail(userEmail)){
		alert("邮箱格式不正确！");
		$("#l_userEmail").focus();
		return false;
	}
	if(userPass==''){
		alert("请输入密码！");
		$("#l_userPass").focus();
		return false;
	}
	if(vc==''){
		alert("请输入验证码！");
		$("#l_loginVCode").focus();
		return false;
	}
	
	$.post("/login",
	 	{'email':userEmail,'password':userPass,'returnPage':location.href,'vc':vc,'t':nowTime(),'jsLogin':'true'},
	 	function(data){
	 		if(data){
	 			eval(data);
	 		}
	 	}
	);
}

function isEmail(email){
	var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/; 
	return !reg.test(email);   
}

function cboxAll(ck,name){
	var o = document.getElementsByName(name);
	if(o)for(var i=0,l=o.length;i<l;i++) o[i].checked=ck;
}

function cboxValues(name){
	var a = new Array();
	var o = document.getElementsByName(name);
	if(o)for(var i=0,l=o.length;i<l;i++) if(o[i].checked) a.push(o[i].value);
	return a;
}

function getCookie(cname)　　
{　　
	var cookieString = new String(document.cookie);
	var cookieHeader = cname+"=";
	var beginPosition = cookieString.indexOf(cookieHeader);
	if (beginPosition > -1){
		cookieString = cookieString.substring(beginPosition + cookieHeader.length);
		var endPosition = cookieString.indexOf(";");
		if(endPosition > -1) {
			cookieString = cookieString.substring(0,endPosition);
		}
		return cookieString.replace(/\"/g,'');
	}
	return "";
}

$().ready(function() {
	if($("#l_userEmail"))
		$("#l_userEmail").val(getCookie("EasyRunUserEmail"));
	/**if($("#searchbox")){
		var ss = $("#searchbox .sselect");
		ss.mouseover(function() {
			$(this).removeClass('sselect_');
		});
		ss.mouseout(function() {
			$(this).addClass('sselect_');
		});
		ss.click(function() {
			showSearchType();
		});
		ss = $("#searchbox .ssearch");
		ss.mouseover(function() {
			$(this).removeClass('ssearch_');
		});
		ss.mouseout(function() {
			$(this).addClass('ssearch_');
		});
		$("#searchbox .sinput input").click(function() {
			showSearchType();
		});
	}*/
	//if(document.getElementById("menu") && document.getElementById("main")){
	//	document.getElementById("menu").style.height=document.getElementById("content").scrollHeight+"px";
	//	document.getElementById("main").style.height=document.getElementById("content").scrollHeight+"px";
	//}
});
function checkPhone(yphone){
	if(yphone.length<7) return false;
	return (
		(/(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(yphone))
		|| (/^13\d{9}$/g.test(yphone))
		||(/^15\d{9}$/g.test(yphone))
		||(/^18\d{9}$/g.test(yphone))
	)
}

function showSearchType(){
	$('#jGlide_001').slideDown(150);
	var txt = $("#searchbox .sinput input");
	if(txt.val()=='如:创业之旅'){
		txt.val('');
	}
	txt.style.color='#333';
}

function jGM_Shwo(txt){
	if(txt){
		//if(!$(jGlideMenu).displayToggle)
			$(this).jGlideMenuToggle();	
	}
	else{
		$(this).jGlideMenuToggle();	
	}
}

function jGM_All(){
	var obj = arguments[0];
	var isChecked = $(obj).attr("checked");
	var arglen = arguments.length;
	if(arglen>1){
		var id = arguments[1];
		//源板块设置
		$("#tile_0"+id+" input").each(function(){
			if(isChecked) $(this).attr("checked",true);
			else  $(this).removeAttr("checked");
		});
		if(arglen>2){
			//当前板块设置
			$($("#jGlide_001 .jGM_content").get(1)).find("input").each(function(){
				if(isChecked) $(this).attr("checked",true);
				else  $(this).removeAttr("checked");
			});
			$("#jGlide_001 input[name='jc"+id+"']").each(function(){
				if(isChecked) $(this).attr("checked",true);
				else  $(this).removeAttr("checked");
			});
		}
	}
	else{
		$("#jGlide_001 input").each(function(){
			if(isChecked) $(this).attr("checked",true);
			else  $(this).removeAttr("checked");
		});
		//当前开户板块设置
		$("#jGlide_001 .jGM_content").each(function(){
			$(this).find("input").each(function(){
				if(isChecked) $(this).attr("checked",true);
				else  $(this).removeAttr("checked");
			});
		});
	}
	//alert($("#jGlide_001").html());
}

function jGM_Value(){
	
}
