// JavaScript Document
//-----------------------------------------------------------------------------
// Popups
	function  customPopup(w,h,cscroll,target)
	{
		return newPop('about:blank',w,h,cscroll,target)
	}
	
	function newPop(newurl,w,h,cscroll,target)
	{
		// check if scrollbars
		var ctarget = target ? target : 'custompopup';
		// check if scrollbars
		cscroll = cscroll ? 'yes' : 'no';
		// define characters
		var characters = "toolbar=no,scrollbars="+cscroll+",directories=no,status=no,menubar=no,resizable=no,width="+w+",height="+h;

		if (null != c_popup[ctarget])
		{
			if (false != c_popup[ctarget].closed)
			{
				c_popup[ctarget].close();
			}
			c_popup[ctarget] = null;
		}

		if ( !(c_popup[ctarget] = window.open(newurl, ctarget , characters)) )
		{
			alert(pop_alert_txt);
			return false;
		}
		else
		{
			c_popup[ctarget].focus();
			return true;
		}
	}

// flash popup
	function getUrlPop(url)
	{
		var caracters = "toolbar=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=no,width=600,height=480";
		if ( !(newwin = window.open(url,"flash",caracters)) )
		{
			alert(pop_alert_txt);
		}
		else
		{
			newwin.focus();
		}
	}
	
//-----------------------------------------------------------------------------
// Currency
	function popCurrency() {
		var filename = "http://www.xe.com/pca/input.cgi?AmountSet=1&FromSelect=EUR&ToSelect=GBP";
		var characters = "toolbar=no,scrollbars=no,directories=no,status=no,menubar=no,resizable=no,width=575,height=125";
		if (!window.open(filename,"currency",characters)) {
			alert(pop_alert_txt);
		}
	}

//-----------------------------------------------------------------------------
// change location

	function getDetail(id,c,sb,p,d)
	{
		var newloc = php_self+"?action=detail";
		newloc += 	"&pid="+id;
		if (c) 		newloc += "&c="+c;
		if (sb)		newloc += "&sb="+sb;
		if (p)		newloc += "&p="+p;
		if (d)		newloc += "&d="+d;
		window.location = newloc;
		return false;
	}

//-----------------------------------------------------------------------------
// switch image on detail

	function switchImage(img)
	{
		$('mainimg').src = img;
	}
	
//-----------------------------------------------------------------------------
// hide images on detail
	function showPhotos(c_id)
	{
		var gebi = $('photoSet_1','photoSet_2');
		if (null != c_id){c_set=c_id}else{c_set=(c_set==1)?0:1;}
		for (var i=0;i<gebi.length;i+=1)
		{
			if (null==gebi[i]){continue;}
			gebi[i].className = 'det_hide_photoset';
		}
		if (null!=gebi[c_set])
		{
			gebi[c_set].className = 'show_photoset';
		}
	}
	
//-----------------------------------------------------------------------------
// select selectedIndex
	this.setSelectedIndex = function(tar, svalue)
	{
		for (var i=0;i<tar.options.length;i+=1)
		{
			if (svalue == tar.options[i].value)
			{
				tar.selectedIndex = i;
				break;
			}
		}
	}
	
//-----------------------------------------------------------------------------
// getElementById workaround from prototype.js  *  (c) 2005 Sam Stephenson <sam@conio.net>
	function $()
	{
		var elements = new Array();
		for (var i=0; i < arguments.length; i+=1)
		{
			var element = arguments[i];
			if (typeof element == 'string')
			{
				element = document.getElementById(element);
			}
			if (arguments.length == 1) 
			{
				return element;
			}
			elements.push(element);
		}
		return elements;
	}
	
//-----------------------------------------------------------------------------
// add eventlistener workaround from Andrew LePera (with some changes)
	function addEvent(obj, evType, fn, useCapture)
	{
		if (obj.addEventListener)
		{
			obj.addEventListener(evType, fn, useCapture);
			return true;
		}
		else if (obj.attachEvent)
		{
			return obj.attachEvent("on"+evType, fn);
		}
		else
		{
			return false;
		}
	}
	
//-----------------------------------------------------------------------------
// Currency
	function popCurrency() {
		var filename = "http://www.xe.com/pca/input.cgi?AmountSet=1&FromSelect=EUR&ToSelect=GBP";
		var characters = "toolbar=no,scrollbars=no,directories=no,status=no,menubar=no,resizable=no,width=575,height=125";
		if (!window.open(filename,"currency",characters)) {
			alert(pop_alert_txt);
		}
	}

