var site_category=1;
var cart_link='cart.html';
var errors_occured='The following error(s) occurred';
var is_required='is required';
var valid_email='must contain an valid e-mail address';

function menu_show_hide(parent,child,classid,show)
{

if (show==1)
	{
	document.getElementById(child).style.display='block';
	document.getElementById(parent).className=classid+'-a';
	}

else if (show==2)
	{
	document.getElementById(child).style.display='none';
	document.getElementById(parent).className=classid;
	}                        
else 
{
if (document.getElementById(child).style.display=='none')
	{
	document.getElementById(child).style.display='block';
	document.getElementById(parent).className=classid+'-a';
	}
else	{
	document.getElementById(child).style.display='none';
	document.getElementById(parent).className=classid;
	}
}


}


function page_display(id, height, width) 
{
 var win = window.open('/popup_page.php?id=' + id + '', id, 'height='+height+',width='+width+',toolbar=0,location=0');
}

function url_display(page, height, width) 
{
 var win = window.open(page, page, 'height='+height+',width='+width+',toolbar=0,location=0');
}


function image_display(id, image, height, width) 
{
 var win = window.open('/popup_image.php?product=' + id +'&photo='+image, id, 'height='+height+',width='+width+',toolbar=0,location=0');
}

function popUpWindow(url, w, h) {
	var left = (screen.width - w.valueOf())/2;
	var top =(screen.height - h.valueOf())/2;
	newwindow=window.open(url, '','toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=' + w + ',height=' + h +',top='+top+'px,left='+left+'px');
	if (window.focus) {newwindow.focus()}
	return false;
}


function set_onmouseover(id, width, height)
{
        var screen_x=screen_y=0;
	var ns=(document.layers);
	var ie=(document.all);
	var ns6=(document.getElementById&&!document.all);

	if (ie){
		if(document.body && document.body.scrollTop)
		{
			screen_x=document.body.clientWidth +document.body.scrollLeft;
			screen_y=document.body.clientHeight+document.body.scrollTop;
		}
		else
		{
                	screen_x=document.documentElement.clientWidth +document.documentElement.scrollLeft;
			screen_y=document.documentElement.clientHeight+document.documentElement.scrollTop;
		}
	}
	else if (ns||ns6){
		screen_x=window.innerWidth +pageXOffset;
		screen_y=window.innerHeight+pageYOffset;
//		alert('ns');
	}

	var pos_x = Math.abs(screen_x-width-20);
	var pos_y = Math.abs(screen_y-height-20);
	var element = document.getElementById(id);

	var width_top_center=width-30;
	var width_center=width-2;
	var height_center=height-21;

	element.style.top=pos_y+'px';
	element.style.left=pos_x+'px';
	element.style.width=width+'px';
	element.style.height=height+'px';
}

function show_box(id, image){
	set_onmouseover(id, 290, 272);
	document.getElementById(id).style.visibility='visible';
	document.getElementById(id+'img').innerHTML='<img src="/image.php?image='+image+'&w=3" alt="" width="250" height="250" alt="" />';
//	alert(document.getElementById(id).innerHTML);
}

function hide_box(id)
{
	document.getElementById(id).style.visibility='hidden';
}




function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; 
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,field,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; field=args[i+1]; val=MM_findObj(args[i]);
    if (val) { 
	if (field!='') nm=field; else nm=val.name;
	if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' '+valid_email+'.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' '+is_required+'.\n'; }
  } if (errors) alert(errors_occured+':\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function openwin() 
{window.open("http://www.providesupport.com?messenger=swissexpert","","top=100,left=100,width=500,height=460") 
} 
suspendcode="<DIV id=backi style='right:0px;POSITION:absolute;TOP:200px;'><a href=# onclick=openwin()><img src=indimg/lh.gif width=23 height=102 border=0></a></div>" 
//document.write(suspendcode); 
lastScrollY=0; 
function heartBeat(){ 
diffY=document.body.scrollTop; 
percent=.1*(diffY-lastScrollY); 
if(percent>0)percent=Math.ceil(percent); 
else percent=Math.floor(percent); 
document.all.backi.style.pixelTop+=percent; 
lastScrollY=lastScrollY+percent; 
} 
// window.setInterval("heartBeat()",1);

function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("It's about time to upgrade you browser don't you think?");
	}
}

