var windowName = null;

function openWindow(URL, w, h, name, external) { 
	if (!w && !h) { //if a width and height are not specified then use these default values
		width = 600;
		height = 450;
		}
	else { //else use the values specified
		width = w;
		height = h;
		}
	if (!name) { //if a name is not specified
		windowName = "PopUpWindow";
		}
	else { //else use the name specified
		windowName = name;
		}

		windowName = window.open(URL,windowName,"width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1,top=100,left=100");
	if (!(external)){
		windowName.focus();
	}
} 

function showWindow(URL, w, h, name, external) { 
	if (windowName) { // object exists
		if (!windowName.closed) { // check and see if it has not been closed
			windowName.location.href = URL; // if not, set focus
			}
		else {
			openWindow(URL, w, h, name, external);
			}
		}
	else { // the window was closed, create it again
		openWindow(URL, w, h, name, external);
		}
	if (!(external)){
		windowName.focus();
	}
}

function toggleSidebar(objDiv,objImg) {
    var elDiv = document.getElementById(objDiv);
    var elImg = document.getElementById(objImg);
    if(elDiv != null) {
        if(elDiv.style.display != 'none') {
            elDiv.style.display = 'none';
            if(elImg != null)
                elImg.src = 'images/module_up.gif';
        }
        else {
            elDiv.style.display = '';
            if(elImg != null)
                elImg.src = 'images/module_down.gif';
        }
    }
}

function toggleFooter(objDiv,mouseover,typ) {
    var elDiv = document.getElementById(objDiv);
    var elPH = document.getElementById('footer-placeholder');
    var elText = document.getElementById('footer-placeholderText');
    var cnt = 0;
    if(elDiv != null) {
        if(mouseover == true) {
            elDiv.style.backgroundColor = 'white';
            elPH.className = 'footerOn';
            if(typ == 1) {
                cnt = generateRandom(arrTrends.length);
                elText.innerHTML = arrTrends[cnt];
            }
            else if(typ == 2) {
                cnt = generateRandom(arrQuotes.length);
                elText.innerHTML = arrQuotes[cnt];
            }
            else if(typ == 3) {
                cnt = generateRandom(arrFYI.length);
                elText.innerHTML = arrFYI[cnt];
            }
        }
        else {
            elDiv.style.backgroundColor = '';
            elPH.className = 'footerOff';
            //elText.innerHTML = '';
        }
    }
}

function generateRandom(max) {
    return Math.floor(Math.random()*max);
}

