// JavaScript Document
function doComparisonFiltering()
{
	var checkBoxes 		= document.getElementsByTagName('input');
	var values 			= new Array();
	
		for(var i = 0; i < checkBoxes.length; i++)
		{
			if((checkBoxes[i].type == 'checkbox') && (checkBoxes[i].name.toString().match('foptionids')) && (checkBoxes[i].checked))
			{
				values.push('foptionids[]=' + checkBoxes[i].value);
			}
		}

	//alert('comparison.php?filtering_mode=1&' + values.concat(query_string).join('&'));
	
	document.location.href = 'comparison.php?find_in_all=1&filtering_mode=1&' + values.concat(query_string).join('&');
}

function popup(url, name, width, height) 
{
	var popup;
		popup = window.open(url, name, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, maximized=no, maximize=no, width=' + width + ',height=' + height + ', top=0, left=0');
		popup.focus();
}

function createNamedElement(type, name) 
{
   var element = null;
   
		if(BrowserDetect.browser == 'Explorer')
		{
		   // Try the IE way; this fails on standards-compliant browsers
		   try 
		   {
			  element = document.createElement('<'+type+' name="'+name+'">');
		   } 
		   catch(e) {}
		}
	
	   if(!element || element.nodeName != type.toUpperCase()) 
	   {
		  // Non-IE browser; use canonical method to create named element
		  element = document.createElement(type);
	   }
	   
	   return element;
}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	
	if(typeof window.onload != 'function')
	{
    	window.onload = func;
	} 
	else 
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

Object.prototype.extendOnChange = function(newOnChange)
{	
	var oldOnChange = this.onchange;
	
	if(typeof this.onchange != 'function')
	{
    	this.onchange = newOnChange;
	} 
	else 
	{
		this.onchange = function()
		{
			oldOnChange();
			newOnChange();
		}
	}
}


		// displays/hides a "processing" message

function processing(){
	var xy = getWindowCenter(this);
	var x = xy[0] - 200;
	var y = xy[1] - 60;
	var oContDiv = getStyleObj("processingDiv");
	var oPTbl = getStyleObj("processingTbl");

	if(oContDiv.display && oContDiv.display == 'none'){
		oContDiv.display='block';
		oContDiv.width = (getWindowWidth() -2) + 'px';
		oContDiv.height = document.body.scrollHeight + 'px';//(getWindowHeight() -2) + 'px';
		oContDiv.backgroundImage = "url(/shop/skin1/images/pix_semi_trans.gif)";
		oContDiv.position='absolute';
		oContDiv.top ='0px';
		oContDiv.left ='0px';
		//oContDiv.top= y + 'px';
		//oContDiv.left= x + 'px';
		oContDiv.visibility ='visible';

	}else{
		oContDiv.visibility='hidden';
		oContDiv.position='absolute';
		oContDiv.top ='0px';
		oContDiv.left ='0px';
		//oContDiv.top= y + 'px';
		//oContDiv.left= x + 'px';
		oContDiv.display='none';
	}

}

	// returns the x and y coordinates of the center of a window.
	function getWindowCenter(win)
	{
	  var w;
	  var x;
	  var coor = new Array();

	  if(win.document.body.clientHeight){
	    h = Math.round(win.document.body.clientHeight/2);
	    w = Math.round(win.document.body.clientWidth/2);
	  }else{
	    h = Math.round(win.innerHeight/2);
	    w = Math.round(win.innerWidth/2);
	  }
	  coor[0] = w;
	  coor[1] = h;
	  return coor;
	}

	function getWindowWidth() 
	{
		var win = window;
		var w = 800;
	  if(win.document.body.clientHeight){
	    w = Math.round(win.document.body.clientWidth);
	  }else{
	    w = Math.round(win.innerWidth);
	  }
		return w;
	}




	// get obj. by ID
/* already included inline
	function getObjByID(id)
	{
		if (document.getElementById) return document.getElementById(id);
		else if (document.all) return document.all[id];
		else if (document.layers) return document.layers[id];
		return null;
	}
*/
	// get the style object
	function getStyleObj(id){
		var obj = getObjByID(id);
		if(obj == null) return null;
		if(obj.style) return getObjByID(id).style;
		else return getObjByID(id);
	}

