function MenuFull() {
var Full = document.getElementById("Full");
var Upgrade = document.getElementById("Upgrade");
	Upgrade.style.display="none";
	Full.style.display="block";
} 

function MenuUpgrade() {
var Full = document.getElementById("Full");
var Upgrade = document.getElementById("Upgrade");
	Full.style.display="none";
	Upgrade.style.display="block";
} 

var checkMenu = true;

function noHref(num) {
			var level1 = document.getElementById('root'+num+'');
			var aNode = level1.lastChild;
			aNode.href = "javascript:;";
			aNode.style.cursor = "default";
} 

function OverImg(num){
	var level1 = document.getElementById(num);
	var img = level1.lastChild.lastChild;
	img.src ="imgs/banner/menu/"+num+"Over.gif";
}

function OutImg(num){
	var level1 = document.getElementById(num);
	var img = level1.lastChild.lastChild;
	img.src ="imgs/banner/menu/"+num+".gif";
}

function OverImg2(num){
	var level1 = document.getElementById(num);
	var img = level1;
	img.src ="imgs/banner/menu/"+num+"Over.gif";
}

function OutImg2(num){
	var level1 = document.getElementById(num);
	var img = level1;
	img.src ="imgs/banner/menu/"+num+".gif";
}

function OpenMenu(num) {

		if(num == 'Shapewear'){
			var level2 = document.getElementById('Shapewear');
			level2.style.display="block";
		}
			var level1 = document.getElementById('root'+num+'');
			var img = level1.lastChild.lastChild;
			img.src ="imgs/banner/menu/root"+num+".gif";
} 

function CloseMenu(num) {
		
		if(num == 'Shapewear'){
			var level2 = document.getElementById('Shapewear');
			level2.style.display="none";
		}
			var level1 = document.getElementById('root'+num+'');
			var img = level1.lastChild.lastChild;
			img.src ="imgs/banner/menu/root"+num+"Hidden.gif";
} 

var count = true;
function tag() {
	var tagUpgradea= document.getElementById('tagUpgradea');
	var tagFulla = document.getElementById('tagFulla');
	if(count == true){
		tagFulla.style.background="url(./imgs/TagBG2.png) top center no-repeat";
		tagUpgradea.style.background="url(./imgs/TagBG.png) top center no-repeat";
		tagUpgradea.innerHTML= '<span id="tagUpgradeb" style="">Upgrade</span>';
		tagFulla.innerHTML= '<span><a href="javascript:MenuFull();tag();" id="tagFullb">Full</a></span>';
		count = false;
	}else if(count == false){
		tagFulla.style.background="url(./imgs/TagBG.png) top center no-repeat";
		tagUpgradea.style.background="url(./imgs/TagBG2.png) top center no-repeat";
		tagFulla.innerHTML= '<span id="tagFullb" style="">Full</span>';
		tagUpgradea.innerHTML= '<span><a href="javascript:MenuUpgrade();tag();" id="tagUpgradeb">Upgrade</a></span>';
		count = true;
	}
} 

function colorSelect(colorID) {
	var colors=new Array("Red","Blue","Green","Black","Grey");
	var targetColor = colorID.slice(11);
	var select = "colorSelect";
	for (x in colors){
		if(targetColor == colors[x]){
		var node= document.getElementById(colorID);
		//document.write(node);
		node.innerHTML = '<img alt="" src="imgs/product/color/'+colorID.slice(11)+'Selected.png" id="colorSelect'+colorID.slice(11)+'" border="0" />';
		}else{
		var selects = select.concat(colors[x]);
		var node= document.getElementById(selects);
		node.innerHTML = '<img alt="" src="imgs/product/color/'+colors[x]+'.png" id="colorSelect'+colors[x]+'" border="0" />';
		}

	}
}

function getWindowScroll() {
    var T, L, W, H;            
    var browserLanguage= detectBrowserLanguage();
    if (browserLanguage.browser != 'Netscape') {
      T = document.documentElement.scrollTop;
      L = document.documentElement.scrollLeft;
      W = document.documentElement.scrollWidth;
      H = document.documentElement.scrollHeight;
    } 
    else {
      var w = window;
      with (w.document) {
        if (w.document.documentElement && documentElement.scrollTop) {
          T = documentElement.scrollTop;
          L = documentElement.scrollLeft;
        } else if (w.document.body) {
          T = body.scrollTop;
          L = body.scrollLeft;
        }
        if (w.innerWidth) {
          W = w.innerWidth;
          H = w.innerHeight;
        } else if (w.document.documentElement && documentElement.clientWidth) {
          W = documentElement.clientWidth;
          H = documentElement.clientHeight;
        } else {
          W = body.offsetWidth;
          H = body.offsetHeight
        }
      }
    }
	return { top: T, left: L, width: W, height: H };
}

var t;

function slideDown() {
	 var windowScroll = getWindowScroll();  
	 var popupTable = document.getElementById('popupTable');
	 popupTable.style.margin = windowScroll.top + "px auto";
	 t=setTimeout("slideDown()",100);
}

function detectBrowserLanguage(){
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
return {browser: browser ,version: version};
}

