//purchase hide

document.write("<style>.purchase #left table th p { display:none;} .defaultSalesman { display:none;}</style>");

//load func

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

//control foot top

function getheight() {
	if(!document.getElementById("left")) return false;
	var left = document.getElementById("left");
	var right = document.getElementById("right");
	var foot = document.getElementById("foot");
	var leftheight = left.clientHeight;
	var rightheight = right.clientHeight;
	if ( leftheight > rightheight) {
		foot.style.top = leftheight + 157 + "px";
	}
	else {
		foot.style.top = rightheight + 157 + "px";
	}
	if (parseInt(foot.style.top) + 90 < document.documentElement.offsetHeight) {
		foot.style.top = document.documentElement.offsetHeight - 90 + "px";
	}
	if (parseInt(foot.style.top) + 90 < window.innerHeight) {
		foot.style.top = window.innerHeight - 90 + "px";
	}
}

addLoadEvent(getheight);

//purchase pages,show text in table

function showhide() {
	var hidetext = this.nextSibling;
	if(hidetext.nodeType == 3) {
		hidetext = hidetext.nextSibling;
	}
    hidetext.className = (hidetext.className == "") ? "show":"";
	getheight();
}

function purchase_show() {
	if(!document.getElementById("show_table")) return false;
	var show_table = document.getElementById("show_table");
	var strongs = show_table.getElementsByTagName("strong");
	for(var j=0; j<strongs.length; j++) {
		if(strongs[j].className == "showhide") {
			strongs[j].onclick = showhide;
		}
	}
}

addLoadEvent(purchase_show);
	
	
//all menu effects

//this func only for some cate which have return menu
function rightmenuHover(menuobj) {
	var links = menuobj.getElementsByTagName("a");
	var windowLocationhref = window.location.href.split("/");
	var locationHref;
	if(windowLocationhref[windowLocationhref.length-1] == "") {
		locationHref = windowLocationhref[windowLocationhref.length-2];
	} else {
		locationHref = windowLocationhref[windowLocationhref.length-1];
	}
	for(i=0; i<links.length; i++) {
		var linksHref = links[i].href.split("/");
		var linksRighthref;
		if(linksHref[linksHref.length-1] == "") {
			linksRighthref = linksHref[linksHref.length-2];
		} else {
			linksRighthref = linksHref[linksHref.length-1];
		}
		if(locationHref == linksRighthref) {
			links[i].className = 'here';
		} else {
			links[i].className = '';
		}
		links[i].onmouseover = function() {
			for(j=0; j<links.length; j++) {
				links[j].className = '';
			}
			this.className = 'here';
		}
		links[i].onmouseout = function() {
			for(j=0; j<links.length; j++) {
				links[j].className = '';
				var linksHref2 = links[j].href.split("/");
				var linksRighthref2;
				if(linksHref2[linksHref2.length-1] == "") {
					linksRighthref2 = linksHref2[linksHref2.length-2];
				} else {
					linksRighthref2 = linksHref2[linksHref2.length-1];
				}
				if(locationHref == linksRighthref2) {
					links[j].className = 'here';
				}
			}
	}
	}
}

//for common menu
function topmenuHover(menuobj) {
	var links = menuobj.getElementsByTagName("a");
	for(i=0; i<links.length; i++) {
		if(window.location.href.indexOf(links[i].href) != -1) {
			links[i].className = 'here';
		} else {
			links[i].className = '';
		}
		links[i].onmouseover = function() {
			for(j=0; j<links.length; j++) {
				links[j].className = '';
			}
			this.className = 'here';
		}
		links[i].onmouseout = function() {
			for(j=0; j<links.length; j++) {
				links[j].className = '';
				if(window.location.href.indexOf(links[j].href) != -1) {
					links[j].className = 'here';
				}
			}
	}
	}
}

//top menu effect
function topmenu () {
	if(!document.getElementById("menu")) return false;
	var menuobj = document.getElementById("menu");
	topmenuHover(menuobj);
}

//right menu effect
function rightmenu () {
	if(!document.getElementById("right")) return false;
	var menuobj = document.getElementById("right");
	rightmenuHover(menuobj);
}

addLoadEvent(topmenu);
addLoadEvent(rightmenu);

