// JavaScript Document

// Browser Detection

    var agt=navigator.userAgent.toLowerCase();

    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

    var is_webtv = (agt.indexOf("webtv") != -1); 

    var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    var is_AOLTV = is_TVNavigator;

    var is_hotjava = (agt.indexOf("hotjava") != -1);
    var is_hotjava3 = (is_hotjava && (is_major == 3));
    var is_hotjava3up = (is_hotjava && (is_major >= 3));

// end Browser Detection



// opens a window with all the HTML inside <div id="copy">
// in a reduced layout suitable for printing
function printThisPage() {
	// get content from <div id="copy">
	var contents = document.getElementById('copy');

	// open window
	if((location.href.substr(0,6)=="https:") || (location.href.substr(0,6)=="HTTPS:")) { method="https"; } else { method="http"; }

	top.printView = window.open(method + '://www.texasteachers.org/blank.html','printView','left=20,top=20,width=700,height=700,toolbar=1,scrollbars=1,resizable=0');
	// write full html document with the content included
	top.printView.document.writeln(
		"<html>\n\n<head>\n  <title>Texas Teachers</title>\n  <base href=\"" + method + "://www.texasteachers.org/\" />" +
		"<link rel=\"stylesheet\" href=\"/includes/print.css\" type=\"text/css\" />\n</head>\n\n<body>\n\n" +
		"<div id=\"content\"><div class=\"top_header\"><img src=\"images/logo_print.gif\"></div><br>Phone: 713.458.1660\n" +
		"<div id=\"action-buttons\" class=\"print_buttons\" style=\"cursor: hand; \">\n" +
		"  <a onclick=\"javascript:window.print()\" title=\"Print This Window\">Print this window</a>\n" +
		" | " +
		"<a onclick=\"javascript:window.close()\" title=\"Close This Window\">Close this window</a></div>\n" +
		"<br /><br />\n\n" + contents.innerHTML + "\n\n</div></body></html>");
	// close text stream, tell browser loading has finished
	top.printView.document.close();
	
	return false;

}

// validates data in the Exam Comment Upload system
function commentValidation() {

	var allOk = true;
	var errorString = "Please fix the following before submitting:\n";
	
	if (!document.commentForm.materials.value) {
			allOk = false;
			errorString += "\n- Please describe the study materials you used.";
	}
	if (!document.commentForm.difficulty.value) {
			allOk = false;
			errorString += "\n- Please describe the test difficulties you experienced.";
	}

	if (!allOk) {
		alert(errorString);
	}
	
	return allOk;

}

function makeEmailLink(user) {
	var output = '<a href=\"mailto:'+user+'\@texasteachers.org?subject=Online Inquiry\">Email</a>';
	return output;
}