if (top != self) top.location.href = location.href;

function openLagerImage(path){
	var winl = (screen.width - 400) / 2;
	var wint = (screen.height - 600) / 2;
	newWindow = window.open('','','height=400,width=600,top='+wint+',left='+winl+',scrollbars=no,resizable=yes');
	newWindow.document.open();
	var content = "<html><head><script>var isNav4, isIE4; if (parseInt(navigator.appVersion.charAt(0)) >= 4) { isNav4 = (navigator.appName == \'Netscape\') ? 1 : 0; isIE4 = (navigator.appName.indexOf(\'Microsoft\') != -1) ? 1 : 0; }";
	content += "function fitWindowSize() { if (isNav4) {window.innerWidth = document.images[0].width; window.innerHeight = document.images[0].height; } if (isIE4) { window.resizeTo(500, 500); width = 500 - (document.body.clientWidth -  document.images[0].width); height = 500 - (document.body.clientHeight -  document.images[0].height); window.resizeTo(width, height); } } </script>";
	content += "<BODY onLoad=\'fitWindowSize()\'><div style=\'position:absolute; left:0px; top:0px\'>";
	content += "<img src=\'"+path+"\' border=0></div></body></html>";
	newWindow.document.write(content);
	newWindow.document.close();
	return false;
}

function buildRvi(count, _count, ar){
	if (ar.length == 0 || ar.length - _count == 0 || (ar.length == 1 && nodeid == ar[0].id))
		return "";
	var str = _buildRviStart();
	for(var i=_count, y=0; i< ar.length; i++){
		if (nodeid == ar[i].id){
			continue;
		}
		str += _buildRvi(count, ar[i]);
		y++;
		if (y >= count)
			break;
	}
	str += _buildRviEnd();
	return str;
}


function _buildRvi(count, prod){
	if (count == 0) return "";	
	var width = 100/count;
	 width = parseInt(width);
	var content = '<td class="itemlist" width="'+width+'%">';
	if (prod.img.length > 0){
		content +='<a href="'+prod.url+'">';
		content +='<img src="'+prod.img+'" alt="' + prod.title + '"';
		if (prod.width > 0)
			content +=' width="'+prod.width+'"';
		if (prod.height > 0)
			content +=' height="'+prod.height+'"';
		content +=' border="0"></a>';
	}
	content +='<br>';
	content +='<a href="'+prod.url+'"class="prodlink">';
	content +=prod.title+'</a><br>';
    content +='<span class="pricesmall">$'+prod.price+'</span>';
	content +='</td>';
	return content;
}

function _buildRviStart(){
	return '<div class="simple-table-line"></div>' +
			'<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">'+
	        '<tr>' +
            '<td class="simple-table-header">Recently Viewed</td>'+
        	'</tr>'+
	        '<tr>' +
            '<td class="simple-table-body"><table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">';
}

function _buildRviEnd(){
	return '</table></td></tr></table>';

}

function onFocusSearch(ctrl, msg){
	if (ctrl.value == msg)
		ctrl.value="";
}
