//-----------------------------------------------------------
//      Menu Definitions  
//	Copyright ©1998 - 2002 Wyse Securities
//	A Division of Pyramid Financial Corporation
//-----------------------------------------------------------

MainMenu = new Menu('MainMenu');
MainMenu.item[0] = "Home";
MainMenu.item[1] = "Trading";
MainMenu.item[2] = "New Account";
MainMenu.execute[0] = "http://www.wysesecurities.com";
MainMenu.execute[1] = "https://myview.swst.com/wyse";
MainMenu.execute[2] = "http://www.wysesecurities.com/apply_now.html";
MainMenu.height = 17;
MainMenu.width = 122;
MainMenu.left = 238;
MainMenu.top = 7;
MainMenu.font = "Courier New";
MainMenu.fontsize = 10;
MainMenu.align = "Center";
MainMenu.color = "lightgrey";
MainMenu.bgcolor = "6B90C1";
MainMenu.highlight ="gray";
MainMenu.texthighlight = "white"; 
MainMenu.border = "lightgrey"
MainMenu.offset = 7;
MainMenu.horizontal = true;
MainMenu.slide = true;
MainMenu.slideSpeed = 18;
MainMenu.arrow = false;

//-----------------------------------------------------------
//      Ticker Definitions
//-----------------------------------------------------------

var top = 35;
var left = 400;
var font = "Courier New";
var fontsize = 12;
var height = 18;
var color = "white";
var tickerstring = "58 3/8 -11/16   85 9/16 -1/4   60 1/2 -3/4   61 15/16 +5/8   29 15/16 -7/16   66 1/4 -2   127 15/16 +1/4    45 5/7 - 2/3";

//-----------------------------------------------------------
//      INIT
//-----------------------------------------------------------

function init() {

	Netscape = (document.layers) ? 1 : 0;
	Explorer = (document.all) ? 1 : 0;

	if (Explorer) {
		MainMenu.construct();
		MainMenu.display();
	}
	TickerInit();
}

//-----------------------------------------------------------
//	MAIN 
//-----------------------------------------------------------

function Menu(MenuName) {

	this.display = MenuDisplay;
	this.construct = MenuConstruct;
	this.hide = MenuHide;
	this.slideout = MenuSlide;

	this.name = MenuName;
	this.layer = MenuName + 'Div';
	this.selection = "None";
	this.offset = 1;
	this.arrow = true;

	this.item = new Array();
	this.execute = new Array();
	this.submenu = new Array();

}

function Clone(MenuName, ParentName) {

	this.display = MenuDisplay;
	this.construct = MenuConstruct;
	this.hide = MenuHide;
	this.slideout = MenuSlide;
	this.selection = "None";

	this.name = MenuName;
	this.layer = MenuName + 'Div';
	this.height = ParentName + ".height";
	this.width = ParentName + ".width";
	this.bgcolor = ParentName + ".bgcolor";
	this.highlight = ParentName + ".highlight";
	this.texthighlight = ParentName + ".texthighlight";
	this.border = ParentName + ".border";
	this.offset = ParentName + ".offset";
	this.left = ParentName + ".left";
	this.top = ParentName + ".top";
	this.color = ParentName + ".color";
	this.font = ParentName + ".font";
	this.fontsize = ParentName + ".fontsize";
	this.shadow = ParentName + ".shadow";
	this.arrow = ParentName + ".arrow";

	this.item = new Array();
	this.execute = new Array();
	this.submenu = new Array();
}

