//BEGIN STYLEWRITER
if(navigator.userAgent.indexOf("MSIE 4.5") != -1){
        document.write('<link rel="stylesheet" href="http://nyas.columbia.edu/sars/index_bin/mac_ns.css">');
}
else if(navigator.userAgent.indexOf("IE") != -1){
        document.write('<link rel="stylesheet" href="http://nyas.columbia.edu/sars/index_bin/ie.css">');
}
else if(navigator.userAgent.indexOf("Mozilla/5") != -1){
        document.write('<link rel="stylesheet" href="http://nyas.columbia.edu/sars/index_bin/ie.css">');
}
else if(navigator.userAgent.indexOf("Mac") != -1 && navigator.appName.indexOf("Netscape") != -1){
        document.write('<link rel="stylesheet" href="http://nyas.columbia.edu/sars/index_bin/mac_ns.css">');
}
else if(navigator.userAgent.indexOf("Mac") != -1){
        document.write('<link rel="stylesheet" href="http://nyas.columbia.edu/sars/index_bin/ie.css">');
}
else{
        document.write('<link rel="stylesheet" href="http://nyas.columbia.edu/sars/index_bin/ns.css">')
}
//END STYLEWRITER


//FUNCTION TO PRINT PAGE
function printit() {
        if (window.print) window.print();
        else {
                if (navigator.platform.indexOf('Mac') != -1) alert('This function does not work in your browser! \n Please select the Print option from the File menu.');
                else if (navigator.platform.indexOf('Win') != -1) alert('This function does not work in your browser! \n Please right click on your mouse and select the Print option.');
                else alert('This function does not work in your browser!');
        }
}
// END FUNCTION TO PRINT PAGE

//FUNCTION FOR SEARCH POPUP
function searchPopUp(url,winname,w,h){
	if(url.indexOf('trans') != -1 || url.indexOf('bio') != -1){
		openURL(url,winname,w,h)
	}else{
		location.href = url;
	}
}


//FUNCTION TO OPEN A URL IN NEW BROWSER WINDOW
function openURL(url,winname,w,h) {
        topWin = (screen.availHeight - h) / 2;
        leftWin = (screen.availWidth - w) / 2;
                if (navigator.platform.indexOf('mac') != -1){
                props = "menubar=yes,width="+w+",height="+h+",top="+topWin+",screenY="+topWin+",left="+leftWin+",screenX="+leftWin+",resizable=yes,scrollbars=yes"; }
                else {
                props = "width="+w+",height="+h+",top="+topWin+",screenY="+topWin+",left="+leftWin+",screenX="+leftWin+",resizable=yes,scrollbars=yes"; }
        var myWin = window.open(url,winname,props);
        myWin.focus();
}

//GLOBAL ROLLOVERS
if(document.images){
	printimg_off = new Image();      
	printimg_off.src = "http://nyas.columbia.edu/sars/index_bin/icon_print.gif";     
	
	printimg_on = new Image();
	printimg_on.src = "http://nyas.columbia.edu/sars/index_bin/icon_print_over.gif";
	
	pdf_off = new Image();      
	pdf_off.src = "http://nyas.columbia.edu/sars/index_bin/icon_pdf.gif";     
	
	pdf_on = new Image();
	pdf_on.src = "http://nyas.columbia.edu/sars/index_bin/icon_pdf_over.gif";
	
	register_on = new Image();      
	register_on.src = "http://nyas.columbia.edu/sars/index_bin/btn_register_over.gif";     
	
	register_off = new Image();
	register_off.src = "http://nyas.columbia.edu/sars/index_bin/btn_register.gif";
	
	signup_on = new Image();      
	signup_on.src = "http://nyas.columbia.edu/sars/index_bin/btn_signup_over.gif";     
	
	signup_off = new Image();
	signup_off.src = "http://nyas.columbia.edu/sars/index_bin/btn_signup.gif";
	
	video_on = new Image();      
	video_on.src = "http://nyas.columbia.edu/sars/index_bin/btn_vt_video_over.gif";     
	
	video_off = new Image();
	video_off.src = "http://nyas.columbia.edu/sars/index_bin/btn_vt_off.gif";
	
	video_trans = new Image();      
	video_trans.src = "http://nyas.columbia.edu/sars/index_bin/btn_vt_transcript_over.gif";     
}

// Function to 'activate' images.
function imgOn(imgName, vidButtons) {
        if (document.images) {
            document[imgName].src = eval(imgName + "_on.src");
			if(vidButtons){
				 document[imgName].src = eval(imgName + "_trans.src");
			}
        }
}

// Function to 'deactivate' images.
function imgOff(imgName, vidButtons) {
        if (document.images) {
            document[imgName].src = eval(imgName + "_off.src");
        }
}
//END LEFT NAV ROLLOVEROLLOVER

// sign up form validation


        var defaultText = ""
        function signUp() {
        //need to build query string here
        //so that the cgi will be able to decode the value of the "from" field
        email = "?from="+document.myform.from.value
        //load the form location and the query string into a variable
        url = "http://ci.columbia.edu/cgi-bin/dkv/dkvprod/sars_mail_jeff.cgi" + email
        //adjust "props" as needed by changing the width, height, or
        //by adding other window properties, such as scrollbars
        props = "width=700,height=300";
        window.open(url,"formval",props)
        }
        function validatit() {
        //test if "from" field is empty or contains the default text
        if(document.myform.from.value == '' || document.myform.from.value == defaultText) {
                alert('Please enter your email.')
                return false;
                }
        //test if "from" contains an @ sign. might want to
        //make this email validation more sophisticated or remove it.
        else if(document.myform.from.value.indexOf("@") == -1) {

                alert('Please enter a valid email address.')
                return false;
        }
        //alert(document.myform.from.value)
        }

//fetch url of selected form option	
function fetch() {
    chosen = document.form1.browse.selectedIndex;
    url    = document.form1.browse.options[chosen].value;
    if (url != 'none') 
        self.location.href = url;
}
