var Load={
	imageHover:function(){
		$(document).ready(function() 
{
	$(".indexImage").hover(function(){
		$("#productShow").attr("src",this.src.replace("small","middle"));
		$("#replaceimg").attr("href",this.src.replace("-small",""));
		$(this).removeClass("indexImage").addClass("indexImageOver");
	},
	function(){
		$(this).addClass("indexImage");	
	}
	);
	});
	}
};

var Company={
	id:"",
	setCompanyid:function(entid){
		this.id = entid;
	}
};

var Menu={
	init:function(){
		var lis = document.getElementById("navmenu").getElementsByTagName("LI");
		for (var i=0; i<lis.length; i++) {
			lis[i].onmouseover=function() {
				this.className+=" iehover";
			}
			lis[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" iehover\\b"), "");
			}
		}
	}
};

var VIP={
	logoutVip:function(inp){
		//$.post("/sa/product/vip/exitVIPRoom.do",{companyID:Company.id,s:s},function(data){
		$.getJSON("http://winxiang.gicp.net:20/jt/viplogin.do?method=viplogout&callback=?",function(data)
		{
			if(data==null||data==""){
				location.href="vip.html";
			}else{
				alert(data);
			}
		});
	},
	loadVipCategoryH3:function(){
		//$.post("/sa/product/vip/inVIP.do",function(data){
		$.getJSON("http://winxiang.gicp.net:20/jt/viplogin.do?method=invip&callback=?",function(data)
		{
		  	if(data==null||data=="")
		  	{
		  		
            }
            else
            {
		    	location.href="vipwelcome_"+ data +".html";
		   	}
		});
	},
	loadVipProduct:function(){
		//$.post("/sa/product/vip/inVIP.do",function(data){
		$.getJSON("http://winxiang.gicp.net:20/jt/viplogin.do?method=invip&callback=?",function(data)
		{
		  	if(data==null||data=="")
		  	{
		  		location.href="vip.html";
            }
            else
            {
		    	
		   	}
		});
	},
	loginVip:function(sub){
		var form=sub.form;
		var pass=form.vippwd.value;
		//var s = new Date().getSeconds();

		//$.post("/sa/product/vip/login.do",{password:pass,companyID:Company.id,s:s},function(data){
		$.getJSON("http://winxiang.gicp.net:20/jt/viplogin.do?method=viplogin&password="+pass+"&companyID="+Company.id+"&callback=?",function(data){
		if(data==null||data==""){
		    alert("Incorrect Password Please try again!");
		}else{
			location.href="vipwelcome_"+ data +".html";
		}
		});
	},

	loginVipToList:function(sub){
		var form=sub.form;
		var pass=form.vippwd.value;

		var s = new Date().getSeconds();

		$.post("/sa/product/vip/loginToList.do",{password:pass,companyID:Company.id,s:s},function(data){
		if(data==null||data==""){
			location.href="/vip/vipwelcome.html";
		}else if(data=="1"){
			alert(Lang.show(Lang.Incorrect_Password_Please_try_again));
		}else{
				location.href="/vip/productList_"+ data +"_1_index.html";
			}
		});
	},

	loadProduct:function(id,div){
	  	$("#"+div).load("/sa/product/vip/vipOneProductData.do",{id:id,companyID:Company.id},function(data){
			if(data==null||data==""){
			    location.href="/vip/index.html";
			}
		});
    },
	loadOtherProduct:function(id,div){
	  $("#"+div).load("/sa/product/vip/vipOtherProducts.do",{id:id});
    },
	loadProductList:function(id,div){
		var list=id.split(",");
		var groupID=list[0];
		var curPage=list[1];
		$("#"+div).load("/sa/product/vip/categoryProductList.do",{groupID:groupID,curPage:curPage,companyID:Company.id});
	},
	loadVipCategoryNav:function(id,div){
		var list=id.split(",");
		var groupID=list[0];
		$("#"+div).load("/sa/product/vip/loadVipCategoryH3.do",{groupID:groupID},function(data){
			if(data==null||data==""){

			    location.href="/vip/index.html";
			}
		});
	},
	loadVipCategoryLink:function(id,div){
		var list=id.split(",");
		var groupID=list[0];
		$("#"+div).load("/sa/product/vip/loadVipCategoryLink.do",{groupID:groupID,companyID:Company.id});
	},
	getChildrenGroup:function(id,div,div2){
	    document.getElementById(div2).style.display="none";
		var list=id.split(",");
		var groupID=list[0];
		$.post("/sa/product/vip/getChildrenGroup.do",{groupID:groupID,companyID:Company.id},function(data){
				if(data==null || data==""){

				}else{
				    document.getElementById(div2).style.display="block";
		            document.getElementById(div).innerHTML=data;
		        }
		});

	},
	vipCategoryLoad:function(div){
		var s = new Date().getTime();
		$.post("/sa/product/vip/category.do",{s:s},function(data){
			if(data==null||data==""){
				document.getElementById("vipProductCategory").style.display="block";
			    var s = new Date().getTime();
				$("#"+div).load("/sa/product/vip/openCategory.do",{s:s,companyID:Company.id});
			}else{
				document.getElementById("vipProductCategory").style.display="block";
				document.getElementById(div).innerHTML=data;
			}
		});
	},

	loadQuery:function(){

		$.post("/sa/queryFollow/queryInfo.do",{companyID:Company.id},function(data){
		if(data==null||data==""){
		document.getElementById("querySelect").innerHTML="<select id='queryMethodID' name='queryMethodID'><option  value='-1'>no data</option></select>";
		}else{
		document.getElementById("querySelect").innerHTML=data;
		}
		});

	},

	loginQueryLogin:function(sub){
	var form=sub.form;
	var cmethodId=form.configureMethodID.value;
	var queryno=form.queryNo.value;
	var pass=form.password.value;

	if(queryno==null||queryno==""){
			alert("num");
			return false;
		}
	if(document.getElementById("password").style.display==""){

		if(pass==null||pass==""){
				alert("pass");
				return false;
		}
	}
	$.post("/sa/queryFollow/queryLogin.do",{companyID:Company.id,configureMethodID:cmethodId,queryNo:queryno,password:pass},function(data){
		if(data==null||data==""){

		alert(Lang.show(Lang.Incorrect_Password_Please_try_again));
		}else{
		location.href="/profile/queryList.html";
		}

		});
	return true;

	},
	loadQueryList:function(sub){
	$.post("/sa/queryFollow/query.do",{companyID:Company.id},function(data){
		if(data==null||data==""){

		document.getElementById("queryList").innerHTML="No Information";
		}else{

		document.getElementById("queryList").innerHTML=data;
		}

		});
	}

};

