/*
  $Id: hokohoko.js,v 1.0 2006/02/25 17:00:00 

	HOKOHOKO.com, Online-Shop
	http://www.hokohoko.com
  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
*/


function uncheck_all(nosubmit){
	

	
		for(var i=0;i<document.tagform.length;++i) {
			if (document.tagform.elements[i].type == "checkbox"){
				document.tagform.elements[i].checked = false;
			}
			if (document.tagform.elements[i].type == "text"){

					document.tagform.elements[i].value="";
				
			}	
			if (document.tagform.elements[i].type == "hidden"){
				//alert(document.tagform.elements[i].name);
				if(document.tagform.elements[i].name != "osCsid"){
					document.tagform.elements[i].value="";
				}
			}					
		}
		
		document.tagform.WOODSTOCK.value ="true";	
		if (document.tagform.manufacturers_id){
			document.tagform.manufacturers_id.selectedIndex = 0;
		}


		if(nosubmit == true){
			
		}else{
			get_down(document.getElementById('tagform'));
		}


}






var http_request = false;
function makeRequest(url, parameters) {
   http_request = false;
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) {
      	// set type accordingly to anticipated content type
         //http_request.overrideMimeType('text/xml');
         http_request.overrideMimeType('text/html');
      }
   } else if (window.ActiveXObject) { // IE
      try {
         http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
         try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (e) {}
      }
   }
   if (!http_request) {
      alert('Cannot create XMLHTTP instance');
      return false;
   }
   http_request.onreadystatechange = alertContents;
   http_request.open('GET', url + parameters, true);
   http_request.send(null);
}

function alertContents() {
   if (http_request.readyState == 4) {
      if (http_request.status == 200) {
         //alert(http_request.responseText);
         result = http_request.responseText;
         document.getElementById('ajax_loading').innerHTML = result;   
         
			$('#lollypop').html("");
			document.getElementById("ajax_loading_bar").style.height = "0px";
			document.getElementById("ajax_loading_bar").style.width = "0px";
			document.getElementById("ajax_loading_bar").style.border = "solid 0px";
			document.getElementById("ajax_loading_bar").style.backgroundImage='';		
			
			//$('#googleadd').load("banner.php?typ=google");
   
      } else {
         alert('There was a problem with the request.');
      }
   }
}


function alertSize() {
	  var myWidth = 0, myWidth = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }
	  
	  var scrOfX = myWidth, scrOfY = myWidth;
	  if( typeof( window.pageYOffset ) == 'number' ) {
	    //Netscape compliant
	    scrOfY += window.pageYOffset;
	    scrOfX += window.pageXOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	    //DOM compliant
	    scrOfY += document.body.scrollTop;
	    scrOfX += document.body.scrollLeft;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	    //IE6 standards compliant mode
	    scrOfY += document.documentElement.scrollTop;
	    scrOfX += document.documentElement.scrollLeft;
	  }	  
	  
	  
	 // window.alert( 'Width = ' + scrOfX );
	 // window.alert( 'Height = ' +scrOfY );
	  return scrOfY;
	}



function get_down(obj) {
	document.tagform.THEMENSUCHE.value='';
	if(document.tagform.sortieren.value=='editor'){
		document.tagform.sortieren.value='aktualitaet_d';
	}

	return get(obj);
}

