var dom = (document.getElementById)? true : false;
var nn4 = (document.layers)? true : false;
var ie4 = (!dom && document.all)? true : false;
var opr = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
function initSearch() {
	document.frmsearch.srchstring.value=search;
}
var languages =  new Array();
function olanguage(id, name)
{
this.id = id;
this.name = name;
}
function loadLanguages()
{
for (var i=0;i<languages.length;i++) 
{
	if (languages[i].id==parseInt(language))
		{
			document.writeln('<OPTION value="' + languages[i].id + '" SELECTED>' + languages[i].name);
		}
		else
		{
			document.writeln('<OPTION value="' + languages[i].id + '">' + languages[i].name);
		}
	}
}
var filters =  new Array();
function ofilter(name)
{
	this.name = name;
}
function loadFilters()
{
	for (var i=0;i<filters.length;i++) 
	{
		if (filters[i].name==filter)
		{
			document.writeln('<OPTION value="' + filters[i].name + '" SELECTED>' + filters[i].name);
		}
		else
		{
			document.writeln('<OPTION value="' + filters[i].name + '">' + filters[i].name);
		}
	}
}
function loadCounts()
{
	var html = '';
	html += (count==4) ?  '<OPTION value="4" SELECTED>' + captionPage4 : '<OPTION value="4">' + captionPage4;
	html += (count==10) ? '<OPTION value="10" SELECTED>' + captionPage10 : '<OPTION value="10">' + captionPage10;
	html += (count==20) ? '<OPTION value="20" SELECTED>' + captionPage20 : '<OPTION value="20">' + captionPage20;
	html += (count==50) ? '<OPTION value="50" SELECTED>' + captionPage50 : '<OPTION value="50">' + captionPage50;
	document.writeln(html);
}
function loadViews()
{
	var html = '';
	html += (view==0) ?  '<OPTION value="0" SELECTED>' + captionViewIcons : '<OPTION value="0">' + captionViewIcons;
	html += (view==1) ?  '<OPTION value="1" SELECTED>' + captionViewList : '<OPTION value="1">' + captionViewList;
	document.writeln(html);
}
function loadMenu()
{
	var html = '' +
	'<NOBR>' +
	'<A href=javascript:changePage("basket") TITLE="' + captionBasket + '"><IMG SRC="' + http + 'images/menu_basket.gif" WIDTH="26" HEIGHT="21" BORDER="0" VSPACE="5" HSPACE="1"></A>' +
	'<A href=javascript:changePage("help") TITLE="' + captionHelp + '"><IMG SRC="' + http + 'images/menu_help.gif" WIDTH="26" HEIGHT="21" BORDER="0" VSPACE="5" HSPACE="8"></A>' + 
	'<A href=javascript:changePage("faq") TITLE="' + captionFAQ + '"><IMG SRC="' + http + 'images/menu_faq.gif" WIDTH="26" HEIGHT="21" BORDER="0" VSPACE="5" HSPACE="1"></A>' +
	'<A href=javascript:changePage("contacts") TITLE="' + captionContacts + '"><IMG SRC="' + http + 'images/menu_mailus.gif" WIDTH="26" HEIGHT="21" BORDER="0" VSPACE="5" HSPACE="8"></A>' +
	'</NOBR>';
	document.write(html);
}

