function record_load(file) {

  var str = document.title;
  
  php_f = "../php/rec_log.php?file=" + file + "&ref=" + str;
  xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
  xmlhttp.open("GET", php_f, true);
  xmlhttp.send(null);
}

var closeimagelink="../images/exit.jpg"
var emaillink="../images/email.ico"
var IE6=(navigator.userAgent.indexOf("MSIE 6")>=0)
var safari=(navigator.userAgent.indexOf("Safari")>=0)
var IE=(navigator.userAgent.indexOf("MSIE")>=0)
var IE8=(navigator.userAgent.indexOf("IE 8")>=0)
var opera=(navigator.userAgent.indexOf("Opera")>=0)
var tb=document.getElementsByTagName('body')
var lbox=document.createElement("div")
var scrollt = 0;

lbox.setAttribute('id','lighterbox2')
tb[0].appendChild(lbox)
tb[0].insertBefore(lbox,tb[0].firstChild)

var lighterboxwrapper=document.createElement("div")
lighterboxwrapper.setAttribute('id','lighterboxwrapper2')
lbox.appendChild(lighterboxwrapper)

var labox=document.createElement("div")
labox.setAttribute('id','lighterboxcontent2')
lighterboxwrapper.appendChild(labox)

var portimage=document.createElement('img')
portimage.setAttribute('src','none')
portimage.setAttribute('id','portimage2')
labox.appendChild(portimage)

var pi=document.createElement('img')
pi.setAttribute('src',emaillink)
pi.setAttribute('id','previmage2')
pi.setAttribute('title','Send eMail')
pi.setAttribute('alt','Email')
labox.appendChild(pi)

var ci=document.createElement('img')
ci.setAttribute('src',closeimagelink)
ci.setAttribute('id','closebutton2')
ci.setAttribute('title','Close')
ci.setAttribute('alt','Close')
labox.appendChild(ci)

var description=document.createElement('div')
description.setAttribute('id','description2')
labox.appendChild(description)
var txt = document.createTextNode("Lighter Box 2");
description.appendChild(txt)

ci.style.cursor="pointer"
pi.style.cursor="pointer"

var lighterbox=document.getElementById('lighterbox2')
var bigpic=lighterbox.getElementsByTagName('img')

function o_box(thispic, wid, hig, name, price, size){
	ci.onclick=function(){
		lbox.style.display="none"
		lbox.setAttribute('class','hide')
		return false;
	}
	pi.onclick=function(){
		window.open("mailto:info@eilati.com?cc=lieilat@gmail.com&subject=Eilati: " + name);		
	}
	function checkKeycode(e) {
		var keycode
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		if (keycode == "27") {
			lbox.style.display="none"
			lbox.setAttribute('class','hide')
			return false;
		}
	}
	document.onkeydown = checkKeycode
	var source=thispic.getAttribute("href")

	var bwidth3=document.documentElement.clientWidth
	var bheight3=document.documentElement.clientHeight
	
	var	t = bheight3 - 115;
	wide = wid
	high = hig
	if (hig > t) {
		t = t / hig;
		wide *= t;
	    high *= t;
	}
	record_load (name)
	portimage.setAttribute('src',source)
	portimage.setAttribute('width',wide)
	portimage.setAttribute('height',high)

	var mytext = null
	if (name != null)  mytext = name
	if (price != null) mytext += "\u00A0 \u00A0 \u00A0 \u00A0" + price
	if (size != null)  mytext += "\u00A0 \u00A0 \u00A0 \u00A0[" + size +"]"
	document.getElementById('description2').firstChild.nodeValue=mytext;
	var wr=document.getElementById('lighterboxwrapper2')
   	var imgdim=document.getElementById('portimage2')
  	imgdim.onload=function(){show()}

	
	if (IE) {
	  if (!IE8) {
	    ci.style.left = 40 + "px";
	    lighterboxwrapper.style.left = "-"+ (document.documentElement.scrollWidth - bwidth3)/2 + "px";    
	  }
	  show();
	}
	function show () {
		var imgdimw=wide
		var imgdimh=high
		wr.style.marginLeft=((bwidth3-imgdimw)/2)+"px"
		wr.style.width=imgdimw+"px"
		wr.style.height=imgdimh+"px"
		lighterbox.setAttribute('class','show')
		lighterbox.style.display='block'
//	}
		if(IE6){}
		else if(safari){
			lbox.style.height=tb[0].scrollHeight+100+"px"
			wr.style.top=((bheight3-imgdimh-35)/2)+scrollt+"px"}
		else{lbox.style.height=document.documentElement.scrollHeight+100+"px"}
		lighterboxwrapper.style.top=((bheight3-imgdimh - 86)/2)+"px"
	}
		
//	if(IE){
//		lbox.style.display="none"
//		lbox.style.display="block"
//		lighterboxwrapper.style.marginTop="10px"
//		if(!IE6){lighterbox.style.height=document.documentElement.scrollHeight+"px"}
//	}
	return false
}