function getPageSize() {          
    var windowWidth, windowHeight;
    var pageHeight, pageWidth;
	var browserLanguage= detectBrowserLanguage();
    if (browserLanguage.browser != 'Netscape') {
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;  
      pageWidth = document.documentElement.scrollWidth;
      pageHeight = document.documentElement.scrollHeight;   
    } 
    else {
      var xScroll, yScroll;
      if (window.innerHeight && window.scrollMaxY) {  
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
      } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
      } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
      }


      if (self.innerHeight) {  // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
      } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
      } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
      }  

      // for small pages with total height less then height of the viewport
      if(yScroll < windowHeight){
        pageHeight = windowHeight;
      } else { 
        pageHeight = yScroll;
      }

      // for small pages with total width less then width of the viewport
      if(xScroll < windowWidth){  
        pageWidth = windowWidth;
      } else {
        pageWidth = xScroll;
      }
    }             
    return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
}

var r;
var countNum = 0;

function opacity(num){
	var div = document.getElementById(num);
	countNum = 1;
	if(countNum <=1){
		div.style.opacity = countNum;
		div.style.filter = 'alpha(opacity='+countNum*100+')';
	}
	r=setTimeout("opacity('"+num+"')",50);
}

function resetOpacity(){
	stopCount(r);
	countNum = 0;
	}

var gTitleDiv;

function openPopup(num) {
		var num = num;
		var popupDiv = document.getElementById(num);
		var popupTable = document.getElementById('popupTable');
		var popupBG = document.getElementById('popupBG');
		var pageSize = getPageSize();
		popupBG.style.height = pageSize.pageHeight + "px";
		var popupId = popupDiv.childNodes;
		popupTable.style.height = pageSize.windowHeight + "px";
		popupBG.style.display="block";
		var titleDiv = popupDiv.childNodes;
		if(navigator.appName == "Netscape"){
			if(titleDiv[1].nodeName == 'DIV'){
				titleDiv[1].style.display="block";
				gTitleDiv = titleDiv[1];
				/*opacity(num);*/
				for(var j=0; j<popupId.length; j++){
					if(popupId[j].nodeName == "DIV"){
						if(popupId[j].id == "editBillingAddress"){
							if(t){
							clearTimeout(t);
							}
							
						}else{
							slideDown();
							break;
						}
					}
				}
			}
		}else if(navigator.appName == "Microsoft Internet Explorer"){
				if(titleDiv[0].nodeName == 'DIV'){
				titleDiv[0].style.display="block";
				gTitleDiv = titleDiv[0];
				/*opacity(num);*/
				for(var j=0; j<popupId.length; j++){
					if(popupId[j].nodeName == "DIV"){
						if(popupId[j].id == "editBillingAddress" ){
							if(t){
							clearTimeout(t);
							}
						}else{
							slideDown();
							break;
						}
					}
				}
			}
		}
		
		var onfocus = document.getElementById('onFocus');
		if(onfocus != null){
		onfocus.focus();
		}
}

function closePopup(num) {
		var popupDiv = document.getElementById(num);
		popupDiv.style.display="none";
		var titleDiv = popupDiv.childNodes;
		if(navigator.appName == "Netscape"){
			if(titleDiv[1].nodeName == 'DIV'){
				titleDiv[1].style.display="none";
			}
			clearTimeout(t);
		}else if(navigator.appName == "Microsoft Internet Explorer"){
			if(titleDiv[0].nodeName == 'DIV'){
				titleDiv[0].style.display="none";
			}
			clearTimeout(t);
		}
}

function hiddenSelect(){
	document.all.select1.style.visibility="hidden";
	document.all.select2.style.visibility="hidden";
	document.all.select3.style.visibility="hidden";
}

function stopCount(num)
{
clearTimeout(num);
}

function fieldText(num){
	var field = document.getElementById(num);
	if(field.value == 'Keyword or Catalog Quick Shop'){
		field.value = "";
	}else if(field.value.length == 0){
		field.value = "Keyword or Catalog Quick Shop";
	}
}

function fieldText2(num){
	var field = document.getElementById(num);
	if(field.value == 'email@domain.com'){
		field.value = "";
	}else if(field.value.length == 0){
		field.value = "email@domain.com";
	}
}

function fieldTextClaimCode(num){
	var field = document.getElementById(num);
	if(field.value == 'Enter Promo Code'){
		field.value = "";
	}else if(field.value.length == 0){
		field.value = "Enter Promo Code";
	}
}

function fieldTextAcc(num){
	var field = document.getElementById(num);
	if(field.value == 'Enter Search Terms'){
		field.value = "";
	}else if(field.value.length == 0){
		field.value = "Enter Search Terms";
	}
}

function sharetoFacebook(){
	var href = location.href;
	var shareingHref;
	shareingHref = "http://www.facebook.com/sharer.php?u="+href+"";
	window.open(shareingHref,'','toolbar=0, resizable=yes, scrollbars=yes, status=0, width=800, height=600' );
}

