// JavaScript Document
function paradocsize(){
	var b=document.body, e=document.documentElement;
	var esw = 0, eow = 0, bsw = 0, bow = 0, esh = 0, bsh = 0, boh = 0;
	if (e){
		esw = e.scrollWidth;
		eow = e.offsetWidth;
		esh = e.scrollHeight;
		eoh = e.offsetHeight;
		eth = e.scrollTop;
	}
	if (b){
		bsw = b.scrollWidth;
		bow = b.offsetWidth;
		bsh = b.scrollHeight;
		boh = b.offsetHeight;
		bth = b.scrollTop;
	}
	return {w:Math.max(esw,eow,bsw,bow),h:Math.max(esh,eoh,bsh,boh),s:Math.max(eth,bth)};
}

function paragetdocument(URL){
	if (window.XMLHttpRequest) { // Mozilla, Safari
		http_request = new XMLHttpRequest();
		 if (http_request.overrideMimeType) {
			// set type accordingly to anticipated content type
			http_request.overrideMimeType('text/html');
		 }
	} else if (window.ActiveXObject) { // Internet Explorer
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
		
	if (!http_request){
		alert("Your browser does not support AJAX methods, in order to use this website you will need to upgrade your browser.");
		return false;
	}
		
	http_request.onreadystatechange = outputdocument;
	http_request.open("GET", URL, true);
	http_request.send(null);
}

function paracommentsubmit(URL){
	// used for the article comments
	if (window.XMLHttpRequest) { // Mozilla, Safari
		http_request = new XMLHttpRequest();
		 if (http_request.overrideMimeType) {
			// set type accordingly to anticipated content type
			http_request.overrideMimeType('text/html');
		 }
	} else if (window.ActiveXObject) { // Internet Explorer
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
		
	if (!http_request){
		alert("Your browser does not support AJAX methods, in order to use this website you will need to upgrade your browser.");
	} else {
	
		// validate form
		ERROR = "";
		if (document.getElementById("name").value.length < 1)ERROR = ERROR + "Your name is missing.\n";
		if (document.getElementById("verification").value.length < 1)ERROR = ERROR + "Your verification code is missing.\n";
		if (document.getElementById("comments").value.length < 1)ERROR = ERROR + "Your comments are missing.\n";
		
		var THEFIELD = document.article_comment_form.rating;
		for (i=0; i < THEFIELD.length; i++) {
				if (THEFIELD[i].checked){
					var RATING = i+1;
				}
		}

		var postSTR = 	"?id=" + encodeURI(document.getElementById("articleid").value) +
						"&name=" + encodeURI(document.getElementById("name").value) + 
						"&website=" + encodeURI(document.getElementById("website").value) + 
						"&rating=" + encodeURI(RATING) + 
						"&verification=" + encodeURI(document.getElementById("verification").value) +
						"&comments=" + encodeURI(document.getElementById("comments").value);
		
		if (ERROR == ""){	
			http_request.onreadystatechange = paracommentoutput;
			http_request.open("GET", URL + postSTR, true);
			http_request.send(null);
		} else {
			alert("Error's where found with your submission.\n"+ERROR+"Please correct and try again.");
		}
	}
}

function paracommentoutput(){
	var browserName=navigator.appName; 
	var ds=paradocsize();
	if (ds.s > 0){
		TOP = parseFloat(ds.s + 10) + "px";
	} else {
		TOP = 10 + "px";
	}

	LEFT = parseFloat(ds.w / 2);
	pabl = document.getElementById("paramiliar_overlay");
	pacl = document.getElementById("Paramiliar_overlaycont");
		
	pacl.style.width = "500px";
	pacl.style.top = TOP;
	pacl.style.left = parseFloat(LEFT - 250)+"px"; // half of the width
	pacl.style.position = "absolute";
	pacl.style.zindex = "1000001";
	pacl.style.backgroundColor = "#FFFFFF";
	pacl.style.border = "2px solid #000000";

	if (browserName=="Microsoft Internet Explorer"){ 
		HEIGHT = ds.h - 5;
		WIDTH = ds.w - 22;
	} else {
		HEIGHT = ds.h;
		WIDTH = ds.w;
	}

	// setup bg alert layer
	pabl.style.left = '0px';
	pabl.style.top = '0px';
	pabl.style.position = "absolute";
	pabl.style.width = WIDTH+"px";
	pabl.style.height = HEIGHT+"px";
	pabl.style.backgroundColor = "#000000";
	pabl.style.zindex = "1000000";
	pabl.style.filter = "alpha(opacity=65)";
	pabl.style.mozOpacity = ".65";
	pabl.style.opacity = ".65";

	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			// output is 0/1|HTMLDATA
            result = http_request.responseText;
			DATA = result.split("|");
			if (DATA[0] == "0"){
				hidelayers();
				location.reload(true)
			} else {
				pacl.innerHTML = "<div style=\"padding:5px; border:1px solid #254394; background-color:#FFFFFF;\">We are sorry but there are errors in your submission.<br />"+DATA[1]+".<br />Please try again.<br /><input type=\"button\" id=\"closewindow\" name=\"closewindow\" value=\"Close\" onclick=\"hidelayers();\" /></div>";
				pabl.style.display = "block";
				pacl.style.display = "block";		
			}
		} else {
			pacl.innerHTML = "<div style=\"padding:5px; border:1px solid #254394; background-color:#FFFFFF;\">We are sorry but we where unable to complete your request at present.<br />Please try again later."+http_request.status+"<br /><input type=\"button\" id=\"closewindow\" name=\"closewindow\" value=\"Close\" onclick=\"hidelayers();\" /></div>";
			pabl.style.display = "block";
			pacl.style.display = "block";
		}
	}
}
	

