// JavaScript Document

//global variables:

var XX = -70;
var YY = -70;
var cur_one = "emptycell";
last_id = "emptycell";
var moving = false;
var xpos1 = 530;
var ypos1 = 170;
var myX = 0;
var myY = 0;


var services = 1;
var about_us = 1;
var client = 1;

function SwapImage(obj,which){
	obj.src = 'images/' + obj.name + which + '.gif';
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
 wind1 =  window.open(theURL,winName,features);
 wind1.focus();
  
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0

  var i,p,v,obj,args=MM_showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) {
		//alert(obj.style.idname);
	  if (v=='show')	
	  {
		if (last_id != args[i])
		{
		//xpos1 = obj.offsetLeft;
		xpos1 = 583;
		//alert(xpos1);
		ypos1 = obj.offsetTop;
		}
	  }	
	
	obj=obj.style; 
	obj.left =xpos1;
	v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
	
	}
	
    obj.visibility=v; 
	}
}

function displayItem1(cmn)
{document.getElementById("td" + cmn).style.color='#FFFFFF';
 document.getElementById("td" + cmn).style.background='#45617E';
}


function displayItem2(cmn)
{document.getElementById("td" + cmn).style.color='#9AB6CB';
document.getElementById("td" + cmn).style.background='#304F70';
 }


function resetColor()
{
for(i=1; i<=7; i++)
document.getElementById("li2m" + i).style.color='#9AB6CB';

}

function displayHeaderTop(){
header = "<table width=760 border=0 align=center cellpadding=0 cellspacing=0 >" +
  "<tr>" +
    "<td colspan=5 height=10><img src='images/sp.gif' /></td>" +
  "</tr>" +
  "<tr bgcolor=#304F70>" +				
				
	"<td width='24' height=24><img src='images/L-top.gif' /></td>" +
    "<td width='328' style='border-left:1px solid #45617E; border-right:1px solid #45617E;' ><img src='images/sp.gif' width='328' height='1' /></td>" +
    "<td width='125' ><img src='images/sp.gif' width=125 height=1 /></td>" +
    "<td width='252' ><img src='images/sp.gif' width=232 height=1 /></td>" +
    "<td width='24' height=24 ><img src='images/R-top.gif' /></td>" +
  "</tr>" +
  "<tr bgcolor=#304F70>" +
    "<td style='border-top:1px solid #8396A9; height:80px' >&nbsp;</td>" +
    "<td style='border-left:1px solid #45617E; border-right:1px solid #45617E; border-top:1px solid #8396A9; background:url(images/head-topgrayline.gif); padding-top:30px;' align='left'><img src='images/logo-hardesty1.gif' /></td>" +
    "<td style='border-top:1px solid #8396A9; background:url(images/head-topgrayline.gif);' >&nbsp;</td>" +
    "<td style='border-top:1px solid #8396A9; background:url(images/head-topgrayline.gif); border-right:1px solid #666666;'>&nbsp;</td>" +
    "<td style='border-top:1px solid #8396A9;' >&nbsp;</td>" +
  "</tr>"
"</table>";
 return header;
}