var Basket={
	loadBasketProductList:function(div){
		//$("#"+div).load("http://winxiang.gicp.net:20/jt/basketManage.do?method=list&rep=basket");
		$.getJSON("http://winxiang.gicp.net:20/jt/basketManage.do?method=list&rep=basket&callback=?",function(data){
		 //alert("data   "+data);
		var rtnStr=eval(data); 
		document.getElementById(div).innerHTML=data;
	   });
	},
	loadFeedbackProductList:function(div){
		//$("#"+div).load("http://117.88.242.52:20/jt/basketManage.do?method=list&rep=feedback");
	},
	showProducts:function(img){
		if(img.alt=='s1'){
			img.alt='s2';
			img.src='../css/images/menu_open.gif';
			document.getElementById('feedbackProduct').style.display='block';
		}else{
			img.alt='s1';
			img.src='../css/images/menu_close.gif';
			document.getElementById('feedbackProduct').style.display='none';
		}
	},
	checkFeedback:function(inp){
		var form=inp.form;
		
      	//产品
		form.products.value=document.getElementById("feedbackProduct").innerText;
		//国家
		var guestcountry=countryfra.document.getElementById("country").value;
		form.countryFrom.value=guestcountry;
		
		//主题
		var guestsubject=form.guestsubject.value;
		if(guestsubject==null||guestsubject=="")
		{
			alert("please_specify_your_name");
			return false;
		}
		
		//邮箱
		var guestemail=form.guestemail.value;
		if(guestemail==null||guestemail=="")
		{
			alert("please_specify_your_email_address");
			return false;
		}
		var pattern=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
	    flag=pattern.test(guestemail);
	    if (!flag)
	    {
		    alert("please_input_valid_email_address");
	        return false;
	    }
	    
	    /*
		var guestphone1=form.guestphone1.value;
		var guestphone2=form.guestphone2.value;
		var guestphone3=form.guestphone3.value;
		var guestfax1=form.guestfax1.value;
		var guestfax2=form.guestfax2.value;
		var guestfax3=form.guestfax3.value;
		*/
		
		//留言
		var guestmessage=form.guestmessage.value;
		if(guestmessage==null||guestmessage=="")
		{
			alert("please_specify_content");
			return false;
		}		
	    return true;
	},
	hidePopMsg:function(){
		$("#show_pop_msg").remove();
	},
	basketAdd:function(inp){ //add product
		var form=inp.form;
		var pSelected=form.pSelected;
		var str="";
		if(pSelected==null){
			str=document.getElementById("proIDdetail").value+",";
		}else{
			if(pSelected.value){
			   if(pSelected.checked){
				   str=pSelected.value+",";
			   }
			}else{
				for(var i=0;i<pSelected.length;i++){
					if(pSelected[i].checked){
						str+=pSelected[i].value+",";
					}
				}
		    }
		    if(str==""){
		       alert("please_select_product_into_basket");
		    }else{
		       alert("add_successfully");
			}
		}
		//$.post("http://117.88.242.52:20/jt/basketManage.do?method=add",{str:str});
		$.getJSON("http://winxiang.gicp.net:20/jt/basketManage.do?method=add&str="+ str +"&callback=?");

	},

	inquire:function(inp){ //add product and goto basket
		var form=inp.form;
		var pSelected=form.pSelected;
		var str="";
		if(pSelected==null){

		}else{
			if(pSelected.value){
			   if(pSelected.checked){
				   str=pSelected.value+",";
			   }
			}else{
				for(var i=0;i<pSelected.length;i++){
					if(pSelected[i].checked){
						str+=pSelected[i].value+",";
					}
				}
		    }
		    if(str==""){
		       //alert(Lang.show(Lang.please_select_product_into_basket));
		    }else{
		       //alert(Lang.show(Lang.add_successfully));
			}
			//$.post("http://117.88.242.52:20/jt/addfeedback.do",{str:str});
		}
		location.href="../face/basketmanager.html";
	},

	addGoToBasket:function(sub){ //add product and goto feedback
		var form=sub.form;
		var pSelected=form.pSelected;
		var str="";
		if(pSelected!=null){
			if(pSelected.value){
			   if(pSelected.checked){
				   str=pSelected.value+",";
			   }
			}else{
				for(var i=0;i<pSelected.length;i++){
					  if(pSelected[i].checked){
					    str+=pSelected[i].value+",";
					  }
				}
		    }
			if(str==""){
		       alert(Lang.show(Lang.please_select_product_into_basket));
		    }else{
		       alert(Lang.show(Lang.add_successfully));
		       $.post("/sa/feedback/addfeedback.do",{str:str},
			       function(data){
					if(data==null||data==""){
						location.href="/profile/feedback.html";
					}else{
						alert(data);
					}
				});
			}
		}
	},
	delFeedbackProducts:function(sub){
		var form=sub.form;
		var pSelected=form.pSelected;
		var str="";
		if(pSelected==null){

		}else{
			if(pSelected.value){
			   if(pSelected.checked){
				   str=pSelected.value+",";
			   }
			}else{for(var i=0;i<pSelected.length;i++){
				  if(pSelected[i].checked){
				  str+=pSelected[i].value+",";
				 }
			   }
			}
			if(str==""){
		       alert("1");
		    }else{
               $.getJSON("http://winxiang.gicp.net:20/jt/basketManage.do?method=del&str="+ str +"&callback=?");
			   location.href="../face/basketmanager.html";
			   alert("success");
			}
		}
	}
};