function MenuConstruct() {

	this.horizontal = (this.horizontal) ? this.horizontal : false;
	this.slide = (this.slide) ? this.slide : false;
	

	if (Explorer) {

		for (var i=0;i < this.item.length;i++) {

			layer = "<DIV ID=" + this.layer + i + 'border' + " STYLE='position:absolute; visibility : hidden;'></DIV>";
			document.body.insertAdjacentHTML("BeforeEnd", layer);

			layer = "<DIV ID=" + this.layer + i + " STYLE='position:absolute; visibility : hidden; font-Size : " + this.fontsize + "pt ;'></DIV>";
			document.body.insertAdjacentHTML("BeforeEnd", layer);

			newBorder = document.all[this.layer + i + 'border'];
			newLayer = document.all[this.layer + i];
			newBorder.style.backgroundColor = this.border;
			newBorder.style.width = this.width + 2; 
			newBorder.style.height = this.height + 2;
			newLayer.style.backgroundColor = this.bgcolor;
			newLayer.style.width = this.width; 
			newLayer.style.height = this.height;

			if (this.horizontal) {
				newBorder.style.pixelLeft = this.left + (this.width * i) + (this.offset * i) - 1 ;
				newBorder.style.pixelTop = this.top - 1;
				newLayer.style.pixelLeft = this.left + (this.width * i) + (this.offset * i);
				newLayer.style.pixelTop = this.top;
			}
			else {
				newBorder.style.pixelLeft = this.left - 1;
				newBorder.style.pixelTop = this.top + (this.height * i) + (this.offset * i) - 1;
				newLayer.style.pixelLeft = this.left;
				newLayer.style.pixelTop = this.top + (this.height * i) + (this.offset * i);
			}

			newLayer.style.color = this.color;
			newLayer.style.cursor = "hand";
			newLayer.onmousemove = MenuOver;
			newLayer.onmouseout = MenuOut;
			newLayer.onmousedown = MouseDown;
			newLayer.highlight = this.highlight;
			newLayer.texthighlight = this.texthighlight;
			newLayer.color = this.color;
			newLayer.bgcolor = this.bgcolor;
			newLayer.submenu = (this.submenu[i]) ? this.submenu[i] : "None";
			newLayer.execute = (this.execute[i]) ? this.execute[i] : "None";
			newLayer.objectname = this.name;
			
			if (this.align == "Left") { this.item[i] = "&nbsp;" + this.item[i]; }
			if (this.align == "Right") { this.item[i] = this.item[i] + "&nbsp;"; }
			if (document.all[this.layer + i].submenu != "None" && this.arrow) {
				newLayer.innerHTML = "<IMG SRC='images/arrow.gif' VSPACE=3 ALIGN=RIGHT><P ALIGN=" + this.align + "><FONT FACE='" + this.font + "'>" + this.item[i] + "</FONT>"

			}
			else { 
					newLayer.innerHTML = "<P ALIGN=" + this.align + "><FONT FACE='" + this.font + "'>" + this.item[i] + "</FONT>"; 
			}
		}
	}
}

function MenuDisplay() {

	if (this.slide) { 
		this.slideSpeed = (this.slideSpeed) ? this.slideSpeed : 50;
		this.hault = false;
		this.slideItem = 0;
		this.slidePos = 0;
		this.slideout(); 
	}

	else if (Explorer) {
		for (var i=0;i < this.item.length;i++) {
			document.all[this.layer + i + 'border'].style.visibility = "visible";
			document.all[this.layer + i].style.visibility = "visible";
		}
	}
}

function MenuSlide() {

	if (Explorer) {
		if (this.slidePos == 0) {
			document.all[this.layer + this.slideItem + 'border'].style.visibility = "visible";
			document.all[this.layer + this.slideItem].style.visibility = "visible";
		}

		this.slidePos++;
		slidePos = this.slidePos + 2;		

		if (this.horizontal) {
			document.all[this.layer + this.slideItem + 'border'].style.clip = "rect(0px " + this.width + 2 + "px " + slidePos + "px 0px)";
			document.all[this.layer + this.slideItem].style.clip = "rect(0px " + this.width + "px " + this.slidePos + "px 0px)";
			if (this.slidePos == this.height + 2) {
				this.slidePos = 0;
				this.slideItem++;
			}
		}
		else {
			document.all[this.layer + this.slideItem + 'border'].style.clip = "rect(0px " + slidePos + "px " + this.height + 2 + "px 0px)";
			document.all[this.layer + this.slideItem].style.clip = "rect(0px " + this.slidePos + "px " + this.height + "px 0px)";

			if (this.slidePos == this.width + 2) {
				this.slidePos = 0;
				this.slideItem++;
			}
		}

		if (this.slideItem < this.item.length && this.hault == false) {
			setTimeout(this.name + ".slideout()",this.slideSpeed);
		}
	}
}

