// iris dishon javascript file. All rights reserved.

function stopError() {
            return true;
         }
 window.onerror = stopError;

 function imgOnNav(imgName) {
      if (document.images) {
		pathst=document[imgName].src;
		if(pathst.substring(pathst.lastIndexOf('.')-1,pathst.lastIndexOf('.'))=='a'){
		document[imgName].src=pathst.substring(0,pathst.lastIndexOf('.')-1)+'b.gif';}
        }
  }

  function imgOffNav(imgName) {
   if (document.images) {
		pathst=document[imgName].src;
		if(pathst.substring(pathst.lastIndexOf('.')-1,pathst.lastIndexOf('.'))=='b'){
		document[imgName].src=pathst.substring(0,pathst.lastIndexOf('.')-1)+'a.gif';}
        }
  }

function changer(){	
		if (document.images.bone.con=='before'){
		imgOnNav('bone');
		document.images.bone.con='after'
		}else{
		imgOffNav('bone');
		document.images.bone.con='before'
		}
	clock=setTimeout("changer()",150);
	}

function show(imgName,closeUp) {
	theURL='show.php?'
	a=show.arguments;
	for(i=0; i<a.length; i++){
    	if (a[i]=='closeup') {
			theURL = theURL + '&closeup=yes' ;
		} else {
			if (i>0) {
				theURL = theURL + '&img' + i + '=' + a[i] ;
			} else {
				theURL = theURL + 'img' + i + '=' + a[i] ;
			}
		}
		
	}
		
		if (window.screen.availWidth<850){
			place_x=0;
			place_y=0;
			h=530;
			w=740;
			theURL = theURL + '&size=small';
		} else {
			h=590;
			w=920;
			place_x=(window.screen.availWidth-w)/2;
			place_y=(window.screen.availHeight-h)/2;
			theURL = theURL + '&size=big';
			}
		winstring='scrollbars=yes,resizable=yes,width='+w+',height='+h+',screenx='+place_x+',screeny='+place_y+',left='+place_x+',top='+place_y;
		

	newwin = window.open(theURL,'viewer',winstring);
	setTimeout('newwin.focus();',250);
	timeImages();
}

function slide(book, title, auther, pub, year) {
	theURL='slider.php?book='+book+'&title='+title+'&auther='+auther+'&pub='+pub+'&year='+year;
	
		
	
		
		if (window.screen.availWidth<850){
			place_x=0;
			place_y=0;
			h=530;
			w=740;
			theURL = theURL + '&size=small';
		} else {
			h=550;
			w=1000;
			place_x=(window.screen.availWidth-w)/2;
			place_y=(window.screen.availHeight-h)/2;
			theURL = theURL + '&size=big';
			}
		winstring='scrollbars=harizontal,resizable=yes,width='+w+',height='+h+',screenx='+place_x+',screeny='+place_y+',left='+place_x+',top='+place_y;
		

	newwin = window.open(theURL,'viewer',winstring);
	setTimeout('newwin.focus();',250);
	timeImages();
}

function timeImages(){
	if (newwin.closed) {
		loadImages();
	} else {	
		setTimeout('timeImages();',50);
	}
}

function loadImages() {
	for (i=0; i<document.images.length;i++){
		if (!document.images[i].complete) {
			document.images[i].src=document.images[i].src;
			}
		}
}

function parentImages() {
	if (window.opener != null) {
		for (i=0; i<document.images.length;i++){
			if (!document.images[i].complete) {
				document.images[i].src=document.images[i].src;
				}
			}
		for (i=0; i<window.opener.document.images.length;i++){
			if (!window.opener.document.images[i].complete) {
				window.opener.document.images[i].src=window.opener.document.images[i].src;
				}
			}
	}	
}

function goback() {
	alert(history.length);
	alert(history.previous());
	var h=2;
	if (navigator.appName.indexOf("Microsoft") != -1) h=1;
	if (history.length == h) {
		history.back();
	} else {
		window.close();
	}
}
imagearr=new Array;
	
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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];}}
}


document.onmousemove = mouseMove;
var mousePos;
function mouseMove(ev){
	ev           = ev || window.event;
	 mousePos = mouseCoords(ev);
}

function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}


function createPopUp(link)
{
	
	var div = document.createElement('div');
	div.className="popUp";
	div.style.top=60;
	div.style.left=mousePos.x-100;
	
	div.innerHTML = "<img style=\"float: right; cursor: pointer;\" src=\"../newImages/close.gif\" onclick=\"this.parentNode.parentNode.removeChild(this.parentNode);\"><br>" + "<iframe class=\"popUpiFrame\" src=\""+link+"\"></iframe>";
	document.body.appendChild(div);
	
	//alert(div.outerHTML);
}
