// JavaScript Document


//加盟申请
function checkJoin()
{
	var temail = /^[a-zA-Z]([a-zA-Z0-9]*[-_.]?[a-zA-Z0-9]+)+@([\w-]+\.)+[a-zA-Z]{2,}$/;
	if(jQuery("#name").val()=='')
	{
		alert('请填写真实姓名。');
		jQuery("#name").focus();
		return false;
	}
	else if(jQuery("#tel").val()=='')
	{
		alert('请填写联系电话。');
		jQuery("#tel").focus();
		return false;
	}
	else if(!isTel(jQuery("#tel").val()))
	{
		alert('联系电话格式不正确。');
		jQuery("#tel").focus();
		return false;
	}
	else if(jQuery("#fax").val()=='')
	{
		alert('请填写传真。');
		jQuery("#fax").focus();
		return false;
	}
	else if(!isTel(jQuery("#fax").val()))
	{
		alert('传真格式不正确。');
		jQuery("#fax").focus();
		return false;
	}
	else if(jQuery("#email").val()=='')
	{
		alert('请填写邮件地址。');
		jQuery("#email").focus();
		return false;
	}
	else if(!temail.test("qq"+jQuery("#email").val()))
	{
		alert('Email格式不合法!');
		jQuery("#email").focus();
		return false;
	}
	else if(jQuery("#address").val()=='')
	{
		alert('请填写详细地址。');
		jQuery("#address").focus();
		return false;
	}
	else if(document.getElementById('address').value.length<12)
	{
		alert('详细地址字数不能少于12。');
		jQuery("#address").focus();
		return false;
	}
	else if(jQuery("#content").val()=='')
	{
		alert('请填写简短描述。');
		jQuery("#content").focus();
		return false;
	}
	else if(document.getElementById('content').value.length<20)
	{
		alert('简短描述字数不能少于20。');
		jQuery("#content").focus();
		return false;
	}
	else if(jQuery("#randcode").val()=='')
	{
		alert('请填写验证码。');
		jQuery("#randcode").focus();
		return false;
	}
}

function DrawImage(ImgD,FitWidth,FitHeight){ 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		if(image.width/image.height>= FitWidth/FitHeight){ 
			if(image.width>FitWidth){ 
				ImgD.width=FitWidth; 
				ImgD.height=(image.height*FitWidth)/image.width; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
		}else{ 
			if(image.height>FitHeight){ 
				ImgD.height=FitHeight; 
				ImgD.width=(image.width*FitHeight)/image.height; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height; 
			} 
		} 
	} 
}

function addfavorite() 
{ 
	if (document.all) 
	{ 
		window.external.addFavorite(location.href,'可乐网盟');
	} 
	else if (window.sidebar) 
	{ 
		window.sidebar.addPanel('可乐网盟',location.href,""); 
	} 
}

function homepage() 
{ 
	this.style.behavior='url(#default#homepage)';this.setHomePage(location.href); 
}


function isTel(s)
{
	var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
	if (!patrn.exec(s)) return false
	return true
}

function isPostalCode(s)
{
	var patrn=/^[0-9 ]{3,12}$/;
	if (!patrn.exec(s)) return false
	return true
}
