/*************************************************************************
  This code is from Dynamic Web Coding at dyn-web.com
  Copyright 2003-5 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function doTooltip(e, ar) {
	if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
	//var tip = document.getElementById( Tooltip.tipID );
	Tooltip.show(e, ar);
}

function hideTip() {
	if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
	Tooltip.hide();
}

// optional preloader 
var imageHandler = { 
	path:"images/", // path to images
	imgs:[], preload:function() { for(var i=0;arguments[i];i++) {
	var img=new Image(); img.src=this.path+arguments[i]; this.imgs[this.imgs.length]=img;}}
}

function collapseReview(id)
{
	var element_id = 'review_links_'+id;
	
	html = '<a onclick="expandReview(' + id + ')"><img class="expand_image" src="images/expand.jpg">&nbsp;Review</a>';
	document.getElementById(element_id).innerHTML=html;
	
	var element_id = 'review_'+id;
	document.getElementById(element_id).innerHTML='';
	
}

function expandReview(id)
{
	var xdoc;
		var element_id = 'review_links_'+id;
	
	html = '<a onclick="collapseReview(' + id + ')"><img class="collapse_image" src="images/collapse.jpg">&nbsp;Review</a>';
	document.getElementById(element_id).innerHTML=html;

	xmlFile = "scripts/php/gen_reviews_xml.php?id=" + id;
	if (document.implementation && document.implementation.createDocument)
	{
		xdoc = document.implementation.createDocument("", "", null);
		xdoc.load(xmlFile);

		xdoc.onload = function()
		{
			create_reviews_html(xdoc,id);
		}

	  return true;
		
	}
	else if (window.ActiveXObject)
	{
		xdoc = new ActiveXObject("Microsoft.XMLDOM");
		xdoc.async = false;
		xdoc.load(xmlFile);
		
		create_reviews_html(xdoc,id);

		return true;
	}
	else
	{
		alert('Your browser can\'t handle this script');
		return;
	}
}


function create_reviews_html(xmlDoc, id) {
	var html = '';
	var reviews = xmlDoc.getElementsByTagName('review');
	for (i = 0; i<reviews.length; i++) {
	
		var part_html = '<div class="review_content" style="padding-bottom: 20px; font-size: 11px; text-align: justify">' + reviews[i].getAttribute("review") + '</div>';
		html = html + part_html;
	}
	var element_id = 'review_'+id;
	document.getElementById(element_id).innerHTML=html;
}