// 网站策划设计：陈伟明
// www.ViMing.cn  www.ViMing.net
// yuzhoufeiyu@163.com
// QQ:151479058

document.write("<script src=\"webinc/config.js\" type=\"text/javascript\"></script>");

//*********************  是否IE  *********************
var isie = 1;
if(window.navigator.appVersion.indexOf("MSIE")<0){
	isie = 0;
}else{
	isie = 1;
}

//*********************  是否IE7.0  *********************
var isie7 = 0;
if(window.navigator.appName=="Microsoft Internet Explorer" && window.navigator.appVersion.substring(window.navigator.appVersion.indexOf("MSIE")+5, window.navigator.appVersion.indexOf("MSIE")+8)==7.0){
	isie7 = 1;
}else{
	isie7 = 0;
}

//*********************  产品展示鼠标指上换边框色  *********************
function newBg(obj) {
	var div = obj.parentElement.parentElement;
	//div.style.backgroundColor = "#ff6600";
	div.style.borderColor = "#ff6600";
}
function oldBg(obj) {
	var div = obj.parentElement.parentElement;
	//div.style.backgroundColor = "";
	div.style.borderColor = "#719BED";
}

//*********************  导航菜单  *********************
function check(obj, num) {
	obj.src = "images/menu_"+ num +"_move.gif";
}
function nocheck(obj, num) {
	obj.src = "images/menu_"+ num +".gif";
}

function checkEn(obj, num) {
	obj.src = "images/menu_en_"+ num +"_move.gif";
}
function nocheckEn(obj, num) {
	obj.src = "images/menu_en_"+ num +".gif";
}

//*********************  确认对话框  *********************
function reCon(text){
	if(confirm(text))
		return true;
	else
		return false;
}

//*********************  后台左栏点击换小图片  *********************
function menu_show(i,img){
	var menu = document.getElementById(i).style;
	var imgo = document.getElementById(img);
	if (menu.display == "none" || menu.display == ""){
		menu.display = "block";
		imgo.src ="images/close.gif";
	}else{
		menu.display = "none";
		imgo.src ="images/open.gif";
	}
}

//*********************  隐藏显示左栏  *********************
function showleft(){
	if(ttt==2){
		ttt=1;
		frameshow.src="images/p_2.gif";
		frameshow.alt="显示左栏";
		window.parent.left_show.cols="0,*";
	}else{
		ttt=2;
		frameshow.src="images/p_1.gif";
		frameshow.alt="隐藏左栏";
		window.parent.left_show.cols="186,*";
	}
}

//*********************  鼠标移上换背景颜色  *********************
function setHover(row){row.className = "listhover";}
function setNormal(row){row.className = "listItem";}

//*********************  复选框全选  *********************
function CheckAll(form){
	for(var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if(e.name != 'chkall') e.checked = form.chkall.checked;
	}
}

//*********************  限制字符个数  *********************
function textLimitCheck(thisArea,maxLength){
	if(thisArea.value.length > maxLength){
		alert(maxLength + ' 个字限制. \r超出的将自动去除.');
		thisArea.value = thisArea.value.substring(0, maxLength);
		thisArea.focus();
	}
    /*回写span的值，当前填写文字的数量*/
	count.innerText = thisArea.value.length;
}

//函数名：chkeMmail
//功能介绍：检查是否为Email Address
//参数说明：要检查的字符串
//返回值：0：不是  1：是
function chkeMmail(a){
	var i=a.length;
	var temp = a.indexOf('@');
	var tempd = a.indexOf('.');
	if ( a.length>6 || a.length<255 ){
		if (temp > 1){
			if ((i-temp) > 3){
				if ((i-tempd) > 2){
					return 1;
				}
			}
		}
		return 0;
	}
	return 0;
}

//函数名：isNumberString
//功能介绍：检查是否含有指定字符
//参数说明：InString：要检查的字符串　RefString：指定字符串
//返回值：0：不是  1：是
function isNumberString(InString,RefString){
	if(InString.length==0) return (false);
	for (Count=0; Count < InString.length; Count++){
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)  
			return (false);
	}
	return (true);
}

//*********************  图片自动缩放  *********************
function DrawImage(ImgD,width,height){
	var image = new Image();
	image.src = ImgD.src;
	var ww = width;   //图片最大宽度
	var wh = height;  //图片最大高度
	var ow = image.width;
	var oh = image.height;
	var nw = ow;
	var nh = oh;
	if(ow>0 && oh>0){
		if(ow >= ww){
			nw = ww;
			nh = oh*ww/ow;
			if(nh >= wh){
				nw = nw*wh/nh;
				nh = wh;
			}
		}else if(oh >= wh){
			nw = ow*wh/oh;
			nh = wh;
			if(nw >= ww){
				nw = ww;
				nh = nh*ww/nw;
			}
		}else{
			nw = ow;
			nh = oh;
		}
	}
	ImgD.width  = nw;
	ImgD.height = nh;
}