function get(obj) {
	
	// ladegrafik
	alertSize();
	document.getElementById("ajax_loading_bar").style.height = alertSize() + "px";
	document.getElementById("ajax_loading_bar").style.width = screen.width + "px";
	document.getElementById("ajax_loading_bar").style.border = "solid 1px";
	document.getElementById("ajax_loading_bar").style.backgroundImage='url(images/ajax-loader-bg.png)';
	$('#lollypop').html("<img src='images/ajax-loader.gif'>");	
	    


	
	
   var getstr = "?";
   for (i=0; i<obj.childNodes.length; i++) {
	   
	   

	   
	   if (obj.childNodes[i].tagName == "UL") {
		   tag_boxen_li = obj.childNodes[i].getElementsByTagName("li");
		   for (z=0; z<tag_boxen_li.length; z++) {
			   


			   //alert(tag_boxen_li[z].firstChild.firstChild.id);
			   tagbox = tag_boxen_li[z].firstChild.firstChild;
			   if (tagbox.type == "checkbox") {
		            if (tagbox.checked) {
		               getstr += tagbox.name + "=" + tagbox.value + "&";
		            } 
		         }					   
		   }
	   }   
	   
	   
		  if (obj.childNodes[i].tagName == "DIV") {
			  boxen_input = obj.childNodes[i].getElementsByTagName("input");
			  for (z=0; z<boxen_input.length; z++) {
				  	if (boxen_input[z].type == "text") {
			            getstr += boxen_input[z].name + "=" + boxen_input[z].value + "&";
			         }
				  
			  }	  
			  boxen_select = obj.childNodes[i].getElementsByTagName("SELECT");
			  for (z=0; z<boxen_select.length; z++) {
			  if (boxen_select[z].type == "select-one") {
			         var sel = boxen_select[z];
			         getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
			      }
			  
			  }
			  
		
			  
			  
				   boxen_col = obj.childNodes[i].getElementsByTagName("td");
				   for (z=0; z<boxen_col.length; z++) {
					   col = boxen_col[z].firstChild;
					   if (col.type == "checkbox") {
				            if (col.checked) {
				               getstr += col.name + "=" + col.value + "&";
				            } 
				         }					   
				   }
			   			  
			  
			  
			  
		  }	   
	   
	   
	   
	   
	   
	   
      if (obj.childNodes[i].tagName == "INPUT") {
         if (obj.childNodes[i].type == "text") {
            getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
         }
         if (obj.childNodes[i].type == "hidden") {
             getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
          }         
         if (obj.childNodes[i].type == "checkbox") {
            if (obj.childNodes[i].checked) {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            } else {
               getstr += obj.childNodes[i].name + "=&";
            }
         }
         if (obj.childNodes[i].type == "radio") {
            if (obj.childNodes[i].checked) {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
         }
      }   
      if (obj.childNodes[i].tagName == "SELECT") {
         var sel = obj.childNodes[i];
         getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
      }
      
   }
   makeRequest('woodstock_search.php', getstr);
}





function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}


addLoadEvent(function () {
	initChecklist();
});

function initChecklist() {
	if (document.all && document.getElementById) {
		// Get all unordered lists
		var lists = document.getElementsByTagName("ul");
		
		for (i = 0; i < lists.length; i++) {
			var theList = lists[i];
			
			// Only work with those having the class "checklist"
			if (theList.className.indexOf("checklist") > -1) {
				var labels = theList.getElementsByTagName("label");
				
				// Assign event handlers to labels within
				for (var j = 0; j < labels.length; j++) {
					var theLabel = labels[j];
					theLabel.onmouseover = function() { this.className += " hover"; };
					theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
				}
			}
		}
	}
}



function show_ssk2(){
	 $("div.ssk_1").find("div.sec:hidden").show();	
	 $("div.ssk_1").find("div.first:visible").hide();
	 $("div.ssk_1").find("div.third:visible").hide();	 
	 $("div.ssk_1").find("div.fourth:visible").hide();	 
} 
function show_ssk3(){
	 $("div.ssk_1").find("div.third:hidden").show();
	 $("div.ssk_1").find("div.first:visible").hide();
	 $("div.ssk_1").find("div.sec:visible").hide();	
	 $("div.ssk_1").find("div.fourth:visible").hide();	 	 
} 

function show_ssk4(){
	 $("div.ssk_1").find("div.first:visible").hide(); 
	 $("div.ssk_1").find("div.sec:visible").hide();
	 $("div.ssk_1").find("div.third:visible").hide();	
	 $("div.ssk_1").find("div.fourth:hidden").show();	 	 	 
} 
