var xOut = new Image(); xOut.src = "/img/xOut.png";
var xOver= new Image(); xOver.src= "/img/xOver.png";
var xDown= new Image(); xDown.src= "/img/xDown.png";

function writeErrDiv() {
	//~ var str = ""
	//~ + "<div id=\"errorDiv\" class=\"alertDiv\" style=\"display:none; z-index:6000;\">"// position:fixed; top:35%; left:30%; z-index:60000;\">" //
		//~ + "<div class=\"alertHead\" style=\"height:20px; background-image:url('/img/tableHead.gif'); background-repeat:repeat-x;\">Feedback"
			//~ + "<div style='position:absolute; top:2px; right:5px; cursor:pointer;' onmouseover=\"document.getElementById('feedback_x').src=xOver.src;\" onmouseout=\"document.getElementById('feedback_x').src=xOut.src;\" onmousedown=\"document.getElementById('feedback_x').src=xDown.src;\" onmouseup=\"document.getElementById('feedback_x').src=xOut.src; toggleErrMsg();\"><img id=\"feedback_x\" src='/img/xOut.png'></div>"
		//~ + "</div>"
		//~ + "<form id=\"errorForm\" onsubmit=\"errorSubmit();\" method=\"post\" action=\"feedback_send.php\">"
			//~ + "<select style=\"display:none\" name=\"type\"><option value=\"Error\">User Reported Error</option></select>"
		 	//~ + "<input style=\"display:none\" id=\"page_cont\" name=\"page_cont\" type=\"text\">"
		 	//~ + "<input style=\"display:none\" id=\"flsver\" name=\"flsver\" type=\"text\">"
		 	//~ + "<input style=\"display:none\" name=\"subject\" type=\"text\" value=\"User submitted error\"/>"
		 	//~ + "<div class=\"alertBody\">An error report will be sent to Course Hero staff with the details of the page you are viewing. If you'd like to add additional comments about the problem, please type them in the box below:</div>"
		 	//~ + "<div class='alertText'>Comment:<br>"
		 	//~ + "<textarea id=\"comment_rep\" class=\"alertTextArea\" name=\"comment\" rows=5 cols=30></textarea>"
			 	//~ + "<input id=\"nocheck\" name=\"nocheck\" type=\"hidden\" value=\"true\">"
			    //~ + "<div style=\"float:right; margin-top:10px;\">"
			    	//~ + "<div style='float:right; margin-left:20px;'>"+btn1+"</div>"
			    	//~ + "<div style='float:right;'>"+btn2+"</div>"
			    	//~ //+ "<span class=\"btn\"><input type=\"submit\" id=\"errorOk\" value=\"Ok\"></span>"
			    	//~ //+ "<span class=\"btn\"><input type=\"submit\" id=\"errorClose\" value=\"Cancel\" onclick=\"toggleErrMsg();\"></span>"
				//~ + "</div>"
				//~ + "<br class=\"clear\">"
			//~ +"</div>"
	    //~ + "</form>"
	 //~ +"</div>"
	 //~ +"<div id=\"errWashOut\" style=\"background-color:#000000; opacity: 0.5; filter:alpha(opacity=50); position:fixed; left:0%; top:0%; width:100%; height:100%; z-index:50000; display:none;\"></div>"
    var str = "<div style=\"text-align:left; padding:0 5px 0 5px;\">Course Hero has recorded the webpage that you are currently viewing. Please provide your comments (e.g., help questions, feature suggestions, website errors) in the text box below. Thank you for providing feedback."
        + "</div><br />    <form id=\"errorForm\" onsubmit=\"errorSubmit();\" method=\"post\" action=\"feedback_send.php\">        <select style=\"display:none\" name=\"type\"><option value=\"Error\">User Reported Error</option></select>"
        + "<input style=\"display:none\" id=\"page_cont\" name=\"page_cont\" type=\"text\">        <input style=\"display:none\" id=\"flsver\" name=\"flsver\" type=\"text\">        <input style=\"display:none\" name=\"subject\" type=\"text\" value=\"User submitted error\"/>"
        + "<input id=\"nocheck\" name=\"nocheck\" type=\"hidden\" value=\"true\">    <textarea id=\"comment_rep\" class=\"alertTextArea\" name=\"comment\" rows=7 cols=55></textarea>    </form>";

	document.write(str);
	}

function toggleErrMsg() {
	setErrPos();
	var el = document.getElementById('errorDiv');
	var bg = document.getElementById('errWashOut');
	if (el.style.display == "none") {
		el.style.display = "inline";
		//if (bg != null) bg.style.display = "inline";
		}
	else {
		el.style.display = "none";
		//if (bg != null) bg.style.display = "none";
		}
	}
function sendErrMsg() {
	document.getElementById('errorForm').submit();
	}
function setErrPos() {
	var errWidth = 440;
    var errHeight = 324;
	//get window width and height!
    var winWidth = 0, winHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) { //non-ie
        winWidth = window.innerWidth;
        winHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //ie 6+
        winWidth = document.documentElement.clientWidth;
        winHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //ie 4
        winWidth = document.body.clientWidth;
        winHeight = document.body.clientHeight;
    }
    //get scroll left and right!
    var sX = (document.all)?document.documentElement.scrollLeft:window.pageXOffset;
    var sY = (document.all)?document.documentElement.scrollTop:window.pageYOffset
    //calculate where the err should go!
    var leftPos = sX+winWidth/2 - errWidth/2;
    var topPos = sY+winHeight/2 - errHeight/2;
    
    //placement!
    var el = document.getElementById('errorDiv');
    if (el) {
    	el.style.left = leftPos+"px";
    	el.style.top = topPos+"px";
    	}
	}