//---------------------------openwindow---------------------------------
// This function opens a new window in the middle of the screen
// Parameters:
// w - the width of the window
// h - the height of the window
// ur - the URL of the window
function openwindow(w,h,ur) {
var d
	winleft = screen.width/2 - ( w/2 )
	wintop = screen.height/2 - ( h/2 ) - 30
var	height = h + 20;
	str = "width=" +w + ",height=" + height + "," + "top=" + wintop + ",left=" + winleft +",scrollbars=no,menubar=no,resizable=no,toolbar=no,location=no,status=yes"
	d = new Date()
	nm = Number(d)
	newWinObj = window.open(ur,nm, str)
	return newWinObj
}

function openwindowadvanced(w,h,ur,params) {
var d
	winleft = screen.width/2 - ( w/2 )
	wintop = screen.height/2 - ( h/2 ) - 30
var	height = h + 20;
	str = "width=" +w + ",height=" + height + "," + "top=" + wintop + ",left=" + winleft +","+params
	d = new Date()
	nm = Number(d)
	newWinObj = window.open(ur,nm, str)
	return newWinObj
}

function rollover(elementName, imageName, onoff)
{
	var image = document.getElementById(elementName)
	if (onoff == 1) 
		image.src = imageName + "_r.jpg"
	if (onoff == 0) 
		image.src = imageName + "_e.jpg"
}

var CurrentPageNum = 1;
function RefreshBook(BookId, skipfml) {
    var bookIframe = document.getElementById("BookViewer1_Preview");
    
    if (bookIframe == null)
    {
       alert("null");
       return;
    }
    //alert("http://fotobook.foto.co.il/ViewBook.asp?skipfml="+skipfml+"&bookid="+BookId+"&page="+CurrentPageNum);

       
    bookIframe.src = "http://fotobook.foto.co.il/ViewBook.asp?skipfml="+skipfml+"&bookid="+BookId+"&page="+CurrentPageNum;
    //bookIframe.src = "http://195.60.232.35/ViewBook.asp?skipfml=1&bookid=8503&page=3";
}

function RefreshBookPage(BookId, skipfml, PageNum) {
    var bookIframe = document.getElementById("BookViewer1_Preview");
    
    if (bookIframe == null)
    {
       alert("null");
       return;
    } 
    alert(BookId);
    alert(skipfml);
    alert(CurrentPageNum);
      
    bookIframe.src = "http://fotobook.foto.co.il/ViewBook.asp?skipfml="+skipfml+"&bookid="+BookId+"&page="+PageNum;
    //bookIframe.src = "http://195.60.232.35/ViewBook.asp?skipfml=1&bookid=8503&page=3";
}


function SaveCurrentPageNum()
{
    if (document.domain != "localhost")
    {
        //document.domain = document.domain.substring(document.domain.indexOf('.') + 1);
        document.domain = "foto.co.il";
    }
    
    //alert(document.domain);
    var bookIframe = document.getElementById("BookViewer1_Preview");
    if (bookIframe == null)
    {
        //alert("bookIframe is null");
        return;
    }
    //set src to null
    bookIframe.src = "";
    //CurrentPageNum = bookIframe.document.PicaPreview.getPageNumber();
    //CurrentPageNum = bookIframe.document.PicaPreview.getPageNumber();
    //CurrentPageNum = bookIframe.document.getElementById("PicaPreview").getPageNumber();
    var PicaObject = bookIframe.document.getElementById("PicaPreview");
    //CurrentPageNum = window.frames["BookViewer1_Preview"].document.PicaPreview.getPageNumber();
    //alert(CurrentPageNum);
    if (PicaObject == null)
    {
        //alert("Picaview is null");
        return;
    }
    else 
    {
        //alert("Picaview not null"); 
        CurrentPageNum = PicaObject.getPageNumber();
        //alert("page changed to:" + CurrentPageNum);
    }   
}

function rolloverGif(elementNameGif, imageNameGif, onoffGif)
{
	var image = document.getElementById(elementNameGif)
	if (onoffGif == 1) 
		image.src = imageNameGif + "_r.gif"
	if (onoffGif == 0) 
		image.src = imageNameGif + "_e.gif"
}


function preload(imgObj,imgSrc){
	if (document.images) {
		eval(imgObj+' = new Image()');
		eval(imgObj+'.src = "'+imgSrc+'"');
    }
}

function divVis(divId,offon)
{
	if (offon==1)
		document.getElementById(divId).style.visibility='visible'
	if (offon==0)
		document.getElementById(divId).style.visibility='hidden'
}

function paintCell(item,type) { 
	item.className = type;
}

function setIconImageSize(obj){
	if (obj.readyState == "complete") {
		if(obj.width >= obj.height)
			obj.width = 105;
		else
			obj.height = 105;
	}
}
	

function setLargeImageSize(obj) {
	if (obj.readyState == "complete")
	{
		if (obj.width >= obj.height)
			obj.width = 438;
		else
			obj.height = 315;
	}
}

function buildYearOptions(){
		for (i=1940;i<2005;i++)
			document.write('<option value="'+i+'">'+i)
}
	
function buildMonthOptions(){
	for (i=1;i<13;i++)
		document.write('<option value="'+i+'">'+i)
}
	
function buildDayOptions(){
	for (i=1;i<31;i++)
		document.write('<option value="'+i+'">'+i)
}
function please_wait_message()
{
	document.all.pleasewaitScreen.style.visibility="visible";
	//window.setTimeout('do_totals2()',1)
}

///fix the problem in activex when you need to click the control
/// in order to activate it.
function fixActiveXFocuse()
{
	fls = document.getElementsByTagName("object");
	for (var a = 0; a < fls.length; a++){fls[a].outerHTML = fls[a].outerHTML;}
}

