/*检测合法日期格式*/
function check_date(str){  
	var dateReg = /^(\d{4})-([0-9]{1,2})-([0-9]{1,2})$/;  
    if(str=="") return false;  
    if(!dateReg.test(str)){ // && RegExp.$2<=12 && RegExp.$3<=31    
		return false;  
    }
    return true;  
}

/*检测合法邮箱格式*/
function check_email(str){  
	var emailReg=/^([a-zA-Z0-9_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    if(str=="") return false;  
    if(!emailReg.test(str)){
		return false;
    }
    return true;  
}

/*检测合法OICQ格式*/
function check_oicq(str){
	if(str=="") return false; 
	if((isNaN(parseInt(str))) || str.length<=4 || str.length>=12){
		return false;
	}
	return true;
}

function check_all(ck) {
	if ($(ck).attr('checked')) {
		$("form :input[name='id[]']").each(function() {
			$(this).attr('checked','checked');
			$(this).parent().parent().addClass('highlight');
		});
	} else {
		$("form :input[name='id[]']").each(function() {
			$(this).removeAttr('checked');
			$(this).parent().parent().removeClass('highlight');
		});
	}
}

function check_all2(ck) {
	if ($(ck).attr('checked')) {
		$("form :input[id='id']").each(function() {
			$(this).attr('checked','checked');
			$(this).parent().parent().addClass('highlight');
		});
	} else {
		$("form :input[id='id']").each(function() {
			$(this).removeAttr('checked');
			$(this).parent().parent().removeClass('highlight');
		});
	}
}

function show_tip(msg) {
	var html = '<span id="show_tip"><div>'+msg+'</div></span>';
	$('body').append(html);
	setTimeout("$('#show_tip').remove();",3000);
}

function do_submit(ac,form) {
	$('#do').val(ac);
	form.submit();
}

//parent.document.title=document.title; 
//parent.window.location.hash = window.location.hash;
//parent.window.location.hash="aaaa";
//alert(main.src);
//if(window.location.href.indexOf("shou3-ye4-geng1-xin1.htm")==-1){ 
	
//} 


//图片按比例缩放
function DrawImage(ImgD,iwidth,iheight){
	//参数(图片,允许的宽度,允许的高度)
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		if(image.width/image.height>= iwidth/iheight){
			if(image.width>iwidth){ 
				ImgD.width=iwidth;
				ImgD.height=(image.height*iwidth)/image.width;
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
			//ImgD.alt=image.width+"×"+image.height;
		}
		else{
			if(image.height>iheight){ 
				ImgD.height=iheight;
				ImgD.width=(image.width*iheight)/image.height; 
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
			//ImgD.alt=image.width+"×"+image.height;
		}
	}
} 

//重设maomaobj位置 {原理:参照底部背景图片高度来定位}
function ResetMaomaoBJ(obj){
	var objTop = $(obj).offset().top;
	$("#maomaobj").css("top",objTop-13);
	$("#maomaobj").css("left",1080);
	$("#maomaobj").show();
}		


//解决frame应用中地址栏不变的问题
(function()
{
	if(top != self)
	{
		var sURL = location.href.replace('&dj%5Fmenu0=%5Btype+Function%5D&%E5%8F%B3%E9%94%AE%E8%8F%9C%E5%8D%95=%5Bobject+Object%5D', '');
		sURL = sURL.replace(/http\:\/\/www\.maomaobj\.com\//gi, '');

		top.document.title = document.title;
		top.location.href = 'http://www.maomaobj.com/site.html#' + sURL;
	}
})()

window.onload = function(){
	for(var i = 0; i < document.links.length; i++)
	{
		if(document.links[i].href.indexOf('#') != -1) document.links[i].href = document.links[i].href.replace(/#/gi, '');
	}
	
	//右下角maomaobj定位
	ResetMaomaoBJ($("#bottombg"));
}