var pop_min;

function do_mini_dboard_menu() {
		pop_min=window.open('', "MiniDashboard",'directories=no,location=no,status=no,width=280,height=320,scrollbars=no,menubar=no,titlebar=no,toolbar=no,resizable=yes,alwaysRaised');
		try { 
			  pop_min.moveTo(10,10);
		} catch(e){
			// catching exception so that the user doesn't see it. 
		};
		
		pop_min.location="/cgi-bin/auth/dispatch.cgi?_code=903vdb&minidash=1";
		pop_min.focus();
	}
	
function emailHotpage(redirect_url, email) {
    //Prompt the user for the email address if none is passed in
    if (email.length == 0) {
        var message = "Please type in your email address.  Note that this will be saved as your email address for ALL Wall Street Source e-mail.";
        email = prompt(message);
    } else {
        var x = confirm("The email will be sent to '" + email + "'.  Is this OK?");
        if (!x) {
            return;
        }
    }

    if ((email != null) && (email.length != 0)) {
        if (!isValidEmail(email)) {
            alert("FAILED!!!  The email address '" + email + "' is not valid");
        } else {
            this.location = redirect_url + "&emails=" + email;
        }
    } else {
        // The user clicked on the cancel button
    }
}

function isValidEmail(str) {
    //var emailRegxp = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]+)(.[\w]{2,3}){1,2}$/;
    //return (emailRegxp.test(str) == true);
	return true;
}


function hide(obj) {
		if (!obj){
			return;
		}
		obj.className = 'group_hide';
	}
	
function show(obj) {
		if (!obj){
			return;
		}
		obj.className = 'group_show';	
	}
	
function grey(obj) {
		if (!obj){
			return;
		}
		obj.className = 'group_grey';	

	}	

function showGrey(id,show_grey) {
		var obj = document.getElementById(id);
		if ( show_grey ) {
			show(obj);	
		} else {
			grey(obj);	
		}
	}


function showHide(id,show_hide) {
		var obj = document.getElementById(id);
		if ( show_hide ) {
			show(obj);	
		} else {
			hide(obj);	
		}
	}

function expandtop30() {
		var obj = document.getElementById("top30");
		obj.className = 'list';
		showHide("expand",0)
}
	
function toggleVis(id,show_hide) {
		var obj = document.getElementById(id);
		if ( obj.className == 'group_hide' ) {
			show(obj);	
		} else {
			hide(obj);	
		}
	}

	
function toggleGrey(id,show_hide) {
		var obj = document.getElementById(id);
		if ( obj.className == 'group_grey' ) {
			show(obj);	
		} else {
			grey(obj);	
		}
	}

function showHideSport(link,group,show_hide) {
	showHide(group,show_hide);
	var obj = document.getElementById(link);
	if ( show_hide ) {
		obj.className = 'open';	
	} else {
		obj.className = 'closed';
	}
}

function toggleSport(link,group,show_hide) {
	toggleVis(group);
	var obj = document.getElementById(link);
	if ( obj.className == 'open' ) {
		obj.className = 'closed';
	} else {
		obj.className = 'open';	
	}
}

function storeHTML( id, html ) {
            var index = id;
            html_storage[ index ] = html;
        }

function retrieveHTML( id ) {
            var index = id;
            return html_storage[ index ];
        }

function adorn_url( anchor, key, value ) {
            if ( !anchor ) return;
            if ( !key ) return;
            if ( !value ) return;
            var p = new ParsedURL( anchor.href );
            p.delete_param( key );
            p.param( key, value );
            anchor.href = p.render();
        }
        
function selection_check(select_widget, thing, action) {
            var i = select_widget.selectedIndex;
            if ( i != null && i > 0 ) { return true };
            if ( ! thing ) {
                thing = 'selection';
            }
            var msg = 'Please choose a ' + thing;
            if ( action ) {
                msg += ' to ' + action;
            }
            alert( msg );
            return false;
        }

    function updateStoryCount() {
        var d = loadJSONDoc('/cgi-bin/auth/dispatch.cgi?_code=864&submit=storycount');
        var c = "<img src='/images/WSS4/new.gif' border=0>";
        d.addCallback(function (response) {
            if (response.count > 0) {
                c = '['+response.count+']';
            }
	    var result = $("storycount");
	    if (result) {
                result.innerHTML = c;
	    } else {
                //We are in a popup, see if the parent window has the storycount div and update that
                if (parent.document && parent.document.getElementById("storycount")) {
                    var result = parent.document.getElementById("storycount");
                    if (result) {
                        result.innerHTML = c;
                    }
                } else if (window.parent.opener && window.parent.opener.document) {
                    var result = window.parent.opener.document.getElementById("storycount");
                    if (result) {
                        result.innerHTML = c;
                    }
                }
            }
	});
    }
var wins = new Array();

function popmain(url,name){
    name = "wss_" + name;
	win_width = self.screen.availWidth - 240;
	width = 1000;
	if ( win_width > 1024 ) {
		width = 1000;
	}
    	if ( url.match(/----/) ) {
		return;
	} else if ( url.match(/javascript/) ) {
		eval(url);
	} else {
		if ( !wins[name] || wins[name].closed ) {
			var showbars = "yes";
			if ( name == 'wss_vown_srch' ) {
				showbars = "no";
			}
			wins[name]=window.open('', name,'directories=no,location=no,status=yes,width=' + width + ',height=500,scrollbars=' + showbars + ',menubar=no,titlebar=no,toolbar=' + showbars + ',resizable=yes');
		}
		wins[name].location= url + "&noback=1";
		wins[name].focus();
	}
    }

function sendLauncher () {
    var phone = document.getElementById("phone");
    if (!phone || !phone.value) {
        var msg = $("bb_msg");
        if (msg) {
            msg.className = "error";
            msg.innerHTML = "Please enter a mobile number";
        }
        return 0;
    }
    var d = loadJSONDoc('/cgi-bin/auth/dispatch.cgi?_code=trial&sendLauncher=1&phone='+phone.value);
    var c = "Error";
    d.addCallback(function (response) {
        if (response.msg) {
            c = response.msg;
        }
        var result = $("bb_msg");
        if (result) {
            if (response.status == 0) {
                result.className = "error";
            } else {
                result.className = "medium";
                setTimeout("toggleVis('bb_launcher2',1)",5000);
            }
            result.innerHTML = c;
        }
    });
}
