
/**
 * navigation_library
 * 
 * Copyright (c) 2005 Genebio
 * 
 * $Author: nicolas $
 * $Revision: 1.9 $ $Date: 2006/04/13 10:30:53 $
 */




//test
function showMessageHello(){
	alert('Hello !');
}



//---------------------------------------------------------
//        library of tools for inter windows communication
//---------------------------------------------------------

/**
 *
 * Opens window defined by argument values
 * link: link to open in target window
 * windowName: name of target window
 * parentWindow: name of target window parent window
 * anchor: anchor name (if any) for document positioning in window
 */
function openWindow(link, windowName, parentWindow, anchor)  {

	// checks if parent window exists
	var currWin=parentWindow;
	if(currWin==undefined)  {
		//alert("undefined parent win...");
		currWin=self;
	}

	// opens/raises window
    if (!currWin[windowName]) {
        // has not yet been defined
        //alert("new "+link+" "+windowName+" "+currWin+" "+currWin[windowName]);
        currWin[windowName]=currWin.open(link,windowName);
    }
    else {
        // has been defined
        if (!currWin[windowName].closed) {
            // still open
            //alert("focus "+link+" "+windowName+" "+currWin+" "+currWin[windowName]);
            currWin[windowName].focus();
        }
        else {
        	//alert("open "+link+" "+windowName+" "+currWin+" "+currWin[windowName]);
        	currWin[windowName]=currWin.open(link,windowName);
        }
    }
    
    // moves to specified position
    if(anchor!=undefined) {
    	if(currWin[windowName].document.anchors.length==0) {
    		//alert(currWin[windowName].document.anchors.length);
    	} else {
    		//alert(anchor+"\n"+currWin[windowName].document.anchors[anchor].name);
    		for(var i=0;i<currWin[windowName].document.anchors.length; i++) {
    			if(currWin[windowName].document.anchors[i].name==anchor) {
    				currWin[windowName].document.anchors[i].focus();
    				//alert(i+": "+anchor+"\n"+currWin[windowName].document.anchors[i].name);
    				break;
    			}
    		}
    	}
    }
}




function wopen(url, w, h)
{
        w += 32;
        h += 96;
	var win = window.open(url,
		'popup', 
		'width=' + w + ', height=' + h + ', ' +
		'location=no, menubar=no, ' +
		'status=no, toolbar=no, scrollbars=yes, resizable=yes');
	win.resizeTo(w, h);
	win.focus();
}


/**
 * tests if popups are enabled
 * returns true if enabled, false otherwise
 */
function isPopupEnabled() {

    var testWin=window.open("http://www.phenyx-ms.com/","test","width=1,height=1,status=no,resizable=no,left=100000,top=100000,screenX=100000,screenY=100000");
    if(testWin==null) {
        return false;
    } else {
        testWin.close();
        return true
    }
}


/**
 * writes a warning in argument writtable element in case popup are blocked;
 */
function popupWarner(textElementID) {


  var enabled=isPopupEnabled();
  
  if(enabled==false) {
  
  	var writableElement=self.document.getElementById(textElementID)
  	writableElement.style.color="red";
  	writableElement.style.fontWeight="bold";
  	//writableElement.style.fontSize="large";
  	writableElement.innerHTML="You currently have popups disabled; please enable popups in order to allow Phenyx to work properly.";
  
  }
}