var Category={
	id:0,
	unique:"",
	show:function(t,num,id){
		var c=t.src;
		var cid=id.replace("cid","");
		num=num+1;
		if(num>3) return;
		if(c.indexOf("close")!=-1){
			t.src="/css/images/menu_open.gif";
			$("#uid"+cid).css("display","block");
		}else{

			t.src="/css/images/menu_close.gif";
			$("#uid"+cid).css("display","none");
		}
	},
	cateInit:function(){
		try{
			var c=$("#cid"+this.id);
			while(p!=null){
				p.style.display="block";
				if(p.tagName=="LI"){
					$("#"+p.id+"/img")[0].src="/css/images/menu_open.gif";
				}
				if(p.className=="category"){
					break;
				}
				p=p.parentNode;
			}
			/*
			p=c.parentNode;
			if(p.tagName=="LI"){
					$("#"+p.id+" .u2").css("display","block");
					if(p.className=="l2"){
						$("#"+p.id+" .u3").css("display","block");
					}
			}
			*/
		}catch(e){}
	}
};

var Foundation={
	gotoPage:function(pageNum){
		var str = decodeURIComponent(location.search.substr(1))+"&";
		var n=str.indexOf("&");
		var s=str.substr(0,n);
		location.href="../face/search.html?"+s+"&&"+ pageNum;
	},
	inputResotre:function(inp){
		inp.value="";
	},
	selectAll:function(inp){
	   var form=inp.form;
	   var arrObj=form.pSelected;
       if(arrObj!=null){
       var allObj=document.getElementsByName("allSelected");

       if(allObj[0].checked){
       	   arrObj.checked = true;
       }else{
       	   arrObj.checked = false;
       }

	  if(allObj[0].checked){
       	for(var i=0;i<arrObj.length;i++){
       		arrObj[i].checked = true;
       	}
       }else{
       	for(var i=0;i<arrObj.length;i++){
       		arrObj[i].checked = false;
       	}
       }
       }
 	},
 	selectOne:function(inp)
 	{
 	
 	},
 	searchSubmit:function(sub,path)
 	{
		var search=encodeURIComponent(sub.form.value.value);
		var colresult = "0";
		var colradio = document.getElementsByName("colselect");
		if (colradio)
		{
			for (i=0;i<colradio.length;i++)
			{
				if(colradio[i].checked)
				{
					colresult = colradio[i].value;
				}
			}
		}
		
		colresult= "**" + colresult;
		location.href=path + "face/search.html?"+search+colresult;
	},
	loadSearchProduct:function()
	{
	   var str = decodeURIComponent(location.search.substr(1));
	   //alert("str  "+str);
	   //str = str.replace("&&","00000");
	   //$.post("http://117.88.242.52:20/jt/search.do?method=search",{str:str,companyID:Company.id},function(data){
       $.getJSON("http://winxiang.gicp.net:20/jt/search.do?method=search&str="+encodeURIComponent(str)+"&companyID="+Company.id+"&callback=?",function(data){
		var rtnStr=eval(data); 
		document.getElementById("searchContent").innerHTML=data;
		if(document.getElementById("siteLanguage").value == "en")
		{
			document.getElementById("searchFoundTitle").innerHTML="Found "+document.getElementById("searchFoundNum").value+" products for "+str.split("**")[0];
		}
		if(Company.id == '58')
		{
			document.getElementById("searchFoundTitle").innerHTML="Found "+document.getElementById("searchFoundNum").value+" results for "+str.split("**")[0];
		}
	   });
	},
	loadSearchDetail:function()
	{
		var str = location.search.substr(1);
		$.getJSON("http://winxiang.gicp.net:20/jt/search.do?method=searchDetail&str="+str+"&callback=?",function(data){
			var rtnStr=eval(data); 
			document.getElementById("searchDetailContent").innerHTML=data;
		});
	}
};


