﻿function forceClick(e, elemId, zoom_query) {
    var elem = document.getElementById(elemId);
    var evt = (e) ? e : window.event;
    var intKey = (evt.which) ? evt.which : evt.keyCode;
    
    if(intKey == 13) {
        elem.click();
        //location.href="/Search.aspx?st=" + escape(document.getElementById(zoom_query).value);
        return false;
    }

    return true;
}
    
function doSearch(e, elemId, zoom_query, strSection) {

    strSection = jQuery('.the_menu li a.on').attr('id');


    var uaURL = "";
    switch (strSection.toLowerCase()) {
        case "ua4you":
            uaURL = "/Search.aspx?usterms=" + escape(document.getElementById(zoom_query).value) + "&ustype=0";
            break;

        case "news":
            uaURL = "/Archived-News-and-Announcements?st=" + escape(document.getElementById(zoom_query).value);
            break;

        case "helpandsupport":
            uaURL = "/Advance-Support?st=" + escape(document.getElementById(zoom_query).value);
            break;
    }



    if(strSection == null || strSection == undefined)
        strSection = "";

    var elem = document.getElementById(elemId);
    var evt = (e) ? e : window.event;
    var intKey = (evt.which) ? evt.which : evt.keyCode;




    location.href = uaURL;
    return false;
} 
function clearMe(e){
    document.getElementById(e).value="";
}
function doOver(imgSrc, imgId, mnu){
    
    if(imgSrc.indexOf("-on.gif") != -1){
        //don't do mouseover
        
    }else{
        //ok to do over
        //split on extensions
        strImg  = imgSrc.split("images/" + mnu + "_");
        strBeg = strImg[1];
        strNewImg = strBeg.split(".");
        strSrc = "/images/" + mnu + "_" + strNewImg[0] + "-on.gif";
        document.getElementById(imgId).src=strSrc;
    }
    
}
function doOut(imgSrc, thisimgId, controlId, currentCatId, mnu){
   
    if(thisimgId!=currentCatId){
        //ok to mouseout  
        strImg  = imgSrc.split("images/" + mnu + "_");
        strBeg = strImg[1];
        strNewImg = strBeg.split("-on.gif");
        strSrc = "/images/" + mnu + "_" + strNewImg[0] + ".gif";
        
        document.getElementById(controlId).src=strSrc;
    }
   
}

function PrintStaff(){

    var printWin = window.open("/modules/PrintStaffDirectory.aspx", "", "width=770, height=700");
 
}

function PrintPage(filename){
    
    var printWin = window.open("/modules/PrintPage.aspx?f=" + filename, "", "width=770, height=700");
    
}

var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

    document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
//end get mouse position
function getMouseXY(e) {
    if(document.body){
      if (IE) { // grab the x-y pos.s if browser is IE
        
        tempX = event.clientX + parent.document.body.scrollLeft
        
        tempY = event.clientY + parent.document.body.scrollTop
      } else {  // grab the x-y pos.s if browser is NS
        tempX = e.pageX
        tempY = e.pageY
      }  
      // catch possible negative values in NS4
      if (tempX < 0){tempX = 0}
      if (tempY < 0){tempY = 0}  
      // show the position values in the form named Show
      // in the text fields named MouseX and MouseY
      
      //adjust for position of IFRAME
      var el =0
	    var x = 0, y = 0;

	    while (el)
	    {
	    tempX += el.offsetLeft;
	    tempY += el.offsetTop;
	    el = el.offsetParent;
	    }
      
      
      //parent.showMouseXY(tempX,tempY)
      //globalMouseX = tempX
      //globalMouseY = tempY
      //document.Show.MouseX.value = tempX
      //document.Show.MouseY.value = tempY
      }
      return true
}	
function showTip(whichTip, width){
	//alert(tempX + "," + tempY)
	//alert(whichTip);
	obj = document.getElementById(whichTip)
	obj.style.top = tempY - 20
	obj.style.left = tempX + 5
	obj.style.visibility = "visible"
	if (width != 0)
	    obj.style.width = width + "px"
}
function hideTip(whichTip){
	document.getElementById(whichTip).style.visibility="hidden"
}	
	function fieldIsEmpty(fieldValue){
		if (fieldValue == ""){
			return true
		} else {
			return false
		}		
	}
	
	function dropDownNotSelected(selectedIndex,defaultIndex){
		if(selectedIndex == defaultIndex){
			return true
		} else {
			return false
		}		
	}
	function isEmailValid(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		  
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   
		    return false
		 }

 		 return true					
	}
	
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
	

function launchHelp(url){
    win = window.open(url, "help", "height=400,width=600,resizable=yes,scrollbars=yes")
}	


