
var Cont = 0;

var style;

var outBack;

var menuArray = new Array();

var currentMenu;

var tmp;

var tmp2;

var type;

var speed = 11;

var lastElement;

var lastEl;

var frame;

var Elem;

var elem;

var main;

var leftNav;

var leftEnd = 164;





function resize(){  



	if (document.getElementById)

	{

		// this is the way the standards work

		frame = document.getElementById('leftNav').style;

		main = document.getElementById('main');

		leftNav = document.getElementById('leftNav');

	}

	else if (document.all)

	{

		// this is the way old msie versions work

		frame = document.all['leftNav'].style;

		main = document.all['main'];

		leftNav = document.all['leftNav'];

	}

	else if (document.layers)

	{

		// this is the way nn4 works

		frame = document.layers['leftNav'].style;

		main = document.layers['main'];

		leftNav = document.layers['leftNav'];

	}



	var height = main.offsetHeight;



	if(leftNav.offsetHeight > height) {height = leftNav.offsetHeight;}



//	trace('main = '+getElementHeight('main')+', leftnav = '+getElementHeight('leftnav'));



//	if (height<500) {height = 500;}

	frame.height = height + 50 +"px"; 

}



function showHide(element){



	if (document.getElementById)

	{

		// this is the way the standards work

		currentElement = document.getElementById(element).style;

		if(lastEl){

		 	lastElement = document.getElementById(lastEl).style;

			//trace (lastEl);

		}

	}

	else if (document.all)

	{

		// this is the way old msie versions work

		currentElement = document.all[element].style;

		if(lastEl){lastElement = document.all[lastEl].style;}

	}

	else if (document.layers)

	{

		// this is the way nn4 works

		currentElement = document.layers[element].style;

		if(lastEl){lastElement = document.layers[lastEl].style;}

	}

	

	if (currentElement.display != "block"){

	 	if(lastEl){lastElement.display = "none";}

	 	currentElement.display = "block"

	 	lastEl = element;

//		trace('show!');

	}else{

	 	currentElement.display = "none"

//		trace('hide!');

	};

}













function show(latestMenu, outBack){

	tmp = true;



//	alert(leftEnd);



	///slideout menu

	if(outBack){



		//if menu exist in array -> change outBack parameter into true, then brake.

		for (var i = 0; i < menuArray.length ; i++){if(!menuArray[i][0] && menuArray[i][1] == latestMenu) {menuArray[i][0] = true;break;}}



		//if menu exist in array -> set var tmp to false.

		for (var i = 0; i < menuArray.length ; i++){if(menuArray[i][1] == latestMenu){tmp = false;}}



		//if menu not exist in array (var tmp eq true) add new menu into array.

		if(tmp){menuArray.push(new Array (true, latestMenu, 0));}

	}



	///slidein menu

	//setting outBack parameter into false;

	if(!outBack){for (var i = 0; i <= menuArray.length ; i++){if(menuArray[i][1] == latestMenu) {menuArray[i][0] = false;break;}}}





 	currentMenu = latestMenu;

	

	//if not stearted sliding yet -> start:)

	if(!Cont){Cont = setInterval('MoveIt()',1);}

}









function MoveIt(){

	if (menuArray[1]){

//		trace (menuArray[1][1]+menuArray[1][2]);	

//		trace (document.getElementById(menuArray[1][1]).style.left);

	}



	for (var i = 0; i < menuArray.length ; i++){



	if (document.getElementById)

	{

		// this is the way the standards work

		currentElement = document.getElementById(menuArray[i][1]).style;

		///how show submenu element in IE7 FF

		type = 'block';

		//for FF set speed (step lenght)

		if(!document.layers && !document.all){speed = 17;};

	}

	else if (document.all)

	{

		// this is the way old msie versions work

		currentElement = document.all[menuArray[i][1]].style;

		///how show submenu element in IE6

		type = 'block';

	}

	else if (document.layers)

	{

		// this is the way nn4 works

		currentElement = document.layers[menuArray[i][1]].style;

		type = 'block';

		///how show submenu element in NN4

	}	



		//slidingOut submenu when menu is still on right side.	

		if(menuArray[i][0] && leftEnd > menuArray[i][2]){

//			trace('movingOut: '+menuArray[i][1]);

		 	currentElement.left = speed;

			currentElement.display = type;

		 	currentElement.left = speed + menuArray[i][2]+"px";

			menuArray[i][2] += speed;



		//slidingIn submenu when menu is still on right side.	

		}else if(!menuArray[i][0] && menuArray[i][2] > 23){

		 	if(menuArray[i][2] < 30){

//				currentElement.background = "none";

			}

			menuArray[i][2] -= speed;

		 	currentElement.left = menuArray[i][2]+"px";

			

		//hidding submenu when menu is on left side.	

		}else if(!menuArray[i][0] && menuArray[i][2] < 23 && currentElement.display != "none"){

//		 	trace ('Hiding: '+menuArray[i][1]+', position: '+ menuArray[i][2]);

			currentElement.display = "none";

		}



// 	trace ('Hiding: '+menuArray[i][1]+', position: '+ menuArray[i][2]);

		

/*		tmp2 = true;

		for (var j = 0; j < menuArray.length ; j++){if(menuArray[j][2] > 0){tmp2 = false;}}

		if(tmp2){clearInterval(Cont);Cont = 0;trace('End');currentElement.display = "none";}

*/

	}
	

}




// Used for pages with strict doctypes (i.e. no target="_blank")
// Automagically adds them back in to links with rel="external"

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
     anchor.target = "_blank";
    }

   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "shareholdershelppopup") {
     anchor.onkeypress = function(){window.open('http://miranda.hemscott.com/helppages/majorshareholders.htm', 'CtrlWindow', 'toolbar=no,menubar=no,height=420,width=580,location=no,scrollbars=yes,resizable=no,status=no,left=100,top=100');return false;}
     anchor.onclick = function(){window.open('http://miranda.hemscott.com/helppages/majorshareholders.htm', 'CtrlWindow', 'toolbar=no,menubar=no,height=420,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") == "news-item") {
         anchors[i].onkeypress = function(){window.open(this.href, 'NewsItem', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,height=540px,width=795px');return false;}
         anchors[i].onclick = function(){window.open(this.href, 'NewsItem', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,height=540px,width=795px');return false;}
    }

    if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "charthelp") {
         anchor.onkeypress = function(){window.open('http://miranda.hemscott.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://miranda.hemscott.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") == "disclaimer") {
      var disclaimerURL = anchor.getAttribute('href');
      anchor.onkeypress = function(){window.open(disclaimerURL, 'CtrlWindow', 'toolbar=no,menubar=no,height=505,width=638,location=no,scrollbars=yes,resizable=no,status=no,left=100,top=100');return false;}
      anchor.setAttribute("href","#");
      anchor.onclick = function(){window.open(disclaimerURL, 'CtrlWindow', 'toolbar=no,menubar=no,height=505,width=638,location=no,scrollbars=yes,resizable=no,status=no,left=100,top=100');return false;}
      anchor.setAttribute("href","#");
      }

}
}
window.onload = externalLinks;