function outputdocument(){
	var browserName=navigator.appName; 
	var ds=paradocsize();
	if (ds.s > 0){
		TOP = parseFloat(ds.s + 10) + "px";
	} else {
		TOP = 10 + "px";
	}

	LEFT = parseFloat(ds.w / 2);
	pabl = document.getElementById("paramiliar_overlay");
	pacl = document.getElementById("Paramiliar_overlaycont");
		
	pacl.style.width = "500px";
	pacl.style.top = TOP;
	pacl.style.left = parseFloat(LEFT - 250)+"px"; // half of the width
	pacl.style.position = "absolute";
	pacl.style.zindex = "1000001";
	pacl.style.backgroundColor = "#FFFFFF";
	pacl.style.border = "2px solid #000000";
	
	
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            pacl.innerHTML = result;
		} else {
			pacl.innerHTML = "<div style=\"padding:5px; border:1px solid #254394; background-color:#FFFFFF;\">We are sorry but we where unable to complete your request at present.<br />  Please try again later.<br /><input type=\"button\" id=\"closewindow\" name=\"closewindow\" value=\"Close\" onclick=\"hidelayers();\" /></div>";
		}
		pacl.style.display = "block";		
	}


	var ds=paradocsize();
	
	if (browserName=="Microsoft Internet Explorer"){ 
		HEIGHT = ds.h - 5;
		WIDTH = ds.w - 22;
	
	} else {
		HEIGHT = ds.h;
		WIDTH = ds.w;
	}

// setup bg alert layer
	pabl.style.left = '0px';
	pabl.style.top = '0px';
	pabl.style.position = "absolute";
	pabl.style.width = WIDTH+"px";
	pabl.style.height = HEIGHT+"px";
	pabl.style.backgroundColor = "#000000";
	pabl.style.zindex = "1000000";
	pabl.style.filter = "alpha(opacity=65)";
	pabl.style.mozOpacity = ".65";
	pabl.style.opacity = ".65";
	pabl.style.display = "block";
		
	// setup content alert layer
}

	
function hidelayers(){
	pabl = document.getElementById("paramiliar_overlay");
	pacl = document.getElementById("Paramiliar_overlaycont");	
	pabl.style.display = "";
	pacl.style.display = "";
}