//*********************  上传产品预览图片开始  *********************
function showImg(w,h,ext){
	if(isie==1){
		var img = document.addform.imginput.value;
		var imgext = img.substr(img.lastIndexOf(".")+1).toLowerCase();
		var extok = ext.split(",");
		var returnValue = false;
		for(key in extok){
			if(imgext==extok[key]){
				returnValue = true;
				break;
			}
		}
		if(returnValue==false){
			alert("请选择指定的图片类型。");
			document.addform.imginput.value = "";
		}else{
			if(isie7==1){
				document.getElementById("showImgDiv").innerHTML = "<div style=\"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img+"', sizingMethod='scale'); width:"+ w +"px; height:"+ h +"px\" title='图片预览'></div>";
			}else{
				document.getElementById("showImgDiv").innerHTML = "<img src='"+img+"' width="+ w +" height="+ h +" alt='图片预览' />";
			}
			document.getElementById("showImgDiv").style.display = "block";
			document.getElementById("DelImgBtn").style.display = "block";
		}
	}else{
		document.getElementById("showImgDiv").innerHTML = "<br /><br />您未使用IE浏览器<br />无法显示预览图片";
		document.getElementById("showImgDiv").style.display = "block";
		document.getElementById("DelImgBtn").style.display = "none";
	}
}

function clearImg(){
	document.getElementById("imgInputDiv").innerHTML = imgInputDivInnerHTML;
	document.getElementById("showImgDiv").innerHTML = "&nbsp;";
	document.getElementById("showImgDiv").style.display = "none";
	document.getElementById("DelImgBtn").style.display = "none";
}

function delImg(){
	var img = addform.imgfile.value;
	if(img){
		if(confirm("确定要删除本张图片吗？")){
			window.parent.tempFrame.location.href = "delimg.asp?imgpath="+img;
			clearImg();
			document.addform.imgfile.value = "";
			document.getElementById("delimg").onclick = function(){clearImg()};
			return true;
		}else{
			return false;
		}
	}else{
		document.getElementById("delimg").onclick = function(){clearImg()};
	}	
}

//*********************  全屏/返回  *********************
function fullwindow(pagename,type){
	parent.noClose = 1;
	parent.isUnload = 1;
	if(type==1){
		newwindow = window.open("index.asp?full=yes&win="+pagename,"_blank","channelmode=yes,scrollbars=yes,resizable=yes,toolbar=no,location=no,status=no");
	}
	if(type==0){
		newwindow = window.open("index.asp?win="+pagename,"_blank","scrollbars=yes,resizable=yes,toolbar=yes,location=yes,status=yes,menubar=yes");
	}
	top.close();
}

//*********************  JS Flash  *********************
function getFlashObject(flashSrc, objWidth, objHeight, etcParam) {
	var tag = "";
	var baseFlashDir = "";
	flashSrc = baseFlashDir+flashSrc;
	if (etcParam!="" || etcParam!=null) {
		if (etcParam.substr(0, 1)=="?")
			flashSrc += etcParam;
		else
			flashSrc += "?"+etcParam;
	}
	tag += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
	tag += "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" ";
	tag += "width=\"" + objWidth + "\" height=\"" + objHeight + "\">";
	tag += "<param name=\"movie\" value=\"" + flashSrc + "\" />";
	tag += "<param name=\"quality\" value=\"high\" />";
	tag += "<param name=\"wmode\" value=\"transparent\" />";
	tag += "<param name=\"menu\" value=\"false\" />";
	tag += "<embed src=\"" + flashSrc + "\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" ";
	tag += "type=\"application/x-shockwave-flash\" width=\"" + objWidth + "\" height=\"" + objHeight + "\" ";
	tag += "quality=\"high\" wmode=\"transparent\" menu=\"false\"></embed>";
	tag += "</object>";
	document.write(tag);
}

//*********************  右键菜单  *********************
function pagemenucn() {
	var menuTitle  = webname+"|→ 首 页|→ 公司简介|→ 产品展示|→ 联系我们|→ 在线留言|网站制作：鹏飞网络科技";  // 标题
	var menuLink   = "|./|indexb.asp|chanpin.asp|lianxib.asp|liuyanb.asp|http://www.pfwl.net/";  // 链接
	var menuTarget = "0|0|0|0|0|0|1";  // 是否新建窗口
	var bottomLine = "1|0|0|0|0|1|0";  // 是否有底线
	var titleWidth = 190;  // 右键菜单宽度
	pagemenuView(menuTitle, menuLink, menuTarget, bottomLine, titleWidth);
}

