var imgZoom = loadedPg = false;
var timeoutId = 0;
function openNewWindow(urlWindow){
	var newwindow = window.open(urlWindow,null,
    'height=400,width=600,status=yes,toolbar=no,menubar=no,location=no');
    
    if (window.focus) {newwindow.focus()}
	return false; 
}
function closeImg(){
	GetElementById('photoImgBg').style.display="none";
	GetElementById('photoImgCont').style.display="none";

	
	imgZoom = false;
}
function activateZoom(){
	/*if(loadedPg!=true) {
		if(timeoutId)
		clearTimeout(timeoutId);		
		timeoutId = setTimeout('activateZoom()');return false;}*/
	if(imgZoom==false){
		var div1 =document.getElementById('photoImgBg');		
		var div2 = document.getElementById('photoImgCont');		
		div1.style.display="block";
		div2.style.display="block";
		
		/*
		xpoz=Math.round((screen.width-width)/2);
		ypoz=Math.round((screen.height-height)/2);
		if (xpoz<0) xpoz=10;
		if (ypoz<0) ypoz=10;
		*/
		
		var div2 = document.getElementById('photoImgCont');		
			//div2.style.position="absolute";
			var posTop =  getScrollHeight()+30;
			var posLeft =  document.body.clientWidth/2+getScrollWidth()-260;
			div2.style.top =posTop+'px';
			div2.style.left = posLeft+'px';
		
		
		if( window.innerHeight && window.scrollMaxY ){ // Firefox {
pageWidth = window.innerWidth + window.scrollMaxX-20;
pageHeight = window.innerHeight + window.scrollMaxY;
}
else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
{
pageWidth = document.body.scrollWidth;
pageHeight = document.body.scrollHeight;
}
else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
{ pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
	pageHeight = document.body.offsetHeight + document.body.offsetTop; 
}

var arrSizes = new Array();
arrSizes = getPageSize();


	//pageHeight = arrSizes[1]+arrSizes[4];
		
		GetElementById('photoImgBg').style.width = pageWidth+'px';
		GetElementById('photoImgBg').style.height = pageHeight+'px';
		imgZoom = true;
		
	}
	
	
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

var pic1;
function zoomThisImage(elm){
	
	var srcImg = elm.src.replace("/icon/","/zoom/");
	 srcImg = srcImg.replace("/big/","/zoom/");
	 activateZoom();
	if(GetElementById("imgZoom").src != srcImg){
	
GetElementById("imgZoom").src = "http://www.onestop.ro/images/img-zoom-loader.gif";
	
	 
	pic1= new Image(500,500); 
	pic1.src=srcImg; 
	timeoutId = setTimeout('imageLoadHandler()',300);
	}
	
	
}
  function imageLoadHandler () {
    // your code here e.g.
  
   if(pic1.complete){
   	GetElementById("imgZoom").src = pic1.src;
   }else{
   	clearTimeout(timeoutId);		
   	timeoutId = setTimeout('imageLoadHandler()',300);
   }
  }
/*



*/
function getScrollWidth()
{

   var w = window.pageXOffset ||
           document.body.scrollLeft ||
           document.documentElement.scrollLeft;
           
   return w ? w : 0;
}

function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}

function scrollMove(){
		
	if(imgZoom)
		try{
			
			var div1 = document.getElementById('photoImgBg');	
			var topPos = getScrollHeight();
	
			div1.style.top = topPos+'px';
			
			
			
		/*	
			var div2 = document.getElementById('photoImgCont');		
			//div2.style.position="absolute";
			var posTop =   getScrollHeight()+30;
			var posLeft =  document.body.clientWidth/2+getScrollWidth()-260;
			div2.style.top =posTop+'px';
			div2.style.left = posLeft+'px';
			document.getElementById('photoImgCont') = 	div2;*/
		}catch(e){
			
		}
}
if(navigator.userAgent.indexOf("MSIE 7.0")>0)
window.onscroll = scrollMove;