﻿// JavaScript Document
function tab (mod,cursor,n){
	for(i=1;i<=n;i++){
		var nav=document.getElementById(mod+i);
		var cont=document.getElementById(mod+"_"+"cont"+i);
		nav.className=(i==cursor)?"current":"";
		cont.style.display=(i==cursor)?"block":"none";
	}
}

function setTab(/*string*/name,/*int*/ itemCnt,/*int*/ curItem, /**/classHide, /**/classShow)
{
	 for(i=1;i<=itemCnt;i++)
	{
		eval("document.getElementById('tab_" + name + "_" + i + "').className='" + classHide + "'");
	} 
	eval("document.getElementById('tab_" + name + "_" + curItem + "').className='" + classShow + "'");
 
 for(i=1;i<=itemCnt;i++)
 {
  eval("ele_hide = document.getElementById('con_" + name + "_" + i +"')");
  if(ele_hide) ele_hide.style.display = "none";
 }
 eval("ele_play = document.getElementById('con_" + name + "_" + curItem + "')");
 if(ele_play) ele_play.style.display = "block";
}

function SetHome(obj,url){
	try{
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(url);
	}catch(e){
		if(window.netscape){
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch(e){
				alert("抱歉，此操作被浏览器拒绝！\n\n请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'");
			}
		}else{
			alert("抱歉，您所使用的浏览器无法完成此操作。\n\n您需要手动将 "+url+" 设置为首页。");
		}
	}
}

function AddFavorite(url,title){
    if (document.all){
		window.external.addFavorite(url,title);
	}else if (window.sidebar){
		window.sidebar.addPanel(title, url, "");
    }
}

function CloseWin(){
	var browserName=navigator.appName; 
	if (browserName=="Netscape") {
		window.open('','_parent','');
		window.close(); 
	} else if (
		browserName=="Microsoft Internet Explorer") {
		window.opener = "whocares"; window.close();
	}
}

function doZoom(size){
	document.getElementById('content').style.fontSize=size+'px'
}



//改变图片大小
function resizepic(thispic)
{
if(thispic.width>700){thispic.height=thispic.height*700/thispic.width;thispic.width=700;} 
}
//无级缩放图片大小
function bbimg(o)
{
  var zoom=parseInt(o.style.zoom, 10)||100;
  zoom+=event.wheelDelta/12;
  if (zoom>0) o.style.zoom=zoom+'%';
  return false;
}

function test_email(strInput){
	var myEdit = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if(myEdit.test(strInput)) return true;
	return false;
}
function test_num(strInput){
var myEdit = /^[\d]{1,11}$/;
if(myEdit.test(strInput)) return true;
return false;
}

function test_mobile(strInput){
var myEdit = /^((\(\d{3}\))|(\d{3}\-))?13\d{9}|15[89]\d{8}$/;
if(myEdit.test(strInput)) return true;
return false;
}

function test_tel(strInput){
var myEdit = /^([0-9]{2,4}\-)?([0-9]{2,3}\-)?([2-9][0-9]{6,8})+(\-[0-9]{1,4})?$/;
if(myEdit.test(strInput)) return true;
return false;
}

function onMsg(){
	var theForm = document.forms['myform'];	
	if(theForm.title.value==''){
		alert('姓名不能为空!'); 
		theForm.title.focus();
		return false;
	}
	if(theForm.tel.value==''){
		alert('电话不能为空!'); 
		theForm.tel.focus();
		return false;
	}
	if(theForm.mail.value==''){
		alert('邮箱不能为空!'); 
		theForm.mail.focus();
		return false;
	}
	if(!test_email(theForm.mail.value)){
		alert('请填写正确的邮箱地址!'); 
		theForm.mail.focus();
		return false;
	}
	if(theForm.content.value==''){
		alert('内容不能为空!'); 
		theForm.content.focus();
		return false;
	}
	if(theForm.content.value.length>500){
		alert('评论内容超出字符限制！最长允许500个字符。'); 
		theForm.content.focus();
		return false;
	}
	if(theForm.verifycode.value==''){
		alert('验证码不能为空!'); 
		theForm.verifycode.focus();
		return false;
	}
	return true;
}



