/////////////////////////////////////////////////////////////////////////////
///This is The Code to Change to update the random images on the home page
/////////////////////////////////////////////////////////////////////////////
function Placeimages(){
	images = new Array();
	images[0] = 'images/FrontPageImages/Random_image1.jpg';
	images[1] = 'images/FrontPageImages/Random_image2.jpg';
	images[2] = 'images/FrontPageImages/Random_image3.jpg';
	images[3] = 'images/FrontPageImages/Random_image4.jpg';
	images[4] = 'images/FrontPageImages/Random_image5.jpg';
	///Add or subtract images as needed...  just maintain the [1],[2] schema///
	index = Math.floor(Math.random() * images.length);
	document.write("<img src='" + images[index] + "' />");	
}
/////////////////////////////////////////////////////////////////////////////

function searchbar_textremove(myElement){
	if (myElement.value == 'Search eSlide'){
		myElement.value = '';
		myElement.focus();
	}
}

function swapMyImage(myElement) {
	myElement.src = 'http://www.eslide.com/images/goButton_down.gif';
}

function searchbar_onblur(myElement) {
	if (myElement.value == ''){
	myElement.value = 'Search eSlide';
	}
}


function CheckIfMain(MyID, thisaction, chgMain) {
	if (MyID != chgMain) {
		ClassChg(MyID, thisaction, chgMain);
	}
}

function writeEmail(ename, eaddress, elink, esubject){
	document.write('<a class="email" href="');
	document.write('mai');
	document.write('lto');
	document.write(':' + ename);
	document.write('@');
	document.write(eaddress);
	document.write('?');
	document.write('su');
	document.write('bject=');
	document.write(esubject + '">' + elink + '</');
	document.write('a');
	document.write('>');
}

function newWindow(mypage, myname, h, w, status, resizable, toolbar, scrollbars, menubar, center){
	if (center=='yes'){
		if(screen.width){
        var winl = (screen.width-w)/2;
        var wint = (screen.height-h)/2;
        }else{winl = 0;wint =0;}
        if (winl < 0) winl = 0;
        if (wint < 0) wint = 0;
	} else {
		var winl = 0;
        var wint = 0;
	}
	var settings = 'height=' + h + ',';
    settings += 'width=' + w + ',';
    settings += 'top=' + wint + ',';
    settings += 'left=' + winl + ',';
    settings += 'status=' + status + ',';
	settings += 'resizable=' + resizable + ',';
	settings += 'toolbar=' + toolbar + ',';
	settings += 'scrollbars=' + scrollbars + ',';
	settings += 'menubar=' + menubar;
	win = window.open(mypage,myname,settings);
 	win.window.focus();
}

var aboutEslide = null;
var Services = null;
var aboutEslideTimer= false;
var ServicesTimer= false;
var ClientArea = null;
var ClientAreaTimer = false;
var Samples = null;
var SamplesTimer = false;
var Contact = null;
var ContactTimer = false;
var Careers = null;
var CareersTimer = false;

function MenuDisp(menu, myX, myY) {
	if(menu.length > 0){
		if (eval(menu + "Timer")) {
			eval("clearTimeout(" + menu + ")");
			eval(menu + "Timer = false");
			}
		  if (document.all) {   
			//IE
			var MyMenu = window.document.getElementById(menu);
			  MyMenu.style.pixelLeft = myX;
			  MyMenu.style.pixelTop = myY+21;
			  MyMenu.style.display='block';
		  } else if (document.layers) {
			//NS
				var MyMenu = window.document.layers[menu];
			  MyMenu.left = myX;
			  MyMenu.top = myY+21;
			  MyMenu.style.display='block'; 
		  } else if (document.getElementById) {
			//NS-old
			  document.getElementById(menu).style.left = myX;
			  document.getElementById(menu).style.top = myY+21;
			  document.getElementById(menu).style.display='block'; 
		  }
  }
}

function TimedBye(menu, myMenuId, byeMainTimed) {
	var myvar = "MenuBye('" + menu + "','" + myMenuId + "','" + byeMainTimed + "')";
	eval(menu + " = setTimeout(myvar,500)");
	eval(menu + "Timer= true");
}

function MenuBye(menu, myMenuHeadId, byeMain) {
	if (eval(menu + "Timer")) {
		eval("clearTimeout(" + menu + ")");
		eval(menu + "Timer = false");
	}
	if (document.all) {   
		var MyMenu = window.document.getElementById(menu);
		MyMenu.style.display='none';
  	} else if (document.layers) {
		var MyMenu = window.document.layers[menu];
		 MyMenu.style.display='none'; 
  	} else if (document.getElementById) {
	 	document.getElementById(menu).style.display='none'; 
  	}
	ClassChg(myMenuHeadId, 'out', byeMain);
	;
	
}

