// Javascript Document

//document.write('<div id="wait" style="position:absolute;top:0;left:0;width:100%;z-index:5;display:none;"><div id="wait-mask" class="wait-mask"></div><div style="background:transparent;position:absolute;z-index:6;" id="wait-message"><div id="productinfo"><div class="productinfotop"></div><div id="productinfomain"><div id="productcontent"><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/></div></div><div class="productinfobottom"></div></div></div></div>')

//document.getElementById('wait-mask').onclick = function(){hidePopup();return false}

if (document.getElementById && document.createTextNode) {
   var forms=document.getElementsByTagName('form');
   for (var i=0;i<forms.length;i++)
   {
   	forms[i].onsubmit = function(){pleaseWait();return true;}
   }
}

function getWindowWidth() {
	// Default to screen dimensions.
	var winW = window.screen.width;
	// Attempt to retrieve browser window dimensions.
	if (window.innerWidth)
	winW = window.innerWidth;
	else {
		if(document.documentElement.offsetWidth)
		winW = document.documentElement.offsetWidth;
		else if (document.body.offsetWidth)
		winW = document.body.offsetWidth;
	}
	return winW;
}

function getPopup() {
	javascript:document.getElementById('productcontent').innerHTML = 'thingy<br/><Br/><br/><br/>'
}

function showPopup() {

	
	// scroll position
	
	var  scrollY;
	if (document.all) {
		if (!document.documentElement.scrollTop)
			scrollY = document.body.scrollTop;
		else
			scrollY = document.documentElement.scrollTop; 
	}
	else {
		scrollY = window.pageYOffset; 
	}
	
	// Default to screen dimensions.
	var winH = window.screen.height;
	// Attempt to retrieve browser window dimensions.
	
	if (window.innerHeight)
		winH = window.innerHeight;
	else {
		if(document.documentElement.offsetHeight)
			winH = document.documentElement.offsetHeight;
		else if (document.body.offsetHeight)
			winH = document.body.offsetHeight }
	
	var wait = document.getElementById('wait');
	var message = document.getElementById('wait-message');
	message.style.left = '254px'
	//message.style.left = ((getWindowWidth()-644)/2)+'px';
	var temptop = scrollY-20
	if (temptop < 100){
		temptop = 105
	}
	message.style.top = temptop+'px';
	
	// hide all selects for IE
	var selects = document.getElementsByTagName("select");
	for(var i = 0; i < selects.length; i++) {
		selects[i].style.visibility = 'hidden';
	}
	
	// add flash animation - this is now done in page loading. See pleaseWait.jsp
	
//	var so = new SWFObject("flash/loader.swf", "waitflash", "340", "36", "6", "#FFF");
//	so.write("wait-flash");
	
		//set bg to height of document
	document.getElementById('wait-mask').style.height = document.body.offsetHeight + 'px';

	// make visible
	wait.style.display = '';
	
	
}

function hidePopup() {
	var wait = document.getElementById('wait');
	var message = document.getElementById('wait-message');
	
	// show all selects for IE
	var selects = document.getElementsByTagName("select");
	for(var i = 0; i < selects.length; i++) {
		selects[i].style.visibility = 'visible';
	}
	
	//if (Cart == 'True'){
	//	OnGetCart();
	//}
	//OnGetContent('smallcart','smallcart')
	// make visible
	wait.style.display = 'none';
}

