﻿//分页
function setPage(s, i)
{
	return s.replace('{p}', i.toString());
}

function ongoto(url,maxpage)
{
	
	var page = document.getElementById("gotopage").value;
	//alert(maxpage+page);
	if (isNaN(page) || page<1)
	{
		page = "1";
	}
	else if (Number(page)>Number(maxpage))
	{
		page=maxpage;
	}
	location.href = setPage(url, page);
}

//图片按比例缩放
//调用：<img src="图片" onload="javascript:DrawImage(this,100,100)">
var imgflag=false;
function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    imgflag=true;
	
	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.style.width=image.width; 
		ImgD.style.height=image.height; 
		//ImgD.style.padding=""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"; 
		//ImgD.style.margin-top=(200-image.height)/2; 
        }
        //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.style.width=image.width;
		ImgD.style.height=image.height;
		//ImgD.style.padding=""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"; 
		//alert(""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"); 
        }
        //ImgD.alt=image.width+"×"+image.height;
        }
    }
} 


function DrawImage2(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    imgflag=true;
	
	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.style.width=image.width; 
		ImgD.style.height=image.height; 
		//ImgD.style.padding=""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"; 
		//ImgD.style.margin-top=(200-image.height)/2; 
        }
        //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.style.width=image.width;
		ImgD.style.height=image.height;
		//ImgD.style.padding=""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"; 
		//alert(""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"); 
        }
        //ImgD.alt=image.width+"×"+image.height;
        }
    }
} 


function chkfeedback(){
	var Material=document.getElementById("Material")
	var Price=document.getElementById("Price")
	var Plan=document.getElementById("Plan")
	var Software=document.getElementById("Software")	
	var UserName=document.getElementById("UserName")
	var Phone=document.getElementById("Phone")
	var Email=document.getElementById("Email")
	var Content=document.getElementById("Content")
	
	if (Material.checked == false & Price.checked == false & Plan.checked == false) {
	alert("请选择需要的产品信息(单选或多选)");
	UserName.focus();
	return false;
}
if (UserName.value == undefined || UserName.value == "") {
	alert("用户名不能为空！");
	UserName.focus();
	return false;
}	
if (Phone.value == undefined || Phone.value == "") {
	alert("联系方式不能为空！");
	Phone.focus();
	return false;
}
if (Email.value == undefined || Email.value == "" || !str.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)) {
	alert("请正确输入Email地址！");
	Email.focus();
	return false;
}
if (Content.value == undefined || Content.value == "" || Content.value.length>600) {
	alert("内容不能为空,且应小于500个字！");
	Content.focus();
	return false;
}
return true;
}

function menuChange(obj,menu)
{
	if(menu.style.display=="none")
	{
		obj.setAttribute("style","");
		obj.src='images/img.jpg'
		//obj.onmouseover=function(){this.className='menu_title2';};
		//obj.onmouseout=function(){this.className='menu_title';};
		menu.style.display="";
	}else{
	obj.src='images/img1.jpg'
		obj.setAttribute("style","background-image:url(/admin_manage/images/admin_title_bg_hide.gif)");
		//obj.onmouseover=function(){this.className='menu_title';};
		//obj.onmouseout=function(){this.className='menu_title2';};
		menu.style.display="none";
	}
}

