/*
================================================================================
@File Name: js_misc_lib.js
@Author: Fabio Serra (Faser) - faser@faser.net
@Last Update: 26/06/01
@Version: 0.5
@Description: various functions to do common tasks
@Log:
================================================================================
*/

/**
@Function: openWin 
@Author: Fabio Serra aka Faser - faser@faser.net
@Input: url=the html document; name:the name of the new window; 
w=width; h=height; param=the allowed parameters for the window object  
@Output: the new window
@Date: 26/06/01
@Description: Open a new custom popup window
*/

function openWin(url, name, w, h, param, centered)		{
	
	// check arguments
	if (!url) 	url = "";
	if (!name)	name="NewWindow";
	if (!w)		w=450;
	if (!h)		h=320;
	if (!param)	{
		param="toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no";
	}	
	

	gui = "width=" + w + ",height=" + h + "," + param;
	
	var win = window.open(url,name,gui);
        
    if (centered)  
        win.moveTo((screen.width-w)/2, (screen.height-h)/2);
    
	win.focus();
		
}

//Only for IE
function modalWin(url,type,args,feat,w,h) {
	if(!w) w = 800;
	if(!h) h = 500;
	if(!args) args = window;
	if(!feat) { 
		feat = "dialogWidth:"+w+"px;dialogHeight:"+h+"px;resizable:yes;scroll:no;help:no;"; 
	} else {
		feat = "dialogWidth:"+w+"px;dialogHeight:"+h+"px;"+feat;
	}
	if(type == "modeless") {
		window.showModelessDialog(url,args,feat);	
	}else{
		window.showModalDialog(url,args,feat);	
	}
}
 

function initRollOver() {
  if (!document.getElementById) return
  var imgOriginSrc;
  var imgTemp = new Array();
  var imgarr = document.getElementsByTagName('img');
  for (var i = 0; i < imgarr.length; i++) {
    if (imgarr[i].getAttribute('hsrc')) {
        imgTemp[i] = new Image();
        imgTemp[i].src = imgarr[i].getAttribute('hsrc');
		
        imgarr[i].onmouseover = function() {
			imgOriginSrc = this.getAttribute('src');
            this.setAttribute('src',this.getAttribute('hsrc'));
        }
        imgarr[i].onmouseout = function() {
			if(!imgOriginSrc) imgOriginSrc = this.getAttribute('src');
			this.setAttribute('src',imgOriginSrc);
        }
    }
  }
}