function MenuHide() {

	this.hault = true;

	if (this.selection != "None") {	
		this.selection + ".hide()";
	}	

	if (Explorer) {
		for (var i=0;i < this.item.length;i++) {
			document.all[this.layer + i + 'border'].style.visibility = "hidden";
			document.all[this.layer + i].style.visibility = "hidden";
		}
	}
}

function MenuOver() {

	if (Explorer) {
		this.style.backgroundColor = this.highlight; 
		this.style.color = this.texthighlight;
	}
	if (eval(this.objectname + ".selection") != "None" && eval(this.objectname + ".selection") != this.submenu) {
		hidemenu = eval(this.objectname + ".selection");
		eval(hidemenu + ".hide()");
		eval(this.objectname + ".selection = 'None'");
			
	}
	if (this.submenu != "None" && eval(this.objectname + ".selection") != this.submenu) {
		eval(this.submenu + ".display()");
		eval(this.objectname + ".selection = this.submenu"); 	
	}

}

function MenuOut() {

	if (Explorer) {	
		this.style.backgroundColor = this.bgcolor;
		this.style.color = this.color;
	}
}

function MouseDown() {
	
	if (this.execute != "None") {
		parent.location = this.execute;
	}
}

function TickerInit() {

	if (Explorer) {

		layer = "<DIV ID=ticker STYLE='position:absolute; visibility : hidden; font-Size : " + fontsize + "pt ;'></DIV>";
		document.body.insertAdjacentHTML("BeforeEnd", layer);

		document.all['ticker'].style.height = height;
		document.all['ticker'].style.pixelLeft = left;
		document.all['ticker'].style.pixelTop = top;
		document.all['ticker'].style.color = color;
			
		document.all['ticker'].innerHTML = "<marquee width=250 SCROLLAMOUNT=1 SCROLLDELAY=1><FONT FACE='" + font + "'>&nbsp;" + tickerstring + "</FONT></marquee>"; 

		document.all['ticker'].style.visibility = "visible";
	}
}

//-----------------------------------------------------------------------------------------------
//		Other Functions
//-----------------------------------------------------------------------------------------------

function popup(location,width,height) {

	if ( cookie_load('wysepopup') != 1) {

        	properties='toolbar=no,location=no,directories=no,menubar=no,';
        	properties+='scrollbars=no,width=' + width + ',height=' + height;

        	if (navigator.appName.indexOf("Microsoft")>=0) {
                	properties+=',left=200,top=200'
        	}
        	else {
        		properties+=',screenX=200,screenY=200'
        	}

		window.open(location,"",properties)

		cookie_save('wysepopup',1);

		var tmp = cookie_load('wysepopup');
	}

}

function openWin(location,width,height) {

	properties='toolbar=yes,location=no,directories=no,menubar=no,';
        properties+='scrollbars=yes,width=' + width + ',height=' + height;

        if (navigator.appName.indexOf("Microsoft")>=0) {
                properties+=',left=200,top=200'
       	}
        else {
                properties+=',screenX=200,screenY=200'
        }

        window.open(location,"",properties)
}

function cookie_save(cname,cval) {

	document.cookie = cname + '=' + cval;

}
function cookie_load(cname) {

    var allcookies = document.cookie;

    if (allcookies == "") return false;

    var start = allcookies.indexOf(cname + '=');

    if (start == -1) return false;   // cookie not defined for this page.

    start += cname.length + 1;  // skip name and equals sign.

    var end = allcookies.indexOf(';', start);

    if (end == -1) end = allcookies.length;

    return allcookies.substring(start, end);
}
