
// Used for pages with strict doctypes (i.e. no target="_blank")
// Automagically adds them back in to links with rel="external"





function setFormTarget(id) {
  //set form action to target frame instead of whole page
  var form = document.getElementById(id);
  if (form) {
    form.target = "contentframe";
    form.mode.value = "content";
  }
}
function getInternetExplorerVersion() {

    var rv = -1; // Return value assumes failure.

    if (navigator.appName == 'Microsoft Internet Explorer') {

        var ua = navigator.userAgent;

        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

        if (re.exec(ua) != null)

            rv = parseFloat(RegExp.$hs1);

    }

    return rv;

}
function setButtonState(id, enabled) {
  //set button state 
  var button = document.getElementById(id);
  button.childNodes[0].style.display = (enabled)? "" : "none";
  if (button.childNodes[1]) button.childNodes[1].style.display = (enabled)? "none" : "";
}
document.onclick=function(){
if(document.getElementById("dropdown-panel")){
	document.getElementById("dropdown-panel").style.display="none";
	}
}

function onloadAll() {
 
  

    var searchBox = document.getElementById("search-field");
      sel = document.getElementById("website");
      var markup = ''
    + '<div id="drop-field"  class="textfieldselect">Group Websites<img src="/images/select-button.gif" class="selctimg"  /></div>';
      var markup2 = "";
      for (var i = 0; i < sel.length;i++) {
        var opt = sel.options[i];
  ;
	   if (opt.value != "") markup2 += '<a href="#" onclick="document.getElementById(\'website\').value=\''+opt.value+'\';document.getElementById(\'drop-field\').innerHTML=\'' + opt.text.substring(0,24) + '<img src=/images/select-button.gif class=selctimg />\';return false;'
          + '">' + opt.text + '</a>';
      }
      
      var drop = sel.parentNode.parentNode.parentNode;
	  sel.style.display = "none";
	  drop.innerHTML += markup;
      drop.onclick = function (e) {
	   if (!e) e = window.event;
        var panel = document.getElementById("dropdown-panel");
	   if (panel.style.display=="none") {
		ua   = navigator.userAgent.toLowerCase();
var ver = getInternetExplorerVersion();
if (ver >= 8.0)
{


	panel.style.top = 1+ document.getElementById("drop-field").offsetTop-32 + "px";
          panel.style.left = 15 + document.getElementById("drop-field").offsetLeft + "px";
}
else
{
		panel.style.top = 1+ document.getElementById("website").offsetParent.offsetParent.offsetTop + "px";
          panel.style.left = 12 + document.getElementById("website").offsetParent.offsetLeft + "px";
}
          panel.style.display="block";
			var t;                       //for closing dropdown incase of mouse out
	 panel.onmouseover=function() {
	  clearTimeout(t);
	  panel.style.display="block";
	  }
	  panel.onmouseout=function()
	  {
	t=setTimeout("callme()",500);
	}
	  panel.onclick=function() {
	 		document.getElementById("dropdown-panel").style.display="none";
	 }
	 window.onclick = function () {
		document.getElementById("dropdown-panel").style.display="none";
           window.onclick = "";
          }
        } else panel.style.display="none";
        e.returnValue = false;
        e.cancelBubble = true;
      }     
	  window.onload = function() {
        var dropMenu = document.createElement("div");
        dropMenu.id = "dropdown-panel";
        dropMenu.style.display = "none";
        dropMenu.innerHTML = markup2;
		
    document.getElementById("header").appendChild(dropMenu);

	}

     
    externalLinks();
  
    
}


function callme(obj)
{
 document.getElementById("dropdown-panel").style.display="none";

}
function setHover(id) {
  //set hover state for given element
  document.getElementById(id).className = "hover"; 
}

function unsetHover(id) {
  //remove hover state for given element
  document.getElementById(id).className="";
}







function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   
   try{
   if (anchor.getAttribute("href") && anchor.getAttribute("rel").indexOf("external")>-1) {
     

	 anchor.target = "_blank";
    }
	}
	catch(e)
	{
	}

  
    if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "news-item") {
         anchors[i].onkeypress = function(){ window.open(this.href, 'NewsItem', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,height=580,width=600');return false;}
         anchors[i].onclick = function(){window.open(this.href , 'NewsItem', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,height=580,width=600');return false;}
    }
	
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "shareholdershelppopup") {
     anchor.onkeypress = function(){window.open('http://online.hemscottir.com/helppages/majorshareholders.htm', 'CtrlWindow', 'toolbar=no,menubar=no,height=643,width=580,location=no,scrollbars=yes,resizable=no,status=no,left=100,top=100');return false;}
     anchor.onclick = function(){window.open('http://online.hemscottir.com/helppages/majorshareholders.htm', 'CtrlWindow', 'toolbar=no,menubar=no,height=643,width=580,location=no,scrollbars=yes,resizable=no,status=no,left=100,top=100');return false;}
     anchor.setAttribute("href","#");
     }


    
    
    if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "webcast") {
         anchors[i].onkeypress = function(){ window.open(this.href, 'webcast', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,height=465,width=770');return false;}
         anchors[i].onclick = function(){window.open(this.href , 'webcast', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,height=465,width=770');return false;}
    }
    

    if (anchor.getAttribute("href") && anchor.getAttribute ("rel") == "charthelp") {
         anchor.onkeypress = function(){window.open('http://online.hemscottir.com/helppages/gifgraphs.htm ', 'ChartHelp', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,height=580,width=600');return false;}
         anchor.onclick = function(){window.open(' http://online.hemscottir.com/helppages/gifgraphs.htm', 'ChartHelp', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,height=580,width=600');return false;}
         anchor.setAttribute ("href","#");
    }


 if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "termofuse") {
         anchors[i].onkeypress = function(){ window.open(this.href, 'Terms Of use', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,height=505,width=638,left=100,top=100');return false;}
         anchors[i].onclick = function(){window.open(this.href , 'Term Of use', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,height=505,width=638,left=100,top=100');return false;}
    }

   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "disclaimer") {
      var disclaimerURL = anchor.getAttribute('href');
      anchor.onkeypress = function(){window.open('http://online.hemscottir.com/legal/cust_disclaim.htm', 'CtrlWindow', 'toolbar=no,menubar=no,height=505px,width=638px,location=no,scrollbars=yes,resizable=no,status=no,left=100,top=100');return false;}
      anchor.setAttribute("href","#");
      anchor.onclick = function(){window.open('http://online.hemscottir.com/legal/cust_disclaim.htm', 'CtrlWindow', 'toolbar=no,menubar=no,height=505px,width=638px,location=no,scrollbars=yes,resizable=no,status=no,left=100,top=100');return false;}
      anchor.setAttribute("href","#");
      }


}

}


function hd_open(frm){
if(frm.myDestination.value!="NONE")
window.open(frm.myDestination.value);

return false;
}

// Used for change the rollver images on the button input

function imgHov(e) {
if(e.src.match('-h.gif')) {

	e.src = e.src.replace(/-h.gif/i, ".gif");

	}  else {

		e.src = e.src.replace(/.gif/i, "-h.gif");

	}
}


window.onload = externalLinks;

