function newImage(ID,file) {
	document.getElementById(ID).src='/images/'+file;
}

function open_window(URL,name,left,top,width,height,menubar){
	 rp=window.open(URL,name,"top="+top+",left="+left+",height="+height+",width="+width+",menubar="+menubar+",scrollbars=1,resizable=1,status=1");
	 rp.focus();
	 return(false);
}

function printPage(url, param){
   rp=window.open(escape(url) + param,"print","scrollbars=1,resizable=1,menubar=1");
   rp.focus();
   rp.print();
}

/*******  functions for creating a automatically resized image popup ****/

var win = '';
loadCount = 0;

/* when changing pics in the carousel, the win needs to be closed */
/* this happens when the arrows are clicked */

function closePopup(){ 
  if(win && !win.closed){
	    win.close();
  }  
}

function popupImage(imgpath)
{   
     if(win && win.closed==false){  //only open new window, when it is not already opened - but also need to open win, when user has closed window actively
       return;
     }
    img = new Image(); 
    img.src =(imgpath);
    fileCheck(imgpath);
}

function fileCheck(imgpath) //this should be revised..
{  
   if(loadCount>10){return;} 
   if((img.width!=0) && (img.height!=0)){ 
        popupImageWindow(imgpath);
    }
    else{ loadCount++;
          temp="fileCheck('"+imgpath+"')"; 
          interval=setTimeout(temp,50); 
    }   
}


function popupImageWindow(imgpath){
    
  var htmlpage = "<html><body style='padding:10px;margin:0px'><img src='" + imgpath + "' /></body></html>";
  
  ht = img.height + 20;
  wd = img.width + 20; 

  
  var args = "height=" + ht;
  args += ",width=" + wd;
  if (window.screen) //the viewer is using a browser that is compatible with Internet Explorer 4+
    { 
        var avht = screen.availHeight; 
        var avwd = screen.availWidth;
        var xcen = (avwd - wd) / 2; 
        var ycen = (avht - ht) / 2;
        args += ",left=" + xcen + ",screenX=" + xcen;
        args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=yes"; 	
    }     
     win = window.open(img, 'image', args); 
     win.document.write(htmlpage);   
}

/*******  end functions for creating a automatically resized image popup ****/

function popup(url,link) {
  window.open(url + "?link=" + link,"","width=630,height=400");
}