function changeSettings()
{
	self.document.location = 'http://' + location.hostname + location.pathname + "?category=" + category + "&language=" + document.frmsettings.language[document.frmsettings.language.selectedIndex].value + "&count=" + document.frmsettings.count[document.frmsettings.count.selectedIndex].value + "&view=" + document.frmsettings.view[document.frmsettings.view.selectedIndex].value + "&start=0&root=" + root + "&srchstring=" + srchstring + "&filter=" + filter;
}
function changeFilter()
{
	self.document.location = 'http://' + location.hostname + location.pathname + "?category=" + category + "&language=" + document.frmsettings.language[document.frmsettings.language.selectedIndex].value + "&count=" + document.frmsettings.count[document.frmsettings.count.selectedIndex].value + "&view=" + document.frmsettings.view[document.frmsettings.view.selectedIndex].value + "&start=0&root=" + root + "&srchstring=" + srchstring + "&filter=" + document.frmfilter.filter[document.frmfilter.filter.selectedIndex].value;
}
function changePage(page)
{
	self.document.location = page + ".php?language=" + document.frmsettings.language[document.frmsettings.language.selectedIndex].value + "&count=" + document.frmsettings.count[document.frmsettings.count.selectedIndex].value + "&view=" + document.frmsettings.view[document.frmsettings.view.selectedIndex].value;
}
function productInfo(id)
{
	self.document.location = 'product.php?category=' + category + '&id=' + id + '&language=' + language + '&count=' + count + '&view=' + view;
}
function getSearch()
{
	self.document.location = 'search.php?srchstring=' + document.frmsearch.srchstring.value + '&language=' + document.frmsettings.language[document.frmsettings.language.selectedIndex].value + '&count=' + document.frmsettings.count[document.frmsettings.count.selectedIndex].value + '&view=' + document.frmsettings.view[document.frmsettings.view.selectedIndex].value;
}
function toBasket(id)
{
	openWindow('tobasket','tobasket.php?actions=add&id=' + id + '&language=' + language,0,0,0,0,0,0,0,0,0,400,300,100,100);
}
function viewBasket(action)
{ 
	document.frmbasket.action = (document.frmbasket.step.value == 1) ? "basket.html" : "nextstep.html";
	document.frmbasket.actions.value = action;
	document.frmbasket.submit();
}
function objImage(imgName,imgOff,imgOn) 
{
	this.name = imgName;
	this.offImgObject = loadImage(imgOff);
	this.onImgObject  = loadImage(imgOn);
	this.on  = imageOn;
	this.off = imageOff;
	this.statuson  =  false;
}
function imageOn()
{
	document[this.name].src = this.onImgObject.src;
	this.statuson = true;
}
function imageOff()
{
	document[this.name].src = this.offImgObject.src;
	this.statuson = false;
}
function loadImage(imgSrcName)
{
	imgObject = new Image()
	imgObject.src = imgSrcName;
	return imgObject;
}
function openWindow(winName,winURL,winFullScreen,winChannelMode,winToolBar,winLocation,winDirectories,winStatus,winMenubar,winScrollbars,winResizable,winWidth,winHeight,winTop,winLeft)
{
var winFeatures  = "fullscreen=" + winFullScreen + "," + "channelmode=" + winChannelMode + "," + "toolbar=" + winToolBar + "," + "location=" + winLocation + "," + "directories=" + winDirectories + "," + "status=" + winStatus + "," + "menubar=" + winMenubar + "," + "scrollbars=" + winScrollbars + "," + "resizable=" + winResizable + "," + "width=" + winWidth + "," + "height=" + winHeight + "," + "top=" + winTop + "," + "left=" + winLeft + ",";
	var winName = window.open(winURL,winName,winFeatures);
}
function viewPicture(id) 
{ 
	openWindow("picture","winimgresize.php?id=" + id + '&language=' + language,0,0,0,0,0,0,0,0,1,100,100,50,50); 
}
function loadSpan(name,info) 
{ 
	if (dom) eval('document.getElementById("' + name + '").innerHTML = info;');
	else if (ie4 || opr) eval('document.all["' + name + '"].innerHTML = info;');
}
var today = new Date();
var expiryyear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
var expirymonth = new Date(today.getTime() + 30 * 24 * 60 * 60 * 1000);
var expiryday = new Date(today.getTime() + 24 * 60 * 60 * 1000);
function getCookieVal(offset) 
{
	var endstr = document.cookie.indexOf(";", offset);
	if(endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
}
function getCookie(name) 
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while(i < clen) 
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) 
		{
			return getCookieVal (j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return null;
}
function deleteCookie(name,path,domain) 
{
	if (getCookie(name)) 
	{
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
function setCookie(name,value,expires,path,domain,secure) 
{
  document.cookie = name + "=" + escape (value) +
   ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
var randomNoveltyInfo = '';
function randomNovelty(id,name,vendor,description,picture)
{
	randomNoveltyInfo = '' + 
			'<TABLE width="190" border="0" cellspacing="0" cellpadding="7" bgcolor="#fcfff0">' +
			'<TR>' +
			'	<TD width="190" align="left" valign="top" class="blue11"><B>' + name + '</B><BR>' + vendor + '</TD>' +
			'</TR>' +
			'<TR>' +
			'	<TD width="190" align="left" valign="top" class="gray11">';	
	randomNoveltyInfo += (picture==0) ? '<A href="product.php?category=' + category + '&id=' + id + '&language=' + language + '&count=' + count + '&view=' + view + '" TITLE="' + description + '"><IMG SRC="' + http + 'thumbnail.php?id=' + id + '&language=' + language + '" BORDER="0" VSPACE="8" ALIGN="top"></A>' : '<A href="#" TITLE="' + description + '"><IMG SRC="' + http + 'images/nogoodsimage.gif" BORDER="0" VSPACE="8" ALIGN="top"></A>';
	randomNoveltyInfo += '' + 
			'<A href="product.php?category=' + category + '&id=' + id + '&language=' + language + '&count=' + count + '&view=' + view + '"><IMG SRC="' + http + 'images/btninfo.gif" WIDTH="18" HEIGHT="16" BORDER="0"  HSPACE="6" VSPACE="8"></A><BR>' + description + '</TD>' +
			'</TR>' +
			'</TABLE>';
}
function showRandom()
{
	document.write(randomNoveltyInfo);
}