var getReq = getXmlHttpRequestObject();


function captcha_refresh() {
	if (getReq.readyState == 4 || getReq.readyState == 0) {
		var rand=Math.random();
		getReq.open("GET", '/index.php?action=captcha&r='+rand, true);
		getReq.onreadystatechange = captcha_request;
		getReq.send(null);
	}
}



function captcha_request()
{
if (getReq.readyState == 4) {
		var ss = document.getElementById('captcha_img');
		ss.innerHTML = '';
		ss.innerHTML = getReq.responseText;
			}
}


function jsRate(value, id)
{
		document.getElementById(id).value=value;
		var echo_val=value*17;
		document.getElementById('rating_layer').innerHTML ='';
		document.getElementById('rating_layer').innerHTML ='<ul class="unit-rating"><li class="current-rating" style="width:'+echo_val+'px;">'+echo_val+'</li><li><a href="#" title="Bad" class="r1-unit"  onclick="jsRate(\'1\', \''+id+'\'); return false;">1</a></li><li><a href="#" title="Poor" class="r2-unit" onclick="jsRate(\'2\', \''+id+'\'); return false;">2</a></li><li><a href="#" title="Fair" class="r3-unit" onclick="jsRate(\'3\', \''+id+'\'); return false;">3</a></li><li><a href="#" title="Good" class="r4-unit" onclick="jsRate(\'4\', \''+id+'\'); return false;">4</a></li><li><a href="#" title="Excellent" class="r5-unit" onclick="jsRate(\'5\', \''+id+'\'); return false;">5</a></li></ul>';
}



function ajaxRate(value,number)
{
	if (getReq.readyState == 4 || getReq.readyState == 0) {
                var rand  = Math.random();
		getReq.open("GET", '/product_rate.html?number='+number+'&value='+value+'&rand='+rand, true);
		getReq.onreadystatechange = ajaxRate_request;
		getReq.send(null);
	}
}


function ajaxRate_request()
{
	if (getReq.readyState == 4) {
		var str = getReq.responseText;
		document.getElementById('rating_layer').innerHTML=str;
	}
}


var url_show_image='';

function showImage(image_idx)
{
 var width = 700;
 var height = 700;
 var left = (screen.availWidth-width)/2;
 var top = (screen.availHeight-height)/2;
 var w = window.open(url_show_image+'?photo='+image_idx,'foto_popup_window','width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',scrollbars=0,resizable=no,toolbar=0');
 w.focus();
}

function choose_ring_size(size,product){
	document.getElementById('buy_now_btn').innerHTML = '<a href="/'+cart_link+'?add='+product+'&amp;size='+size+'" class="buynow-btn-'+site_category+'">&nbsp;</a>';
}

function check_box(box, product){
  if (document.getElementById('buy_box_checkbox').checked==true)  
	document.getElementById('buy_now_btn').innerHTML = '<a href="/'+cart_link+'?add='+product+'&amp;box='+box+'" class="buynow-btn-'+site_category+'">&nbsp;</a>';
  else	
	document.getElementById('buy_now_btn').innerHTML = '<a href="/'+cart_link+'?add='+product+'" class="buynow-btn-'+site_category+'">&nbsp;</a>';
}

function floating_banner()
{

        var screen_y=0;
	var ns=(document.layers);
	var ie=(document.all);
	var ns6=(document.getElementById&&!document.all);

	if (ie){
		if(document.body && document.body.scrollTop)
		{
			screen_y=document.body.scrollTop;
		}
		else
		{
			screen_y=document.documentElement.scrollTop;
		}
	}
	else if (ns||ns6){
		screen_y=pageYOffset;
	}

	var pos_x = 0;
	var pos_y = Math.abs(screen_y);

	var element = document.getElementById('floating_banner');
	element.style.top=pos_y+'px';
	element.style.left=pos_x+'px';

	setTimeout("floating_banner()",10);
}