function MenuKeep(menu) {
	if (eval(menu + "Timer")) {
		eval("clearTimeout(" + menu + ")");
		eval(menu + "Timer = false");
	}
}

function DL_GetElementLeft(eElement)
{
    var nLeftPos = eElement.offsetLeft;          // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nLeftPos += eParElement.offsetLeft;      // appending left offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nLeftPos;                             // return the number calculated
}
          
function DL_GetElementTop(eElement)
{
    var nTopPos = eElement.offsetTop;            // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nTopPos += eParElement.offsetTop;        // appending top offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nTopPos;                              // return the number calculated
}

function ClassChg(MyID, thisaction, chgMain) {
	var MyTopSec = document.getElementById(MyID);
		if (thisaction == 'in') {
			if (chgMain == MyID) {
				MyTopSec.className='Menutxt';
			} else {
				MyTopSec.className='MenutxtOVER';
			}
		} 
		if (thisaction == 'out'){
			if (chgMain == MyID) {
			MyTopSec.className='Menutxt';
			} else {
			MyTopSec.className='Menutxt_off';
			}
		}
}
function SubClassChg(MyID, thisaction, menuID, chgSub, mySubAnch, myMainpge) {
	var MySubSec = document.getElementById(MyID);
	var MySubAnchorSec = document.getElementById(mySubAnch);
	if (thisaction == 'in') {
		MySubSec.className='Menutxt_subOVER';
		MySubAnchorSec.className='Menutxt_a_sub_over';
		ClassChg(menuID, thisaction, myMainpge);
	} 
	if (thisaction == 'out'){
		if (chgSub==MyID) {
			MySubSec.className='Menutxt_sub';
			MySubAnchorSec.className='Menutxt_a_sub';
			//commented to remove the subnav highlight of current page
			//MySubSec.className='Menutxt_subOVER';
			//MySubAnchorSec.className='Menutxt_a_sub_over';
			//
		}else{
			MySubSec.className='Menutxt_sub';
			MySubAnchorSec.className='Menutxt_a_sub';
		}
	}
}

function highlightMenu(myMainMenuID, mySubMenuID){
	
	pic1 = new Image(); 
	pic1.src="http://www.eslide.com/images/goButton_down.gif";
	resizeOuterTo(960,'');
	if(myMainMenuID.length > 0){
		var MySubMenuText = document.getElementById(myMainMenuID + "_" + mySubMenuID)
		var MyMainMenu = document.getElementById(myMainMenuID);
		var MySubMenu = document.getElementById(mySubMenuID);
		MyMainMenu.className='Menutxt';
	}
	//commented to remove the subnav highlight of current page - Also UNCOMMENT lines 157-158
	//MySubMenu.className='Menutxt_subOVER';
	//MySubMenuText.className='Menutxt_a_sub_over';
	//end
}
function checkIt(string)
{
	var detect = navigator.userAgent.toLowerCase();
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


function resizeOuterTo(w,h) {
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	var closebottom = w-10
	var closetop = w+10
	if (checkIt('msie')){
		frameWidth = frameWidth + 20;
	}
	if (frameWidth < closebottom ||  frameWidth > closetop){
		frameHeight = frameHeight + 135;
		 if (parseInt(navigator.appVersion)>3) {
		   if (navigator.appName=="Netscape") {
			top.outerWidth=w;
			top.outerHeight=frameHeight;
		   }
		   else top.resizeTo(w, frameHeight);
 		}
	
	}
}

function chkNumeric(objName, minval, maxval)
{
	// only allow 0-9 be entered, plus any values passed
	// (can be in any order, and don't have to be comma, period, or hyphen)
	// if all numbers allow commas, periods, hyphens or whatever,
	// just hard code it here and take out the passed parameters
	var checkOK = "0123456789";
	var checkStr = objName;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	
	for (i = 0;  i < checkStr.value.length;  i++)
	{
	ch = checkStr.value.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	if (ch == checkOK.charAt(j))
	break;
	if (j == checkOK.length)
	{
		allValid = false;
		break;
	}
	if (ch != ",")
		allNum += ch;
	}
	if (!allValid)
	{	
		return (false);
	}
	
	// set the minimum and maximum
	var chkVal = allNum;
	var prsVal = parseInt(allNum);
	if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
	{
		return (false);
	}
	return(true);
}