function tableruler()
{
 if (document.getElementById && document.createTextNode)
  {
   var tables=document.getElementsByTagName('table');
   for (var i=0;i<tables.length;i++)
   {
    if(tables[i].className=='ruledtable')
    {
	 Ruler=true
     var trs=tables[i].getElementsByTagName('tr');
     for(var j=0;j<trs.length;j++)
     {
      if(trs[j].parentNode.nodeName=='TBODY' && trs[j].parentNode.nodeName!='TFOOT')
       {
	    trs[j].onmouseover=function(){this.className='ruled';return false}
	   	//trs[j].onclick=function(){alert('test');return false}
	   if (j%2==0){ 
			trs[j].className = 'ruleda'; 
			trs[j].onmouseout=function(){this.className='ruleda';return false}
			
		} else { 
			trs[j].className = 'ruledb';
			trs[j].onmouseout=function(){this.className='ruledb';return false}
		}
     }
    }
   }
  }
 }
 
 if (document.getElementById && document.createTextNode)
  {
   var tables=document.getElementsByTagName('ul');
   for (var i=0;i<tables.length;i++)
   {
    if(tables[i].className=='menu-posts'||tables[i].className=='menu-tagsonly')
    {
	 Ruler=true
     var trs=tables[i].getElementsByTagName('li');
     for(var j=0;j<trs.length;j++)
     {
      
	   //trs[j].onmouseover=function(){this.className='ruled';return false}
	   //trs[j].onclick=function(){showPopup();;return false}
	   if (j%2==0){ 
	   		if(trs[j].className=='checked'){
				trs[j].className = 'optionruledcheckeda'; 
				trs[j].onmouseout=function(){this.className='optionruledcheckeda';return false}
				trs[j].onmouseover=function(){this.className='optionruledchecked';return false}
			} else {
				trs[j].className = 'optionruleda'; 
				trs[j].onmouseout=function(){this.className='optionruleda';return false}
				trs[j].onmouseover=function(){this.className='optionruled';return false}
			}
			
		} else { 
			if(trs[j].className=='checked'){
				trs[j].className = 'optionruledcheckedb';
				trs[j].onmouseout=function(){this.className='optionruledcheckedb';return false}
				trs[j].onmouseover=function(){this.className='optionruledchecked';return false}
			} else {
				trs[j].className = 'optionruledb';
				trs[j].onmouseout=function(){this.className='optionruledb';return false}
				trs[j].onmouseover=function(){this.className='optionruled';return false}
			}
		}
     
    }
   }
  }
 }
 

 if (document.getElementById && document.createTextNode)
  {
   var tables=document.getElementsByTagName('ul');
   for (var i=0;i<tables.length;i++)
   {
    if(tables[i].className=='menu-categories')
    {
	 Ruler=true
     var trs=tables[i].getElementsByTagName('li');
     for(var j=0;j<trs.length;j++)
     {
      
	   //trs[j].onmouseover=function(){this.className='ruled';return false}
	   //trs[j].onclick=function(){showPopup();;return false}
	   if (j%2==0){ 
	   		if(trs[j].className=='checked'){
				trs[j].className = 'tagsruledcheckeda'; 
				trs[j].onmouseout=function(){this.className='tagsruledcheckeda';return false}
				trs[j].onmouseover=function(){this.className='tagsruledchecked';return false}
			} else {
				trs[j].className = 'tagsruleda'; 
				trs[j].onmouseout=function(){this.className='tagsruleda';return false}
				trs[j].onmouseover=function(){this.className='tagsruled';return false}
			}
			
		} else { 
			if(trs[j].className=='checked'){
				trs[j].className = 'tagsruledcheckedb';
				trs[j].onmouseout=function(){this.className='tagsruledcheckedb';return false}
				trs[j].onmouseover=function(){this.className='tagsruledchecked';return false}
			} else {
				trs[j].className = 'tagsruledb';
				trs[j].onmouseout=function(){this.className='tagsruledb';return false}
				trs[j].onmouseover=function(){this.className='tagsruled';return false}
			}
		}
     
    }
   }
  }
 }
}

var inputs;
var imgFalse = "_images/generic/unchecked.gif";
var imgTrue = "_images/generic/checked.gif";


function replaceChecks() {
 
	 //get all the input fields on the page
	 inputs = document.getElementsByTagName('input');

     //cycle trough the input fields
     for(var i=0; i < inputs.length; i++) {

		 //check if the input is a checkbox
		 if(inputs[i].getAttribute('type') == 'checkbox') {
			 //create a new image
			 var img = document.createElement('img');
	
			 //check if the checkbox is checked
			 if(inputs[i].checked) {
				 img.src = imgTrue;
			 } else {
				 img.src = imgFalse;
			 }
	 
			 //set image ID and onclick action
			 img.id = 'checkImage'+i;
	 
			 //set image
			 img.onclick = new Function('checkChange('+i+')');
	 
			 //place image in front of the checkbox
			 inputs[i].parentNode.insertBefore(img, inputs[i]);
	 
			 //hide the checkbox
			 inputs[i].style.display='none';
		}
      }
}


//change the checkbox status and the replacement image
function checkChange(i) {
	if(inputs[i].checked) {
	    inputs[i].checked = '';
        document.getElementById('checkImage'+i).src=imgFalse;
    } else {
        inputs[i].checked = 'checked';
        document.getElementById('checkImage'+i).src=imgTrue;
   }
}
