
/*
	Filename: $Workfile: /common/knights.js $
	Original author: B. Menoza
	Creation date: 7/11/2003
	Version: 5
	Modified by: bmenoza on 7/15/2003
	Modified by: $Author: al $ on $Date: 2008/09/05 01:31:41 $
	
	Copyright (c) 2006 Knights of Columbus
	1 Columbus Plaza
	New Haven, CT 06510-3326
	(800) 524-3611
	http://www.kofc.org
*/

function KofC_ChooseCSS() {
    if (navigator.userAgent.toLowerCase().indexOf('mac_ppc') != -1) { // AOL 5, MAC OS 9
        document.write('<link rel="STYLESHEET" type="text/css" href="/common/knights-mac.css">');
    }
    else {
        document.write('<link rel="STYLESHEET" type="text/css" href="/common/knights.css">');
    }
}

function KofC_ChangeState(id,state) {
    if (document.getElementById) { // NETSCAPE 6, IE 5.X+
        document.getElementById(id).className = state;
    } else if (document.all) {
        document.all[id].className = state;
    }
}



function KofC_OpenNewWindow(url,type,name,w,h) {
    var type;
    var new_win;
    var features;
    var toolbar;
    var location;
    var statusbar;
    var menubar;
    var resizable;
    var scrollbars;
    type = type.toLowerCase();
    if (type == 'html') {
        h=h-50;
        toolbar = 1;
        location = 1;
        statusbar = 1;
        menubar = 1;
        resizable = 'yes';
        scrollbars = 1;
        features =
        'height=' + h + ',' +
        'width=' + w + ',' +
        'top=' + (screen.height - h)/6 + ',' +
        'left=' + (screen.width - w)/2 + ',' +
        'toolbar=' + toolbar + ',' +
        'location=' + location + ',' +
        'statusbar=' + statusbar + ',' +
        'menubar=' + menubar + ',' +
        'resizable=' + resizable + ',' +
        'scrollbars=' + scrollbars;
    }
    else if (type == 'media') {
        toolbar = 0;
        location = 0;
        statusbar = 1;
        menubar = 0;
        resizable = 'no';
        scrollbars = 1;
        features =
        'height=' + h + ',' +
        'width=' + w + ',' +
        'top=' + (screen.height - h)/2 + ',' +
        'left=' + (screen.width - w)/2 + ',' +
        'toolbar=' + toolbar + ',' +
        'location=' + location + ',' +
        'statusbar=' + statusbar + ',' +
        'menubar=' + menubar + ',' +
        'resizable=' + resizable + ',' +
        'scrollbars=' + scrollbars;
    }
    else if (type == 'warning') {
        toolbar = 0;
        location = 0;
        statusbar = 1;
        menubar = 0;
        resizable = 'no';
        scrollbars = 1;
        features =
        'height=400' + ',' +
        'width=600' + ',' +
        'top=' + (screen.height - h)/2 + ',' +
        'left=' + (screen.width - w)/2 + ',' +
        'toolbar=' + toolbar + ',' +
        'location=' + location + ',' +
        'statusbar=' + statusbar + ',' +
        'menubar=' + menubar + ',' +
        'resizable=' + resizable + ',' +
        'scrollbars=' + scrollbars;
    }
    else if (type == 'flash') {
        toolbar = 0;
        location = 0;
        statusbar = 1;
        menubar = 0;
        resizable = 'no';
        scrollbars = 0;
        features =
        'height=' + h + ',' +
        'width=' + w + ',' +
        'top=' + (screen.height - h)/2 + ',' +
        'left=' + (screen.width - w)/2 + ',' +
        'toolbar=' + toolbar + ',' +
        'location=' + location + ',' +
        'statusbar=' + statusbar + ',' +
        'menubar=' + menubar + ',' +
        'resizable=' + resizable + ',' +
        'scrollbars=' + scrollbars;
    }
    else {
        toolbar = 0;
        location = 1;
        statusbar = 0;
        menubar = 0;
        resizable = 'yes';
        scrollbars = 1;
        features =
        'height=' + h + ',' +
        'width=' + w + ',' +
        'top=' + (screen.height - h)/4 + ',' +
        'left=' + (screen.width - w)/2 + ',' +
        'toolbar=' + toolbar + ',' +
        'location=' + location + ',' +
        'statusbar=' + statusbar + ',' +
        'menubar=' + menubar + ',' +
        'resizable=' + resizable + ',' +
        'scrollbars=' + scrollbars;
    }

    new_win = window.open(url,name,features) ;
    new_win.focus();
}

function KofC_determineOS() {
    var isOSX;
    if (navigator.userAgent.toLowerCase().indexOf('os x') != -1) { // MAC OS X
        isOSX = true;
    }
    else {
        isOSX = false;
    }
}

function KofC_rotateHomePageImage(altText, imageWidth) {
    var randomNumber = Math.floor(3*Math.random()+1);
    var randomImage = '/images/level0_photo'+randomNumber+'.jpg';
	
    document.writeln('<img src="' + randomImage + '" alt="' + altText + '" width="' + imageWidth + '" vspace="4" border="0" title="' + altText + '"/>');
}

function getQueryStringValue(paramName){
    // GET THE &param=value pairs to the right of the ?
    var qString = window.location.href.split("?")[1];
    var paramArray = qString.split("&")

    for(var i=0;i<paramArray.length;i++){
        var temp = paramArray[i].split("=")
        if(temp[0] == paramName) return (temp[1]);
    }

}
function KofC_limitTextarea(limitField, limitNum, limitDisclaimer) {
    var oDisclaimer;
    if (document.getElementById) {
        oDisclaimer = document.getElementById(limitDisclaimer);
    }
    else if (document.all) {
        oDisclaimer = document.all[limitDisclaimer];
    }
    if (limitField.value.length > limitNum) {
        //limitField.value = limitField.value.substring(0, limitNum);
        oDisclaimer.style.display = "block";
    }
    else {
        oDisclaimer.style.display = "none";
    }
}

KofC_ChooseCSS();
KofC_determineOS();