//提交表单
var submit_form=function(str){
	var objform=document.getElementById(str);
	var ckf=Validator.Validate(objform,3);
	if(ckf){
		objform.submit();
	}
};
function submit_form_to(obj,url){
	$('#'+obj).attr("action",url);
	$('#'+obj).submit();
}
//加入email组 
var join_email=function(){
	var email=$("#email").val();
	if(test_email(email)!=false){
		window.location.href="index.php?_m=sub_email&email="+email;
	}else{
		alert("邮箱格式不正确，请重新输入");
		$("#email").val("");
		$("#email").focus();
	}
}
//验证email
var test_email=function(str)
{
   //对电子邮件的验证
   var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
   if(!myreg.test(str))
   {
		return false;
   }
}

function con_win() {
	var checkdel = window.confirm("确定要继续吗？");
	if (checkdel == false){
	   return false;
	}else {
	   return true;	
	}
}
function gotowhere(url){
	window.location.href=url;
}
var goback=function(url){
	var frompage=document.referrer;
	//alert(frompage);
	if (url==="frompage"){
		window.location.href=frompage;
	}else if(url!==""){
		window.location.href=url;
	}else{
		history.go(-1);
	}
};
//全选脚本
function sel_all(obj_1,obj_2)
{
	var Ck=document.getElementsByName(obj_1);
	var CkNum=Ck.length;
	var Ck_2=document.getElementById(obj_2);
 
	for(var i=0;i<CkNum;i++)
	{
		Ck[i].checked=(Ck_2.checked)?true:false;
	}
}
//选项框功能
function tag_show(id){
	//alert($('#tag_'+id).attr('class'));
	for(i=0;i<10;i++){
		if($('#tag_'+i)=='undefined'){return;}
		if(i==id){
			$('#tag_'+i).addClass('on');
			$('#con_'+i).show();
		}else{
			$('#tag_'+i).removeClass();	
			$('#con_'+i).hide();
		}
	}
}
//js输出flash
//调用方法：<script>LoadFlash('url','transparent',803,225)</ script>
function LoadFlash(url,wmode,width,Height)
{ 
var flashcode = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id=scriptmain name=scriptmain codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+Height+'">\
<param name="movie" value="'+url+'">\
<param name="quality" value="high">\
<param name=scale value=noscale>\
<param name="LOOP" value="false">\
<param name="menu" value="false">\
<param name="wmode" value="'+wmode+'">\
<embed src="'+url+'" width="'+width+'" height="'+Height+'" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" salign="T" name="scriptmain" menu="false" wmode="'+wmode+'"></embed></object>';
document.write (flashcode); 
} 

//图片自适应
function DrawImage(ImgD,WidthNum,HeightNum){ 
var image=new Image(); 
image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		flag=true; 
		if(image.width/image.height>= WidthNum/HeightNum){ 
			if(image.width>WidthNum){ 
				ImgD.width=WidthNum; 
				ImgD.height=(image.height*WidthNum)/image.width; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
	
		}else{ 
			if(image.height>HeightNum){ 
				ImgD.height=HeightNum; 
				ImgD.width=(image.width*HeightNum)/image.height; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
			
		} 
	} 
} 