var Subscriber={
   addSubscriber:function(sub,path){
      var form=sub.form;
	   var name=form.name.value;
	   var email=form.email.value;
	   var company=form.company.value;
	   if(name==null || name=="" ){
		  alert("please specify your name");
	      return false;
	   }
	   if(company==null || company=="" ){
	      alert("please specify your company");
	      return false;
	   }
	   if(email==null || email=="" ){
	      alert("please specify your email address");
	      return false;
	   }
	   var pattern=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
	   flag=pattern.test(email);
	   if (!flag){
		  alert("please input valid email address");
	      return false;
	   }
	   if(name==null || name=="" || email==null || email==""||company==null || company==""){
	      alert("please specify content");
	      return false;
	   }else{
	      //$.post("http://winxiang.gicp.net:20/jt/addSubscriber.do",{name:name,email:email,company:company,companyID:Company.id},function(data){
          $.getJSON("http://winxiang.gicp.net:20/jt/addSubscriber.do?name="+encodeURIComponent(name)+"&email="+email+"&company="+encodeURIComponent(company)+"&companyID="+Company.id+"&callback=?");
		  alert("thanks for your subscription");
	   }
   }
};

var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};

Spry.Widget.TabbedPanels = function(element, opts)
{
	this.element = this.getElement(element);
	this.defaultTab = 0; // Show the first panel by default.
	this.bindings = [];
	this.tabSelectedClass = "TabbedPanelsTabSelected";
	this.tabHoverClass = "TabbedPanelsTabHover";
	this.tabFocusedClass = "TabbedPanelsTabFocused";
	this.panelVisibleClass = "TabbedPanelsContentVisible";
	this.focusElement = null;
	this.hasFocus = false;
	this.currentTabIndex = 0;
	this.enableKeyboardNavigation = true;

	Spry.Widget.TabbedPanels.setOptions(this, opts);

	// If the defaultTab is expressed as a number/index, convert
	// it to an element.

	if (typeof (this.defaultTab) == "number")
	{
		if (this.defaultTab < 0)
			this.defaultTab = 0;
		else
		{
			var count = this.getTabbedPanelCount();
			if (this.defaultTab >= count)
				this.defaultTab = (count > 1) ? (count - 1) : 0;
		}

		this.defaultTab = this.getTabs()[this.defaultTab];
	}

	// The defaultTab property is supposed to be the tab element for the tab content
	// to show by default. The caller is allowed to pass in the element itself or the
	// element's id, so we need to convert the current value to an element if necessary.

	if (this.defaultTab)
		this.defaultTab = this.getElement(this.defaultTab);

	this.attachBehaviors();
};