function displayRMenu1()
{
var current = GetParam();
//alert(current);
//return;
//document.write ("<table width=164 border=0 cellspacing=0 cellpadding=1 class=RMenu1 >" +
//      "<tr>" +
//        "<td  id='rollover'><a href='#'>The Firm</a></td>" +
//      "</tr>" +
//	  "<tr>" +
//        "<td  onmouseover='td01.style.background='#FFCC00', td01.style.cursor=hand, td01.style.borderColor=#5A728D' >once this is written this the code is encoded already</td>" +
//      "</tr>" +
//	  "</table>");
 
document.write ("<table width=120 border=0 cellspacing=0 cellpadding=1 class=RMenu1 >" +
	  "<tr>" +
		"<td><img src='images/sp.gif' height=17 width=120 /></td>" +
	  "</tr>" +
	   "<tr>" +
		"<td><a href='hardesty-services.html'>Services</a></td>" +
	  "</tr>" +
	  "<tr>" +
		"<td><a href='about-hardesty.html'>About Us</a></td>" +
	  "</tr>" +
      "<tr>" +
        "<td background='images/home_menubg.gif'>" +
  
  "<table border=0 align=right cellpadding=0 width=115 cellspacing=0 class=RMenu1 >" +
		  
          "<tr id='td1' height=19>");
document.write("<td background='images/");
document.write((current =='the-firm.html')? "CMactive.gif' style='padding-left:16px' ><font color='#FFFFFF'>The Firm</font>" : "RMinactive.gif' style='cursor:pointer; cursor:hand; padding-left:16px' onMouseOver=displayItem1('1'); onmouseout=displayItem2('1'); onclick=window.location.href='the-firm.html'>The Firm");
document.write("</td>");
document.write("</tr>" +
		  
		  
          "<tr id=td2  height=19 >");
document.write("<td background='images/");
document.write((current =='why-hardesty.html')? "CMactive.gif' style='padding-left:16px'><font color='#FFFFFF'>Why Hardesty</font>" : "RMinactive.gif' style='cursor:pointer; padding-left:16px;' onMouseOver=displayItem1('2'); onmouseout=displayItem2('2'); onclick=window.location.href='why-hardesty.html'>Why Hardesty");
document.write("</td>");
document.write("</tr>" +		  
		  		  
		  
          "<tr id=td3  height=19 >");
document.write("<td background='images/");
document.write((current =='yours-or-theirs.html')? "CMactive.gif' style='padding-left:16px'><font color='#FFFFFF'>Yours or Theirs</font>" : "RMinactive.gif' style='cursor:pointer; padding-left:16px;' onMouseOver=displayItem1('3'); onmouseout=displayItem2('3'); onclick=window.location.href='yours-or-theirs.html'>Yours or Theirs");
document.write("</td>");
document.write("</tr>" +	
		  
		  
          "<tr id=td4  height=19 >");
document.write("<td background='images/");
document.write((current =='advisor-broker-planner.html')? "CMactive2.gif' style='padding-left:16px'><font color='#FFFFFF'>Advisor, Broker, Planner?</font>" : "RMinactive.gif' style='cursor:pointer; padding-left:16px;' onMouseOver=displayItem1('4'); onmouseout=displayItem2('4'); onclick=window.location.href='advisor-broker-planner.html'>Advisor, Broker, Planner?");
document.write("</td>");
document.write("</tr>" +

		  
          "<tr id=td5  height=19 >");
document.write("<td background='images/");
document.write((current =='executive-team.html')? "CMactive.gif' style='padding-left:16px'><font color='#FFFFFF'>Executive Team</font>" : "RMinactive.gif' style='cursor:pointer; padding-left:16px;' onMouseOver=displayItem1('5'); onmouseout=displayItem2('5'); onclick=window.location.href='executive-team.html'>Executive Team");
document.write("</td>");
document.write("</tr>" +

		  
          "<tr id=td6  height=19 >");
document.write("<td background='images/");
document.write((current =='investment-philosophy.html')? "CMactive2.gif' style='padding-left:16px'><font color='#FFFFFF'>Investment Philosophy</font>" : "RMinactive.gif' style='cursor:pointer; padding-left:16px;' onMouseOver=displayItem1('6'); onmouseout=displayItem2('6'); onclick=window.location.href='investment-philosophy.html'>Investment Philosophy");
document.write("</td>");
document.write("</tr>" +		  

		  
    "<tr id=td7  height=19 >");
document.write("<td background='images/");
document.write((current =='investment-performance.html')? "CMactive2.gif' style='padding-left:16px'><font color='#FFFFFF'>Investment Performance</font>" : "RMinactive.gif' style='cursor:pointer; padding-left:16px;' onMouseOver=displayItem1('7'); onmouseout=displayItem2('7'); onclick=window.location.href='investment-performance.html'>Investment Performance");
document.write("</td>");
document.write("</tr>" +


	"</table>" +
  
  "</td>" +
  	   "<tr>" +
		"<td><a href='hardesty-client-resources.html'>Client Resources</a></td>" +
	  "</tr>" +
	  "<tr>" +
		"<td><a href='contact-hardesty.html'>Contact Us</a></td>" +
	  "</tr>" +
	  
		"<tr>" +
		"<td><img src='images/sp.gif' height=3 /></td>" +
		"</tr>" +
		
      "</tr>" +
      "<tr>" +
        "<td><img src='images/home_Rmenubtom.gif' height=5 /></td>" +
      "</tr>" +
    "</table>");
 
}
 
function GetParam()
{
 
//source = document.location.pathname; 
source = document.location.href; 
 
mystring = source.split("/");
//alert(mystring[mystring.length - 1]);
return mystring[mystring.length - 1]
  
}



// movable layer


function InitializeMove() {
cur_one = "movmenu";
XX = eval("xpos1") ;
YY = eval("ypos1");
}

function InitializeMove1() {
cur_one = "movmenu1";
XX = eval("xpos1") ;
YY = eval("ypos1");
}

function InitializeMove2() {
cur_one = "movmenu2";
XX = eval("xpos1") ;
YY = eval("ypos1");
}

function InitializeMoveG(id) {
cur_one = id;
XX = eval("xpos1");
YY = eval("ypos1");
}


function CaptureMove() {
if (document.layers) document.captureEvents(Event.MOUSEMOVE);
}

function EndMove() {
if (document.layers) document.releaseEvents(Event.MOUSEMOVE);
last_id = cur_one;
cur_one = "emptycell"
moving = false;
document.close();
}

function WhileMove() {

  if (document.all) {
    eval(cur_one+".style.left="+myX);
    eval(cur_one+".style.top="+myY);
  }
  
  if (document.layers) {
    eval("document."+cur_one+".left="+myX);
    eval("document."+cur_one+".top="+myY);
  }
}

function MoveHandler(e) {

myX = (document.all) ? event.clientX : e.pageX;
myY = (document.all) ? event.clientY : e.pageY;

  if (!moving) {
    diffX =  XX - myX;
    diffY = YY - myY;
    moving = true;
  if (cur_one == "emptycell") moving = false;
}
myX += diffX;
myY += diffY;

  if (moving) {
    xpos1 = myX;
    ypos1 = myY;
  }

WhileMove();
}

function ClearError() {
return true;
}


function clearMouseUp()
{
	if(moving == true)
	{
	EndMove();
	}
}


if (document.layers) {
document.captureEvents(Event.CLICK);
document.captureEvents(Event.DBLCLICK);
}


document.onmousemove = MoveHandler;
document.onclick = CaptureMove;
document.onmouseup = clearMouseUp;
document.ondblclick = EndMove;
window.onerror = ClearError;

WhileMove();

// Cookies

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	
	if(value)
	alert('true');

}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}
