//加入以收藏夹
function bookmarkit() 
{
window.external.addFavorite(window.location,document.title);
//window.external.addFavorite('http://www.testgou.com/','东方评购网') 
} 
//图片按比例缩放
function proPicResize(img)
{
	if(img.src=="#"){return;}
	var w=img.getAttribute("w");
	var h=img.getAttribute("h");
	if (w==null||w==null)
	{
		w=img.offsetWidth;
		h=img.offsetHeight;
		img.setAttribute("w",w);
		img.setAttribute("h",h);
	}
	w=parseInt(w);
	h=parseInt(h);
	var image=new Image();
	image.src=img.src;
	
	var img_w=image.width;
	var img_h=image.height;
	if(img_w>0 && img_h>0)
	{
		if (img_w>w||img_h>h)
		{
			if(img_w/img_h>= w/h)
			{
				img.width=w;
				img.height=parseInt((img_h*w)/img_w);
			}
			else
			{
				img.width=parseInt((img_w*h)/img_h); 
				img.height=h;
			}
		}
		else
		{
			img.width=img_w; 
			img.height=img_h;
		}
	}
	else
	{
		//img.src="./images/Default/pro.gif";
		//img.alt="No Pic";
	}
}
//图片按比例缩放
function resize(img,w,h)
{
	if(img.src=="#"){return;}
	//var w=img.getAttribute("w");
	//var h=img.getAttribute("h");
	if (w==null||w==null)
	{
		w=img.offsetWidth;
		h=img.offsetHeight;
		img.setAttribute("w",w);
		img.setAttribute("h",h);
	}
	w=parseInt(w);
	h=parseInt(h);
	var image=new Image();
	image.src=img.src;	
	var img_w=image.width;
	var img_h=image.height;
	if(img_w>0 && img_h>0)
	{
		if (img_w>w||img_h>h)
		{
			if(img_w/img_h>= w/h)
			{
				img.width=w;
				img.height=parseInt((img_h*w)/img_w);
			}
			else
			{
				img.width=parseInt((img_w*h)/img_h); 
				img.height=h;
			}
		}
		else
		{
			img.width=img_w; 
			img.height=img_h;
		}
	}
	else
	{
		//return false;
		img.src="/images/Default/pro.gif";
		img.alt="No Pic";
	}
}
//window.onerror = function() {return true;};
//boboCall
function newshowtalk_old(UnionID,ProID,FromUrl){
	var talkWin;
        var sUrl;
        sUrl="/WebChatClient/chat_flash_talk.asp?fromUrl=TestGooChatTalking#TALK";
   	talkWin = window.open(sUrl,'TestGooFlashChatClient','width=700,height=555,toolbar=no,resizable=no,status=no,scrollbars=no,location=no,menu=0,titlebar=no,top=217,left=290');
	if(talkWin!=null){                
 		setTimeout(function(){talkWin.document.getElementById("testgooclientchat").focus();talkWin.document.getElementById("testgooclientchat").WindowFocus();talkWin.document.getElementById("testgooclientchat").viewProduct(ProID,FromUrl);},1000);
         }else{
		return talkWin;
	}

}
/*shopid 商家商城ID，以便商家客服进行分配*/
function newshowtalk(shopid,ProID,FromUrl){
	var talkWin;
	var sUrl;
	//sUrl="/Service/ChientChat/chatclient/chat_flash_talk.asp?fromUrl=TestGooChatTalking#TALK";
	sUrl="/WebChatClient/chat_flash_talk.asp?fromUrl=TestGooChatTalking#TALK";
	//sUrl="/Service/ChientChat/chatclient/chat_flash_talk.asp?shopid="+shopid+'&ProductID='+ProID+'&fromUrl='+FromUrl;
   	talkWin = window.open(sUrl,'TestGooFlashChatClient','width=700,height=555,toolbar=no,resizable=no,status=no,scrollbars=no,location=no,menu=0,titlebar=no,top=217,left=290');
	if(talkWin!=null){                
 		setTimeout(function(){talkWin.document.getElementById("testgooclientchat").focus();talkWin.document.getElementById("testgooclientchat").WindowFocus();talkWin.document.getElementById("testgooclientchat").viewProduct(ProID,FromUrl);},1000);
         }else{
		return talkWin;
	}

}
//加入收藏
function AddFavorite(URL, Title)
{
	if (window.sidebar)
	{	//FF
		window.sidebar.addPanel(Title,URL,"");
	}
	else if( document.all )
	{ //IE browser  
  	window.external.AddFavorite(url,title);   
  }
	else if( window.opera && window.print )
	{
		var mbm = document.createElement("a");
		mbm.setAttribute("rel","sidebar");
		mbm.setAttribute("href",URL);
		mbm.setAttribute("title",Title);
		mbm.click();
	}
	else
	{
		alert("此操作被浏览器拒绝！请使用Ctrl+D进行添加");
	}
	return false;
}
//设置为首页
function SetHomePage(obj,url)
{
	try
	{
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(url);
	}
	catch(e)
	{
		if(window.netscape)
		{
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
			} catch (e){ 
				alert("此操作被浏览器拒绝！请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'");
				location.href="about:config";
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',url);
		}
		else
		{
			alert("此操作被浏览器拒绝！");
		}
	}
	return false;
}
//返回
function goBack()
{
	history.go(-1);
}
//弹开窗口
function winopen(url,n,w,h)
{
	var t=(screen.availHeight-h)/2;
	if (h==0) t=-1000;
	var l=(screen.availWidth-w)/2;
	if (w==0) w=-1000;
	//window.open使用具有局限性，IE7无法取消地址栏，IE插件遮蔽弹出窗口
	var newwin=window.open(url,n,"top="+t+",left="+l+",width="+w+",height="+h+",toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
	if (!newwin) return;	//使用form弹出窗口或使用div虚拟窗口 省略
	if (h==0||w==0)
	{
		newwin.onload=function()
		{
			this.resizeTo(this.document.body.scrollWidth,this.document.body.scrollHeight+20);
			this.moveTo(parseInt((this.screen.availWidth-this.document.body.scrollWidth)/2),parseInt((this.screen.availHeight-this.document.body.scrollHeight)/2));
		}
	}
	newwin.focus();
	return newwin;
}
function UpFile(bk,oe,of,cmd)
{
	for (var i=0; i<document.forms.length; i++)
	{
		if (document.forms[i]==of)
		{
			of="forms["+i+"]";
			for (var ii=0; ii<document.forms[i].elements.length; ii++)
			{
				if (document.forms[i].elements[ii]==oe)
				{
					oe="elements["+ii+"]";
					break;
				}
			}
			break;
		}
	}
	winopen("UpFile.asp?Block="+bk+"&EditName="+oe+"&FormName="+of+"&Cmd="+cmd,"文件上传",400,40);
}
//与非门
function checkLab(bts,mas,obj)
{
	var ind=0;
	return;
	for (var i=0; i<bts.length; i++)
	{
		bts[i].className="";
	//	mas[i].className="";
		ind=(bts[i]==obj)?i:ind;
	}
	bts[ind].className="selected";
	//mas[ind].className="selected";
}
//A标签获得焦点虚线框处理
function a_load()
{
	var a=document.getElementsByTagName("a");
	var tempFunc;
	for (var i=0;i<a.length; i++)
	{
		tempFunc=a[i].onfocus;
		a[i].onfocus=function(){
		if (typeof (tempFunc) == "function"){
			try{
				tempFunc();
			} catch(e){}
		}
		this.blur();
		};
	}
}
//全部元素式样动作处理
function form_load()
{
	var form=document.forms;
	var obj;
	for (var i=0; i<form.length; i++)
	{
		obj=form[i].elements;
		for (var ii=0; ii<obj.length; ii++)
		{
			obj[ii].className=obj[ii].type;
			addEvent(obj[ii],"onfocus",function(){this.className=this.type+"Focus";});
			addEvent(obj[ii],"onblur",function(){this.className=this.type;});
			addEvent(obj[ii],"onmouseover",function(){this.className=this.type+"Focus";});
			addEvent(obj[ii],"onmouseout",function(){if (this!=document.activeElement) this.className=this.type;});
			addEvent(obj[ii],"onmouseout",function(evt){ evt=evt?evt:window.event; if (this!=(evt.srcElement || evt.target)) this.blur();});
		}
	}
}
//搜索表单动作
function search_load()
{
	var Search=document.getElementById("search");
	if (!Search) return;
	var SearchForms=Search.getElementsByTagName("form")[0];
	var keywords=SearchForms.keywords;
	addEvent(keywords,"onmouseover",function(){this.focus();});
	addEvent(keywords,"onmouseout",function(evt){ evt=evt?evt:window.event; if (this!=(evt.srcElement || evt.target)) this.blur();});
	addEvent(keywords,"onfocus",function(){if (this.value==this.defaultValue) this.value=""; this.select();});
	addEvent(keywords,"onblur",function(){if (this.value=="") this.value=this.defaultValue;});
	addEvent(SearchForms,"onsubmit",function(evt){if (this.keywords.value==this.keywords.defaultValue||IsNull(this.keywords.value)){alert("请输入搜索关键字"); this.keywords.focus(); this.keywords.value=""; stopEvent(evt);}});
}
//判断字符串是否为空字符串
function IsNull(str){
  var re=/^[　\s]*$/;
  return re.test(str);
} 
//左菜单动作
function leftMenu()
{
	var menu=document.getElementById("lefter");
	if (!menu) return;
	var menu=menu.getElementsByTagName("ol")[0];
	var url=location.href;
	if (url.substr(url.length-1,1)=="/") url+="Class.asp";
	url=url.toLowerCase();
	for (var i=0; i<menu.childNodes.length; i++)
	{
		if (menu.childNodes[i].nodeType != 3)	//兼容 FF/NS FF/NS认为换行为文本空节点
		{
			var menuHref=menu.childNodes[i].getElementsByTagName("a");
			//默认选择处理
			for (var ii=1; ii<menuHref.length; ii++)
			{
				if (url.indexOf(menuHref[ii].href.toLowerCase())!=-1)
				{
					menu.childNodes[i].getElementsByTagName("ol")[0].className="selected";
					menuHref[ii].className="selected";
				}
			}
			menuHref[0].onclick=function(evt)
			{
				var downMenu=this.parentNode.getElementsByTagName("ol");
				if (downMenu.length!=0)
				{
					downMenu[0].className=(downMenu[0].className=="")?"selected":"";
					stopEvent(evt);
				}
			}
		}
	}
}
//addEvent(window,"onload",leftMenu);
addEvent(window,"onload",a_load);
addEvent(window,"onload",form_load);
addEvent(window,"onload",search_load);
//拉条式样
if(window.ActiveXObject)
{
	document.writeln("<style type=\"text/css\" />");
	document.writeln("html,body { ");
	document.writeln("	scrollbar-face-color:  #ffffff; ");			///立体滚动条的颜色
	document.writeln("	SCROLLBAR-HIGHLIGHT-COLOR: #acacac; ");	//滚动条空白部分的颜色
	document.writeln("	SCROLLBAR-SHADOW-COLOR: #acacac; ");		//立体滚动条阴影的颜色
	document.writeln("	SCROLLBAR-3DLIGHT-COLOR: #ffffff; ");		//立体滚动条亮边的颜色
	document.writeln("	SCROLLBAR-ARROW-COLOR: black; ");				//三角箭头的颜色
	document.writeln("	SCROLLBAR-TRACK-COLOR: #f8f8f8;");			//立体滚动条背景颜色
	document.writeln("	scrollbar-darkshadow-color: #666666;");	//立体滚动条强阴影的颜色
	document.writeln("	scrollbar-base-color: #acacac;");				//滚动条的基本颜色
	document.writeln("}");
	document.writeln("</style>");
}
else
{
	document.writeln("<style type=\"text/css\" />");
	document.writeln("html { ");
	document.writeln("	width: 980px;");
	document.writeln("	margin-right: auto;");
	document.writeln("	margin-left: auto;");
	document.writeln("}");
	document.writeln("</style>");
}
function GetStyle(obj)
{
	if (obj.currentStyle)
	{
		return obj.currentStyle;
	}
	else if (window.getComputedStyle)
	{
		return window.getComputedStyle(obj,null);
	}
}
window.onresize=function()
{
	var Ems=document.getElementsByTagName("*");
		for (var i=0; i<Ems.length; i++)
		{
			if (GetStyle(Ems[i]).position=="absolute")
			{
				Ems[i].style.position="static";
				Ems[i].style.position="absolute";
			}
		}
} 