Spry.Widget.TabbedPanels.prototype.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
}

Spry.Widget.TabbedPanels.prototype.getElementChildren = function(element)
{
	var children = [];
	var child = element.firstChild;
	while (child)
	{
		if (child.nodeType == 1 /* Node.ELEMENT_NODE */)
			children.push(child);
		child = child.nextSibling;
	}
	return children;
};

Spry.Widget.TabbedPanels.prototype.addClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
		return;
	ele.className += (ele.className ? " " : "") + className;
};

Spry.Widget.TabbedPanels.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};

Spry.Widget.TabbedPanels.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
	if (!optionsObj)
		return;
	for (var optionName in optionsObj)
	{
		if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
			continue;
		obj[optionName] = optionsObj[optionName];
	}
};

Spry.Widget.TabbedPanels.prototype.getTabGroup = function()
{
	if (this.element)
	{
		var children = this.getElementChildren(this.element);
		if (children.length)
			return children[0];
	}
	return null;
};

Spry.Widget.TabbedPanels.prototype.getTabs = function()
{
	var tabs = [];
	var tg = this.getTabGroup();
	if (tg)
		tabs = this.getElementChildren(tg);
	return tabs;
};

Spry.Widget.TabbedPanels.prototype.getContentPanelGroup = function()
{
	if (this.element)
	{
		var children = this.getElementChildren(this.element);
		if (children.length > 1)
			return children[1];
	}
	return null;
};