function sharetoDigg(){
	var href = location.href;
	var shareingHref;
	shareingHref = "http://digg.com/submit?phase=2&url="+href+"";
	window.open(shareingHref,'','toolbar=0, resizable=yes, scrollbars=yes, status=0, width=800, height=600' );
}

function sharetoDelIcioUs(){
	var href = location.href;
	var shareingHref;
	shareingHref = "http://del.icio.us/post?v=4&noui&jump=close&url="+href+"";
	window.open(shareingHref,'','toolbar=0, resizable=yes, scrollbars=yes, status=0, width=800, height=600' );
}
				  
function hiddenSelect(node){
	var node = document.getElementById(node);
	if(node != null){
	node.style.visibility="hidden";
	}
}
			
function showSelect(node){
	var node = document.getElementById(node);
	if(node != null){
	node.style.visibility="visible";
	}
}

function loadPng(){
	DD_belatedPNG.fix('div');
	DD_belatedPNG.fix('.png, .menuPng');
}

function selectColorImgs(name, id) {
    anchors = document.getElementsByName(name);
    checkAnchor = document.getElementById(id);
    if(checkAnchor && anchors) {
        for(var i=0;i<anchors.length;i++) {
            anchor = anchors[i];
            var img = null;
            for(var j=0;j<anchor.childNodes.length;j++) {
                if(anchor.childNodes[j].tagName == 'IMG' || anchor.childNodes[j].tagName == 'img') {
                    img = anchor.childNodes[j];
                }
            }
            if(img != null) {
                if(anchor == checkAnchor) {
                    img.src = img.src.replace(/(_on)*.gif$/g, '_on.gif');
                    anchor.setAttribute('style', 'cursor:default;');
                }
                else {
                    img.src = img.src.replace(/_on.gif$/g,'.gif');
                    anchor.setAttribute('style', '');
                }
            }
        }
    }
}

function loadStar(input, divId) {
var image = 'star0_0.gif';

if (input < 0.25 ) image= 'star0_0.gif';
else if (input < 0.75) image= 'star0_5.gif';
else if (input < 1.25) image= 'star1_0.gif';
else if (input < 1.75) image= 'star1_5.gif';
else if (input < 2.25) image= 'star2_0.gif';
else if (input < 2.75) image= 'star2_5.gif';
else if (input < 3.25) image= 'star3_0.gif';
else if (input < 3.75) image= 'star3_5.gif';
else if (input < 4.25) image= 'star4_0.gif';
else if (input < 4.75) image= 'star4_5.gif';
else if (input <= 5.00 || input > 5.00) image= 'star5_0.gif';

document.getElementById(divId).innerHTML = '<img src="/imgs/product/rate/'+image+'" broder="0"/>';
}

function controlAllSelect(num){
	var check = num;
	var selectList = document.getElementsByTagName('select');
	var listLength = selectList.length;
	for(var a = 0; a < listLength; a++){
		if(check == 0){
		selectList[a].style.display = 'none';
		}else if(check == 1){
			selectList[a].style.display = 'inline';
		}
	}
	
}
                    
function Calendar(day, month, year, inputFieldId){
	var day = document.getElementById(day).value;
	var month = document.getElementById(month).value;
	var year = document.getElementById(year).value;
	var inputField = document.getElementById(inputFieldId);
	
	var input = ''+month+'/'+day+'/'+year+'';
	
	if (input.indexOf('m')>=0 && input.indexOf('d')>=0 && input.indexOf('y')>=0) {
		inputField.value = '01/01/' + ((new Date()).getFullYear() + 1);
	} else {
		inputField.value = input;
	}
}

function setCalendar(day, month, year, inputFieldId){
	var inputField = document.getElementById(inputFieldId).value.split('/');
	var dayValue = inputField[1];
	var monthValue = inputField[0];
	var yearValue = inputField[2];
	document.getElementById(day).value = dayValue;
	document.getElementById(month).value = monthValue;
	document.getElementById(year).value = yearValue;
}

function addInputSubmitEventLogin(input) {
	if(navigator.appName == "Microsoft Internet Explorer"){
		input.onkeydown = function(e) {
			e = e || window.event;
			if (e.keyCode == 13) {
				submitFormWithURL('loginFormPopup','popupForm','/cyberswim/includes/ajax/login.jsp');return false;
			}
		}
	}
}

function addInputSubmitEvent(form, input) {
    input.onkeydown = function(e) {
        e = e || window.event;
        if (e.keyCode == 13) {
            form.submit();
            return false;
        }
    }
}

function InputSubmit() {
    var forms = document.getElementsByTagName('form');

    for (var i=0;i < forms.length;i++) {
        var inputs = forms[i].getElementsByTagName('input');

        for (var j=0;j < inputs.length;j++)
            addInputSubmitEvent(forms[i], inputs[j]);
    }
}

function acceptTerms(checked) {
var notAccept = document.getElementById("notAcceptBtn");
var accept = document.getElementById("acceptBtn");

		if(checked==true){
			accept.style.display="block";
			notAccept.style.display="none";
		}else if(checked==false){
			accept.style.display="none";
			notAccept.style.display="block";
		}
	
} 