/**
 *  Changes made to this javascript file see ticket:27 for more info. Peter.E 17.04.2007
 * 
 *
 *
 */





/*function product_rollover(PhotoId,ContentId)
{
	//alert("product_rollover");
	
	if(PhotoId == "")
	{
		PhotoId = "prod_default.gif";
	}	
	
	$('product_photo').src='/images/prod_listing/' + PhotoId;
	

	$$('.prodcontent').each(
		function(val)
		{
			val.setStyle( { display: 'none' } );
		}
	);
	
	if('' != ContentId)
	{
		$('prod_content'+ContentId).setStyle( { display: 'block' } );
	}
	
	
	
	element = $('press_listing_issue').getElementsByTagName('div');
		
	$A(element.childNodes).each(function(element) {
  			element.setStyle({display: 'none'});
		});


}*/

function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

/**
 * 
 * @param string PhotoId the image src to update the product src preview with
 * @param string ContentId The product id the user has hovered over
 * @param Event event A javascript Event object
 */
function product_rollover2(PhotoId, ContentId, event)
{
	
	// move the div
	
	if( !event ) { event = window.event; }
  	if( !event ) { //in the worst case we cant get the event object so report an error?
  				   window.alert("Cant perform product_rollover2() as cant get Event."); return; }
	
  			//	   if(!$('debugbox')) {
  			//	   	$('press_listing_issue').innerHTML =  '<div id="debugbox" style="display:block;">DEBUG</div>' + $('press_listing_issue').innerHTML;
  			//	   }

	/**
	 * Ok this is nasty and ideally id like to remove all of the is IE 5.5 stuff here
	 * and simply use prototype but.... for some reason the prototype code doesnt work in 
	 * IE 5.5 but... it does work in 6 and 7, Firefox and Safari! So here is the dirty hack to
	 * get it to work! :-( 
	 * If prototype works with IE 5.5 in the future i guess we can remove this or
	 * if a clever developer knows how to get around this using prototype?
	 *
	 * Peter E 18.04.2007
	 */
	
	//Detect IE5.5+

    	var x = document.getElementsByTagName('div');
		for (var i=0;i<x.length;i++)
		{
			if (x[i].className == "prodcontent")
			{
				//alert(x[i].className);
				x[i].style.display = 'none';
			}
		}
		
		if('' != ContentId)
		{
			document.getElementById('prod_content'+ContentId).style.display = 'block';
		}


	
	//alert(getCursorPosition(event));

	var MouseYPos = getCursorPosition(event);
	
	
	document.getElementById('press_listing_issue').style.left = "0";
	
	//var spaceAbove = 0;// amount of space above the visible space
	var spaceAbove = getScrollingPosition();	
	
	var spaceAbove = getScrollingPosition();// + 00 - 0*(getCursorPosition(event) - getScrollingPosition()) ;	
	
	var pos = parseInt(spaceAbove+50);
	
	//$('debugbox').innerHTML = "getCursorPosition(event) = "+getCursorPosition(event)+"   getScrollingPosition() = "+getScrollingPosition();
	
	if(pos>0)
	{
		document.getElementById('press_listing_issue').style.top = pos + "px";
	}
	
	if(spaceAbove==0)
	{
		document.getElementById('press_listing_issue').style.top = 0;
	}
	
	
	
	if(PhotoId == "")
	{
		var PhotoId = "/images/prod_listing/prod_default.gif";
	}

	document.getElementById('product_photo').src = '' + PhotoId;



}

/*
//Safari Browser Check
//This should now be redundant! 17.04.2007 See trac ticket:27
function IsSafari()
{
	var agt=navigator.userAgent.toLowerCase();
   	var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
    return is_safari;
}


//Konqueror Browser Check
//This should now be redundant! 17.04.2007 See trac ticket:27
function IsKhtml()
{
	var agt=navigator.userAgent.toLowerCase();
   	var is_khtml  = (is_safari || is_konq);
   	return is_khtml;
		
}*/

function getScrollingPosition()
{
	  //alert("getScrollingPosition");	
		
	 var position = [0, 0];
	
	 if (typeof window.pageYOffset != 'undefined')
	 {
	   position = window.pageYOffset;
	
	 }
	 else if (typeof document.documentElement.scrollTop
	     != 'undefined' && document.documentElement.scrollTop > 0)
	 {
	   position =  document.documentElement.scrollTop;
	 }
	
	 else if (typeof document.body.scrollTop != 'undefined')
	 {
	   position =  document.body.scrollTop;
	 }
//return 0;
	 return position;
}


/**
 *
 * @param Event e We are expecting here a javascipt model 'Event' object
 * @return int the Y coord for the mouse position
 */
function getCursorPosition(e)
{

	var mouseX = e.pageX,
        mouseY = e.pageY; 	
        
	return mouseY; //we only want the Y coord for the mouse

}