Spry.Widget.TabbedPanels.prototype.getContentPanels = function()
{
	var panels = [];
	var pg = this.getContentPanelGroup();
	if (pg)
		panels = this.getElementChildren(pg);
	return panels;
};

Spry.Widget.TabbedPanels.prototype.getIndex = function(ele, arr)
{
	ele = this.getElement(ele);
	if (ele && arr && arr.length)
	{
		for (var i = 0; i < arr.length; i++)
		{
			if (ele == arr[i])
				return i;
		}
	}
	return -1;
};

Spry.Widget.TabbedPanels.prototype.getTabIndex = function(ele)
{
	var i = this.getIndex(ele, this.getTabs());
	if (i < 0)
		i = this.getIndex(ele, this.getContentPanels());
	return i;
};

Spry.Widget.TabbedPanels.prototype.getCurrentTabIndex = function()
{
	return this.currentTabIndex;
};

Spry.Widget.TabbedPanels.prototype.getTabbedPanelCount = function(ele)
{
	return Math.min(this.getTabs().length, this.getContentPanels().length);
};

Spry.Widget.TabbedPanels.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
			element.addEventListener(eventType, handler, capture);
		else if (element.attachEvent)
			element.attachEvent("on" + eventType, handler);
	}
	catch (e) {}
};

Spry.Widget.TabbedPanels.prototype.onTabClick = function(e, tab)
{
	this.showPanel(tab);
};

Spry.Widget.TabbedPanels.prototype.onTabMouseOver = function(e, tab)
{
	this.addClassName(tab, this.tabHoverClass);
};

Spry.Widget.TabbedPanels.prototype.onTabMouseOut = function(e, tab)
{
	this.removeClassName(tab, this.tabHoverClass);
};

Spry.Widget.TabbedPanels.prototype.onTabFocus = function(e, tab)
{
	this.hasFocus = true;
	this.addClassName(this.element, this.tabFocusedClass);
};

Spry.Widget.TabbedPanels.prototype.onTabBlur = function(e, tab)
{
	this.hasFocus = false;
	this.removeClassName(this.element, this.tabFocusedClass);
};

Spry.Widget.TabbedPanels.ENTER_KEY = 13;
Spry.Widget.TabbedPanels.SPACE_KEY = 32;

Spry.Widget.TabbedPanels.prototype.onTabKeyDown = function(e, tab)
{
	var key = e.keyCode;
	if (!this.hasFocus || (key != Spry.Widget.TabbedPanels.ENTER_KEY && key != Spry.Widget.TabbedPanels.SPACE_KEY))
		return true;

	this.showPanel(tab);

	if (e.stopPropagation)
		e.stopPropagation();
	if (e.preventDefault)
		e.preventDefault();

	return false;
};

Spry.Widget.TabbedPanels.prototype.preorderTraversal = function(root, func)
{
	var stopTraversal = false;
	if (root)
	{
		stopTraversal = func(root);
		if (root.hasChildNodes())
		{
			var child = root.firstChild;
			while (!stopTraversal && child)
			{
				stopTraversal = this.preorderTraversal(child, func);
				try { child = child.nextSibling; } catch (e) { child = null; }
			}
		}
	}
	return stopTraversal;
};

