//********************************************************* Detect Browser

var browser;
var newWin;

if (document.layers) {												//Netscape 4
	browser = 'NS4';	
}
else if (document.getElementById && !document.all) {				//Netscape 6+
	browser = 'NS6';	
}
else if (document.all && navigator.userAgent.indexOf("Opera")>-1){	//Opera 5+
	browser = 'Opera';	
}
else if (document.all) {											//Internet Explorer 4+
	browser = 'IE';	
}
else {																//Other
	browser = 'Other';
}

 
 
//********************************************************* Swap Image Function
/* 
Arguments
	imgName: value of "name" and "id" attribute in "img" tag
	imgPath: relative path of new image file
	imgLayer: if the target image is part of a layer, the layers's ID 
Note:
	"name" and "id" attributes for each "img" tag must have the same value 
Usage examples:
	onMouseOver="swapImage('imageName','newImageRelativePath','');"
	onMouseOver="swapImage('imageName','newImageReletivePath','LayerID');"
*/  

function swapImage(imgName, imgPath, imgLayer) {
	if (imgLayer.length <= 0) {						// Without Layers
		document.images[imgName].src = imgPath;	
	}
	else {											// With Layers
		if (browser == 'NS4') {
			document.layers[imgLayer].document.images[imgName].src = imgPath;
		}
		else if (browser == 'NS6') {
			document.getElementById(imgName).src = imgPath;
		}
		else {
			document.images[imgName].src = imgPath;
		}	
	}  
}  
 


//********************************************************* Show - Hide Layers Function
/* 
Arguments:
	layerID: value of "id" attribute in "div" tag
	action: Show or Hide a layer. Values: 'show', 'hide'.
Usage examples:
	onMouseOver="showHideLayer('LayerID','show');"
	onMouseOver="showHideLayer('LayerID','hide');"		
*/
 
function showHideLayer(layerID,action) {
	
	var thisLayer;
	var thisAction;
	var visible;
	var hidden;
	
	if (browser == 'NS4') {
		thisLayer = document.layers[layerID];
		visible = 'show';
		hidden = 'hide';
	}
	else if (browser == 'NS6'){
		thisLayer = document.getElementById(layerID).style;
		visible = 'visible';
		hidden = 'hidden';
	}
	else if (browser == 'Opera') {
		thisLayer = document.all(layerID).style;
		visible = 'VISIBLE';
		hidden = 'HIDDEN';
	}
	else {
		thisLayer = document.all(layerID).style;
		visible = 'visible';
		hidden = 'hidden';				
	}
	
	if (action == "show") {
		thisLayer.visibility = visible;
	}
	else if (action == "hide") {
		thisLayer.visibility = hidden;
	}
	
} 



//********************************************************* Pop-Up Window Function
/* 
Arguments:
	page: Page's relative path of popup Window
	x: The x position of popup Window
	y: The y position of popup Window
	w: The width of popup Window
	h: The height of popup Window
	scroll: The popup Window will be has scrollbars. Values: 'yes', 'no'.
	resize: The popup Window will be resizable. Values: 'yes', 'no'.
	content: HTML code of popup Window instead of loading another page	
Usage examples:
	<a href="javascript:popUpWindow('page.htm',20,20,100,200,'yes','yes','')">Link</a>
	<a href="javascript:popUpWindow('',20,20,100,200,'no','no','<p>Hello World</p>')">Link</a>	
*/
function popUpWindow(page,x,y,w,h,scroll,resize,content){
   
   var pWidth,pHeight,xPos,yPos,scrollThis,resizeThis;
  
   pWidth = w;
   pHeight = h;
   xPos =  x;
   yPos =  y;
   scrollThis = scroll;
   resizeThis = resize;
   winProp = "top="+yPos+",left="+xPos+",width="+pWidth+",height="+pHeight+",scrollbars="+scrollThis+",resizable="+resizeThis; 
   
	if(typeof(newWin)=='object') {
		if(!newWin.closed && browser != 'Opera'){
			newWin.close();				
		}
	}
         
	if(page.length > 0){	
		newWin = window.open(page,"newWindow",winProp);
		newWin.focus();
	}	
	else if (content.length > 0) {
		newWin = window.open("","newWindow",winProp);
		newWin.document.open();		
		newWin.document.write(content);
		newWin.document.close();	
		newWin.focus();
	}
}