function pagemenuen() {
	var menuTitle  = webname2+"|→ Homepage|→ Company|→ Products|→ Feedback|→ Contact Us|→ 中文版";  // 标题
	var menuLink   = "|enindex.asp|encompany.asp|enproducts.asp|enfeedback.asp|enlink.asp|./";  // 链接
	var menuTarget = "0|0|0|0|0|0|1";  // 是否新建窗口
	var bottomLine = "1|0|0|0|0|0|0";  // 是否有底线
	var titleWidth = 270;  // 右键菜单宽度
	pagemenuView(menuTitle, menuLink, menuTarget, bottomLine, titleWidth);
}

function pagemenuView(menuTitle, menuLink, menuTarget, bottomLine, titleWidth) {
	var menuTitleArr  = menuTitle.split("|");
	var menuLinkArr   = menuLink.split("|");
	var menuTargetArr = menuTarget.split("|");
	var bottomLineArr = bottomLine.split("|");
	
	var pageContextMenuStyle = "";
	pageContextMenuStyle += "<style type=\"text/css\">";
	pageContextMenuStyle += "#pageContextMenu{width:"+ titleWidth +"px; position:absolute; z-index:99; border-top:1px #F1EFE2 solid; border-left:1px #F1EFE2 solid; border-right:1px #716F64 solid; border-bottom:1px #716F64 solid; background:#ffffff}";
	pageContextMenuStyle += "#pageContextMenuDiv{border-top:1px #FFFFFF solid; border-left:1px #FFFFFF solid; border-right:1px #ACA899 solid; border-bottom:1px #ACA899 solid}";
	pageContextMenuStyle += "#pageContextMenuUl{margin:0; padding:1px; list-style:none; border:1px #ECE9D8 solid}";
	pageContextMenuStyle += "#pageContextMenuUl li{padding:3px 16px; color:#000000; text-align:left; line-height:13px; font-size:12px; cursor:default}";
	pageContextMenuStyle += "#pageContextMenuUl #bottomLine{padding:0; height:3px; line-height:1px; font-size:1px}";
	pageContextMenuStyle += "</style>";
	document.write(pageContextMenuStyle);
	
	var menutext = "";
	menutext += "<div id='pageContextMenu' style='display:none' onblur='hidMenutext()'><div id='pageContextMenuDiv'><ul id='pageContextMenuUl'>";
	for (var i=0; i<menuTitleArr.length; i++) {
		menutext += "<li onmouseover='newmenubg(this)' onmouseout='oldmenubg(this)' onclick=\"gourl('"+ menuLinkArr[i] +"',"+ menuTargetArr[i] +")\">"+ menuTitleArr[i] +"</li>";
		
		if (bottomLineArr[i]==1) {
			menutext += "<li id='bottomLine' style='border-bottom:1px #ACA899 solid'></li>";
			menutext += "<li id='bottomLine'></li>";
		}
	}
	menutext += "</ul></div></div>";
	document.write(menutext);
	
	document.body.oncontextmenu = document.getElementsByTagName("html")[0].oncontextmenu = function(event) {
		if (isie==0) {
			alert("欢迎光临！");
		} else {
			var showMenutext = document.getElementById("pageContextMenu");
			if (showMenutext.style.display=="none") {
				event = event || window.event;
				var htmlBody = document.getElementsByTagName("body")[0];  // 使用 !DOCTYPE 声明时用html，反之用body
				var w = htmlBody.getAttribute("clientWidth");
				var h = htmlBody.getAttribute("clientHeight");
				var l = htmlBody.getAttribute("scrollLeft");
				var t = htmlBody.getAttribute("scrollTop");
				var cx = event.clientX;
				var cy = event.clientY;
				var divW = showMenutext.getAttribute("clientWidth");
				var divH = showMenutext.getAttribute("clientHeight");
				var st, sl;
				
				if (w-cx>divW) {
					sl = l+cx;
				} else {
					sl = l+cx-divW;
				}
				if (h-cy>divH) {
					st = t+cy;
				} else {
					st = t+cy-divH;
				}
				
				with (showMenutext) {
					style.left    = sl + "px";
					style.top     = st + "px";
					style.display = "block";
					focus();
				}
			}
		}
		return false;
	};
	
	hidMenutext = function() {
		document.getElementById("pageContextMenu").style.display = "none";
	};
	
	newmenubg = function(obj) {
		obj.style.backgroundColor = "#3A4057";
		obj.style.color = "#FFFFFF";
	};
	
	oldmenubg = function(obj) {
		obj.style.backgroundColor = "#FFFFFF";
		obj.style.color = "#000000";
	};
	
	gourl = function(url,target) {
		if (url!="") {
			if (target==1) {
				window.open(url);
			} else {
				self.location.href = url;
			}
		}
	};
}