Spry.Widget.TabbedPanels.prototype.addPanelEventListeners = function(tab, panel)
{
	var self = this;
	Spry.Widget.TabbedPanels.addEventListener(tab, "click", function(e) { return self.onTabClick(e, tab); }, false);
	Spry.Widget.TabbedPanels.addEventListener(tab, "mouseover", function(e) { return self.onTabMouseOver(e, tab); }, false);
	Spry.Widget.TabbedPanels.addEventListener(tab, "mouseout", function(e) { return self.onTabMouseOut(e, tab); }, false);

	if (this.enableKeyboardNavigation)
	{
		// XXX: IE doesn't allow the setting of tabindex dynamically. This means we can't
		// rely on adding the tabindex attribute if it is missing to enable keyboard navigation
		// by default.

		// Find the first element within the tab container that has a tabindex or the first
		// anchor tag.

		var tabIndexEle = null;
		var tabAnchorEle = null;

		this.preorderTraversal(tab, function(node) {
			if (node.nodeType == 1 /* NODE.ELEMENT_NODE */)
			{
				var tabIndexAttr = tab.attributes.getNamedItem("tabindex");
				if (tabIndexAttr)
				{
					tabIndexEle = node;
					return true;
				}
				if (!tabAnchorEle && node.nodeName.toLowerCase() == "a")
					tabAnchorEle = node;
			}
			return false;
		});

		if (tabIndexEle)
			this.focusElement = tabIndexEle;
		else if (tabAnchorEle)
			this.focusElement = tabAnchorEle;

		if (this.focusElement)
		{
			Spry.Widget.TabbedPanels.addEventListener(this.focusElement, "focus", function(e) { return self.onTabFocus(e, tab); }, false);
			Spry.Widget.TabbedPanels.addEventListener(this.focusElement, "blur", function(e) { return self.onTabBlur(e, tab); }, false);
			Spry.Widget.TabbedPanels.addEventListener(this.focusElement, "keydown", function(e) { return self.onTabKeyDown(e, tab); }, false);
		}
	}
};

Spry.Widget.TabbedPanels.prototype.showPanel = function(elementOrIndex)
{
	var tpIndex = -1;

	if (typeof elementOrIndex == "number")
		tpIndex = elementOrIndex;
	else // Must be the element for the tab or content panel.
		tpIndex = this.getTabIndex(elementOrIndex);

	if (!tpIndex < 0 || tpIndex >= this.getTabbedPanelCount())
		return;

	var tabs = this.getTabs();
	var panels = this.getContentPanels();

	var numTabbedPanels = Math.max(tabs.length, panels.length);

	for (var i = 0; i < numTabbedPanels; i++)
	{
		if (i != tpIndex)
		{
			if (tabs[i])
				this.removeClassName(tabs[i], this.tabSelectedClass);
			if (panels[i])
			{
				this.removeClassName(panels[i], this.panelVisibleClass);
				panels[i].style.display = "none";
			}
		}
	}

	this.addClassName(tabs[tpIndex], this.tabSelectedClass);
	this.addClassName(panels[tpIndex], this.panelVisibleClass);
	panels[tpIndex].style.display = "block";

	this.currentTabIndex = tpIndex;
};

Spry.Widget.TabbedPanels.prototype.attachBehaviors = function(element)
{
	var tabs = this.getTabs();
	var panels = this.getContentPanels();
	var panelCount = this.getTabbedPanelCount();

	for (var i = 0; i < panelCount; i++)
		this.addPanelEventListeners(tabs[i], panels[i]);

	this.showPanel(this.defaultTab);
};



function correctPNG()
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images[i]
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
{
var imgID = (img.id) ? "id='" + img.id + "' " : ""
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
var imgStyle = "display:inline-block;" + img.style.cssText
if (img.align == "left") imgStyle = "float:left;" + imgStyle
if (img.align == "right") imgStyle = "float:right;" + imgStyle
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
var strNewHTML = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
img.outerHTML = strNewHTML
i = i-1
}
}
}
if(window.attachEvent){window.attachEvent("onload", correctPNG);}
