if(self!=top) top.location=self.location;



function axjaUrl(aType,aUrl,aData,aReturnId){
	$.ajax({type: aType,
	url: aUrl,
	dataType: "html",
	data: aData,
	success: function(result){
		/*alert(result);*/
		if(aReturnId) $("#"+aReturnId).html(result);
	}
	});
}


function showads(id,ShowId){
	$.ajax({type: "post",
	url: "../showad.php",
	dataType: "html",
	data: "id="+id,
	success: function(result){
		
		var ad_result = String($.trim(result));
		ad_result = ad_result.split('|+|');
		var ad_url = ad_result[0];
		var ad_height = ad_result[1];
		var ad_width = ad_result[2];
		$("#"+ShowId).html('<iframe src="'+ad_url+'" height="'+ad_height+'" width="'+ad_width+'" frameborder="0"  marginheight="0" marginwidth="0"  scrolling="No"></iframe>');
		/*alert(result);*/
	}
	});
}


function autoResize()
{
	try
	{
		document.all["classpage"].style.height=classpage.document.body.scrollHeight
	}
	catch(e){}
}

function UpImg(ShowUrl) {
	$.ajax({type: "post",
	url: "../require/upfile.php",
	dataType: "html",
	data: "",
	success: function(result){
		var r_str = String($.trim(result));
		$("#"+ShowUrl).html(r_str);
	}
	});

}

function addBookmark(title) {
	var url=parent.location.href;
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}





function subsearch(id) {
	id=id.substring(2,id.length);
	var subValue=document.getElementById(id).value;
	alert(subValue);
	document.getElementById('subiframe').src="/user/subsearch.php?subvalue="+subValue;
}



function refreshimg(){
	document.all.imgcheckcode.src='/require/chk_num.php';
}


function getUserLogin(obj){
	$("#"+obj).load('/'+obj+'.php');
}



function showadv() {
	if(document.register.advshow.checked == true) {
		document.getElementById("reg2").style.display = "";
	} else {
		document.getElementById("reg2").style.display = "none";
	}
}

function search_form(){
	document.search.submit();
}

function onMouseDiv(images,id){
	var showImages = document.getElementById("show_images_"+id);
	showImages.innerHTML = '' ;
}



function searchM(valueM,Mid){
	var showM = document.getElementById(Mid);
	if (valueM == 2){
		search_type_td.style.display = "none";
		search_area_td.style.display = "block";
		searchM2.style.display = "block";
		searchM1.style.display = "none";

	}else{
		search_type_td.style.display = "block";
		search_area_td.style.display = "none";
		searchM2.style.display = "none";
		searchM1.style.display = "block";
	}
}




function bitTotal(num){
	modes=0;
	for (i=0;i<3;i++){
		if (num & 1) modes++;
		num>>>=1;
	}
	return modes;
}

function CharMode(iN){
	if (iN>=65 && iN <=90) //大寫字母
	return 2;
	if (iN>=97 && iN <=122) //小寫
	return 4;
	else
	return 1; //數字
}

function checkStrong(sPW){
	Modes=0;
	for (i=0;i<sPW.length;i++){
		Modes|=CharMode(sPW.charCodeAt(i));
	}
	var btotal = bitTotal(Modes);
	if (sPW.length >= 10) btotal++;
	switch(btotal) {
		case 1:
		return "<table width='130' class='pswstrong'><tr><td bgcolor='#FE707E'><strong>弱</strong></td><td><span style='color:#666;'>中</span></td><td><span style='color:#666;'>強</span></td></tr></table>";
		break;
		case 2:
		return "<table width='130' class='pswstrong'><tr><td bgcolor='#FCFA93'><span style='color:#666;'>弱</span></td><td bgcolor='#FCFA93'><strong>中</strong></td><td><span style='color:#666;'>強</span></td></tr></table>";
		break;
		case 3:
		return "<table width='130' class='pswstrong'><tr><td bgcolor='#BDFEA6'><span style='color:#666;'>弱</span></td><td bgcolor='#BDFEA6'><span style='color:#666;'>中</span></td><td bgcolor='#BDFEA6'><strong>強</strong></td></tr></table>";
		break;
		default:
		return "<font color='#33CC00'>強</font>";
	}
}
function ShowStrong(obj,oMsg,status){
	var obj = oo(obj);
	if(status==1){
		obj.innerHTML = oMsg
	}else{
		obj.innerHTML = ""
	}
}

function copyToClipBoard(){
	var clipBoardContent="";
	clipBoardContent+=this.location.href;
	window.clipboardData.setData("Text",clipBoardContent);
	alert("本页网址复制成功");
}

function showhidediv(id){
	try {
		var panel=document.getElementById(id);
		if(panel){
			if(panel.style.display=='none'){
				panel.style.display='block';
			}else{
				panel.style.display='none';
			}
		}
	}catch(e){}
}





//表单验证代码

function  contain(str,charset)//  字符串包含测试函数
{
	var  i;
	for(i=0;i<charset.length;i++)
	if(str.indexOf(charset.charAt(i))>=0)
	return  true;
	return  false;
}
function  CheckForm()
{
	if  ((contain(document.form.NAME.value,  "%\(\)><"))  ||  (contain

	(document.form.MESSAGE.value,  "%\(\)><")))
	{
		alert("输入了非法字符");
		document.form.NAME.focus();
		return  false;
	}
	return  true;
}

function IsNumber(str)///////只有数字
{
	var number_chars = "1234567890";
	var i;
	for (i=0;i<str.length;i++)
	{
		if (number_chars.indexOf(str.charAt(i))==-1) return false;
	}
	return true;
}

//表单验证代码over

//验证是否大于30
function checkNum_s()
{
	var num = document.getElementById('e_time').value;

	if(num)
	{
		if(num >30)
		{
			document.getElementById('f_e_time').style.display="";
			document.getElementById('f_e_time').className="chDivError";
			document.getElementById('e_time').value="30";
			document.getElementById('f_e_time').innerText="有效时间不能超过30天";
		}
		else
		{
			document.getElementById('f_e_time').style.display="none";
			document.getElementById('f_e_time').className="chDivOk";
		}
	}
	else
	{
		document.getElementById('e_time').value="30";
	}
}



function ImgAuto(i){//你必须给图片提前设定初始宽度和高度，建议直接就是最大宽度和高度
	var MaxW=190; //定义图片显示的最大宽度
	var MaxH=150; //定义图片显示的最大高度
	var o=new Image();
	o.src=i.src;
	var w=o.width;
	var h=o.height;
	var t;
	if (w>MaxW){
		t=MaxW;
	}else{
		t=w;
	}
	if ((h*t/w)>MaxH){
		i.height=MaxH;i.width=MaxH/h*w;
	}else{
		i.width=t;i.height=t/w*h;
	}
}



function CheckAll(id)
{
	var myform=document.getElementById(id);
	var checkBoxs=myform.getElementsByTagName("input");
	for(i=0;i<checkBoxs.length;i++)
	{
		if(checkBoxs[i].type=="checkbox")
		{
			checkBoxs[i].checked=true;
		}
	}

}

function CheckOther(id)
{
	//取消全选的选中状态
	var myform=document.getElementById(id);
	var checkBoxs=myform.getElementsByTagName("input");
	for(i=0;i<checkBoxs.length;i++)
	{
		if(checkBoxs[i].type=="checkbox")
		{
			if(checkBoxs[i].checked)
			{
				checkBoxs[i].checked=false;
			}
			else
			{
				checkBoxs[i].checked=true;
			}
		}
	}

}

