// This code and the findDOM is used to detect browser
// and allow for generic code elsewhere in the javascript
// Taken from DHTML and CSS for the World Wide Web
// Author: Reza Nabi @ KSU

var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;

if (document.getElementById) { isID = 1; isDHTML = 1;}
else { if (document.all) { isAll = 1; isDHTML = 1; }
else { browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && 
   (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
}}

function findDOM(objectID,withStyle) {
  if (withStyle == 1) {
    if (isID) {
      if (document.getElementById(objectID)) {
        return (document.getElementById(objectID).style);
      }
    }
    else { if (isAll) { return (document.all[objectID].style); }
    else { if (isLayers) { return (document.layers[objectID]); }}}}
  else {
    if (isID) { return (document.getElementById(objectID)); }
  else { if (isAll) { return (document.all[objectID]); }
  else { if (isLayers) { return (document.layers[objectID]); }}}}
}


// javascript popup tech begin
// following 2 function is needed to have popup tech in client side
function findLivePageWidth() {
	if (window.innerWidth != null)
		return window.innerWidth;
	if (document.body.clientWidth != null)
		return document.body.clientWidth;
	return (null);
}
	
function popUp(evt,objectID){
	if (isDHTML) { // Makes sure this is a DHTML browser
		var livePageWidth = findLivePageWidth();
		//alert(livePageWidth);
		domStyle = findDOM(objectID,1);
		dom = findDOM(objectID,0);
		state = domStyle.visibility;
		if (dom.offsetWidth) elemWidth = dom.offsetWidth;
		else { if (dom.clip.width)	elemWidth = dom.clip.width; }
		if (state == "visible" || state == "show")  { domStyle.visibility = "hidden"; }
		else {
			if (evt.pageY) { //Calculates the position for Navigator 4 
				topVal = evt.pageY + 20;
				leftVal = evt.pageX - (elemWidth / 2) + 10; 
			}
			else { 
				if (evt.y) { // Calculates the position for IE4
					topVal = evt.y + 20 + document.body.scrollTop;
					leftVal = evt.x - (elemWidth / 2) + document.body.scrollLeft + 10;
				}
			}
		/*If the element goes off the page to the left, this moves it back */
			if(leftVal < 2) { leftVal = 2; }
			else { 
				if ((leftVal + elemWidth) > livePageWidth) { leftVal = leftVal - (elemWidth / 2); }
			}
			domStyle.top = topVal; // Positions the element from the top
			domStyle.left = leftVal; // Positions the element from the left
			domStyle.visibility = "visible"; // Makes the element visable 
		}
	}
}
// javascript popup tech end


function popupWin(mylink, windowname)
{
	// get the browswer width and height
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth-16;
			winH = window.innerHeight-16+30;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth-20;
			winH = document.body.offsetHeight-20+30;
		}
	}
   var win = window.open(mylink, windowname, 'top='+((screen.height - winH) / 2)+',left='+((screen.width - winW) / 2)+'+,toolbar=0 status=1,resizable=1,Width='+winW+',height='+winH+',scrollbars=1');
   win.focus();

}


// begion please wait tech		
function fDisplayWait(f){
  var ctlWithStyle = findDOM('pwait',1);
  if(f){
    ctlWithStyle.visibility = "visible";
  }else{
    ctlWithStyle.visibility = "hidden";
  }
}

function fBlinkIt() {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags('blink').length;i++){
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}
// end please wait tech



