﻿//分页
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 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";
	}
}


function showpic(ob,obwidth,obheight)
{
if (typeof window.pageYOffset != 'undefined') {
	   scrollPos = window.pageYOffset;
		}
		else if (typeof document.compatMode != 'undefined' &&
					 document.compatMode != 'BackCompat') {
		   scrollPos = document.documentElement.scrollTop;
		}
		else if (typeof document.body != 'undefined') {
				   scrollPos = document.body.scrollTop;
		}
	scrollPos=scrollPos+150
var allbox=document.getElementById("allbox")
if(allbox!==null)
{
	document.body.removeChild(allbox)
}
var screenwidth=(document.body.scrollWidth)
var newlayer=document.createElement("div")
newlayer.style.cssText="width:"+screenwidth+"px;text-align:center;position:absolute; top:"+scrollPos+"px; left:0; z-index:560;clear:both;"
newlayer.setAttribute("id","allbox")

var ahref=document.createElement("a")
ahref.setAttribute("href","#")
ahref.style.cssText="border:none;"

var pic=document.createElement("img")
pic.setAttribute("src",ob)
pic.style.cssText="width:"+obwidth+"px;height:"+obheight+"px; padding:3px;background:#fff; margin:0 auto;"
pic.onclick=function()
{
document.body.removeChild(newlayer)
return false;
}

var pic_box=document.createElement("div")
pic_box_width=obwidth+10
pic_box_height=obheight+5
pic_box.style.cssText="width:"+pic_box_width+"px;height:"+pic_box_height+"px; margin:0 auto;"
ahref.appendChild(pic)
pic_box.appendChild(ahref)
newlayer.appendChild(pic_box)
document.body.appendChild(newlayer)

}


function Show_aBlkBlackTab(aBlkBlackTabid_num,aBlkBlackTabnum){
	for(var i=0;i<6;i++){document.getElementById("aBlkBlackTabcontent_"+aBlkBlackTabid_num+i).style.display="none";}
	for(var i=0;i<6;i++){document.getElementById("aBlkBlackTabmenu_"+aBlkBlackTabid_num+i).className="bgoff";}
	document.getElementById("aBlkBlackTabmenu_"+aBlkBlackTabid_num+aBlkBlackTabnum).className="bgon";
	document.getElementById("aBlkBlackTabcontent_"+aBlkBlackTabid_num+aBlkBlackTabnum).style.display="block";
}	

