/*
*	Version 1
*	Author Isabel Ralph/Jim Coll
*	Created 01 June 2005
*	Last Modified: 14 Jan 2007
*/


	// park_auctioner_new.js
	var choice;
	var appVer=parseInt(navigator.appVersion);		
	var isNC=false,isN6=false,isIE=false;
	if (document.all && appVer >= 4) isIE=true; else
	if (document.getElementById && appVer > 4) isN6=true; else
	if (document.layers && appVer >= 4) isNC=true;	
	
	var counter=1;
	
	// Array to store menu status
	menu_status = new Array();
	
	// Displays sub menu items
	
	function showHide(theid){
	    if (document.getElementById) {
	    var switch_id = document.getElementById(theid);
	
	        if(menu_status[theid] != 'show') {
	           switch_id.className = 'show';
	           menu_status[theid] = 'show';
	        }else{
	           switch_id.className = 'hide';
	           menu_status[theid] = 'hide';
	        }
	    }
	}

	
	
	//Swapping classes for menu highlighting	
	function ChangeClass(menu, newClass) 
	{ 
	 	if (document.getElementById) { 
	 		document.getElementById(menu).className = newClass;
	 	} 
	} 
	//Swapping classes for menu highlighting	
	function BackToSales() 
	{ 
	 	var x=document.getElementById("COUNTRY");
		alert(x.innerHTML);
		if (x.innerHTML == "Slovenia")
		{
		location.href="overseas_sales2_slovenia.html";
		}
		else if (x.innerHTML == "Germany")
		{
			location.href="overseas_sales2_germany.html";
		}
		else
		{
			location.href="sales2_keep.html";
		}
		document.write(location.href);
	}
	 	
		
	//function loadXML(file_loc, xml_file, xml_part)
	function loadXML(url, make_table, xml_file, xml_part, counter)
	{		
		if (isIE)
		{		
			var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async="false";
			xmlDoc.load(url);
			make_table(xmlDoc, url, xml_file, xml_part, counter);
		}
		else
		{
		// user the standard DOM Level 2 technique, if it is supported
		if (document.implementation && document.implementation.createDocument){
		//create a new document object
			var xmlDoc=document.implementation.createDocument("","",null);
			//specify what should happen wht it finishes loading				
			xmlDoc.onload = function() {make_table(xmlDoc, url, xml_file, xml_part, counter);}
			//and tell it what url to load
			xmlDoc.load(url);								
		}
		}		
	}
	
	function loadXMLbyID(url,xml_file, xml_part, counter)
	{		
		if (isIE)
		{		
			var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async="false";
			xmlDoc.load(url);
			make_table_byID(xmlDoc, url, xml_file, xml_part, counter);
		}
		else
		{
		// user the standard DOM Level 2 technique, if it is supported
		if (document.implementation && document.implementation.createDocument){
		//create a new document object
			var xmlDoc=document.implementation.createDocument("","",null);
			//specify what should happen wht it finishes loading				
			xmlDoc.onload = function() {make_table_byID(xmlDoc, url, xml_file, xml_part, counter);}
			//and tell it what url to load
			xmlDoc.load(url);								
		}
		}		
	}
	
	
	
	function make_table(xmlDoc, url, xml_file, xml_part, counter)
	{
		//var index=0;		
		if (isIE)
		{			
			populate_table(xmlDoc, xml_part, counter);				

		}			
		else{
			
			populate_table_ns(xmlDoc, xml_part, counter);

		}
		
	}

	function make_table_byID(xmlDoc, url, xml_file, xml_part, counter)
	{
		//var index=0;		
		if (isIE)
		{			
			populate_table_byID(xmlDoc, xml_part, counter);				

		}			
		else{
			
			populate_table_ns(xmlDoc, xml_part, counter);

		}
		
	}

	
	function populate_table_ns(xmlDoc, containerTag, index)
	{
		var elem;
		var picvalue ="";
		var rawData = xmlDoc.getElementsByTagName(containerTag)[index];				
		var tagnumber = rawData.getElementsByTagName("*").length;
			
		for(i=0;i<tagnumber;i++)
		{
			var namestring = rawData.getElementsByTagName("*")[i].nodeName;
			var oneRecord = rawData.getElementsByTagName("*")[i];
			
			if(namestring == "PICTURE_1"|namestring=="PICTURE_2"||namestring=="PICTURE_3")
			{
					if (oneRecord.firstChild.nodeValue.length < 8)
					{
						picvalue = "<p> </p>" //DO NOTHING
					}
					else
					{
						//alert("Picture:" +picvalue);
						picvalue= "<div ><IMG src=\"" + oneRecord.text + "\" border=1 width=220 height=160></div>";
					}
					elem = document.getElementById(namestring);			
					elem.innerHTML = picvalue;
			} //if
			else 
			{
					try{			
						elem = document.getElementById(namestring);			
						elem.innerHTML = oneRecord.firstChild.nodeValue;//oneRecord.firstChild.data;
					}
					catch (e){
						elem.innerHTML ="";
					}
			} //else
		} //for
	}	
	
	function populate_table(xmlDoc, containerTag, index)//ie
	{
		var elem;
		var picvalue = "";						
		var rawData = xmlDoc.getElementsByTagName(containerTag)[index];
		var tagnumber = rawData.childNodes.length;
		
		for (i = 0; i < tagnumber ;i++)
		{			
			namestring = rawData.childNodes[i].nodeName;			
			picvalue = "";
			oneRecord = rawData.childNodes[i];
					
			if(namestring == "PICTURE_1"|namestring=="PICTURE_2"||namestring=="PICTURE_3")
			{
				if (oneRecord.text.length < 8)
				{
					picvalue= "<p> </p>" //DO NOTHING
					//alert("no picture");
				}
				else
				{
					picvalue= "<div ><IMG src=\"" + oneRecord.text + "\" border=1 width=220 height=160></div>";
					//alert("Picture:" +picvalue);
				}
					elem = document.getElementById(namestring);			
					elem.innerHTML = picvalue;
			}
			else 
			{
				try{			
						elem = document.getElementById(namestring);		
						elem.innerHTML = oneRecord.text;
				}
				catch (e) {
				}
			}		
			
		}					
	}
	
	function populate_table_byID(xmlDoc, containerTag, id)//ie
	{
		var elem;
		var picvalue = "";	
		var index=0;
		var prop_id = "";					
		
		var propertyindex = xmlDoc.getElementsByTagName("PROPERTYID");
		for (i=0; i < propertyindex.length; i++) 
		{
			prop_id = propertyindex.item(i).text;
			if (prop_id == id)
			{
				index = i;
			}
		}
		
		var rawData = xmlDoc.getElementsByTagName(containerTag)[index];
		var tagnumber = rawData.childNodes.length;
		var detailstring = ""
		
		for (i = 0; i < tagnumber ;i++)
		{			
			namestring = rawData.childNodes[i].nodeName;			
			picvalue = "";
			oneRecord = rawData.childNodes[i];
			if(namestring == "PICTURE_1"|namestring=="PICTURE_2"||namestring=="PICTURE_3")
			{
				if (oneRecord.text.length < 8)
				{
					picvalue= "<p> </p>" //DO NOTHING
					//alert("no picture");
				}
				else
				{
					picvalue= "<div ><IMG src=\"" + oneRecord.text + "\" border=1 width=220 height=160></div>";
					//alert("Picture:" +picvalue);
				}
					elem = document.getElementById(namestring);			
					elem.innerHTML = picvalue;
			}
			else if( namestring.substring(0,7) == "DETAILS")
			{
				//alert("Found DETAILS");
				elem = document.getElementById("DETAILS");
				//alert("InnerHTML: " + elem.innerHTML);
				elem.innerHTML = elem.innerHTML + "<br></br>" + oneRecord.text;
			}
			else 
			{
				
				elem = document.getElementById(namestring);			
				elem.innerHTML = oneRecord.text;
			}	
		}					
		
	}

	
							