function alertwindow(w, h){ // LawsLoop Alert
var windowwidth=0;windowheight=0; // Work out screen dimensions:
if (typeof(window.innerWidth)=='number'){windowheight=window.innerHeight;windowwidth=window.innerWidth;} else if(document.documentElement && (document.documentElement.clientWidth)){windowheight=document.documentElement.clientHeight;windowwidth=document.documentElement.clientWidth;} else if(document.body && (document.body.clientWidth)){windowheight=document.body.clientHeight;windowwidth=document.body.clientWidth;}
var widthscroll=0, heightscroll=0; // Work out scroll position
if( typeof(window.pageYOffset)=='number'){heightscroll=window.pageYOffset;widthscroll=window.pageXOffset;} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)){heightscroll=document.body.scrollTop;widthscroll=document.body.scrollLeft;} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){heightscroll=document.documentElement.scrollTop;widthscroll = document.documentElement.scrollLeft;}
yWithScroll=windowheight; // Work out scroll height. 
if (window.innerHeight && window.scrollMaxY){yWithScroll = window.innerHeight + window.scrollMaxY;} else if (document.body.scrollHeight > document.body.offsetHeight){yWithScroll = document.body.scrollHeight;} else {yWithScroll = document.body.offsetHeight;}

var div=document.getElementById("alertbox");

if (w > 0 && h > 0){ // Stops inner area being removed on resize
div.innerHTML="<table width=\"100%\" height=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><table width=\"100%\" height=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"background-color:#FFFFFF;border-left:1px solid #464646;border-top:1px solid #464646;\"><span style=\"font-size:1px;line-height:1px;\">&nbsp;<\/span><\/td><td style=\"background-color:#FFFFFF;border-top:1px solid #464646;border-right:1px solid #464646;\"><span style=\"font-size:1px;line-height:1px;\">&nbsp;<\/span><\/td><td width=\"6\" height=\"6\"><img src=\"/images/layout/cnr/shade/tr.png\" style=\"width:6px;height:6px;\"><\/td><\/tr><tr><td style=\"background-color:#FFFFFF;border-left:1px solid #464646;border-bottom:1px solid #464646;\"><span style=\"font-size:1px;line-height:1px;\">&nbsp;<\/span><\/td><td valign=\"top\" style=\"padding-right:5px;padding-bottom:5px;background-color:#FFFFFF;border-right:1px solid #464646;border-bottom:1px solid #464646;\" class=\"left\" id=\"alerttext\"><\/td><td width=\"6\" style=\"background: url(/images/layout/cnr/shade/right.png) repeat-y top left;\" valign=\"top\"><\/td><\/tr><tr><td width=\"6\" height=\"6\"><img src=\"/images/layout/cnr/shade/bl.png\" style=\"width:6px;height:6px;\"><\/td><td width=\"100%\" style=\"height:6px;background: url(/images/layout/cnr/shade/bottom.png) repeat-x top left;\"><span style=\"font-size:1px;line-height:1px;\">&nbsp;<\/span><\/td><td width=\"6\" height=\"6\"><img src=\"/images/layout/cnr/shade/br.png\" style=\"width:6px;height:6px;\"><\/td><\/tr><\/table></td><td valign=\"top\" class=\"left\" width=\"22\"><a href=\"javascript:void(0);\" onClick=\"alertclose();\"><img src=\"/images/layout/icons/_small_close.png\" style=\"width:22px;height:22px;\"></a><\/td><\/tr><\/table>";
if (browser != "Microsoft Internet Explorer"){fadeIn('alertbox');} else {div.style.display="block";}document.getElementById("bg").style.display="block"; document.getElementById("bg").style.height=yWithScroll+"px"; // Creates grey bg full screen
}

if ((w > 0) && (h > 0)){div.style.height=h+"px";div.style.width=w+"px";document.getElementById("alerttext").style.height=h+"px";} else {w=div.style.width;var w = w.replace(/px/g, "");h=div.style.height;var h = h.replace(/px/g, "");}

var left = (windowwidth/2)-(w/2)+widthscroll-22;var top = (windowheight/2)-(h/2)+heightscroll-(h/15);
div.style.left=left+"px";div.style.top=top+"px";
}
function alerttext(text){document.getElementById("alerttext").innerHTML=text;}
function alertclose(){document.getElementById("bg").style.display="none";if (browser != "Microsoft Internet Explorer"){fadeOut('alertbox');} else {document.getElementById("alertbox").style.display="none";}}








function alert_quote(val1){selected(val1);alertwindow(650, 210);alerttext('<strong>Loading Post...</strong>');alertbox_ajax(1);}
function alert_updates(val1){selected(val1);alertwindow(800, 285);alerttext('<strong>Loading Updates...</strong>');loadScript("/_js/js_updates.js", function(){update_ajax(2);});}
function alert_register(){alertwindow(368, 345);alerttext('<strong>Loading Registration Form...</strong>');loadScript("/_js/js_details.js", function(){alertbox_ajax(2);});}
function alert_mail(val1){alertwindow(650, 450);alerttext('<strong>Loading Mail...</strong>');loadScript("/_js/js_mail.js", function(){if(val1){selected(val1);mail_ajax(3);} else {mail_ajax(1);}});}
function alert_acc_settings(){alertwindow(650, 450);alerttext('<strong>Loading Account Settings...</strong>');loadScript("/_js/js_accountsettings2.js", function(){acc_settings_ajax(1);});}


var xmlHttp;
function alertbox_ajax(opt){
try {xmlHttp=new XMLHttpRequest();}  // Firefox, Opera 8.0+, Safari  
	catch (e){try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");} // Internet Explorer
		catch (e){try {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
			catch (e) {alert("Your browser does not support AJAX!");return false;}
			}
		}



if (opt == 1){var val=document.getElementById('selected').innerHTML;var queryString = "method=11&val=" + val +"&upd=" + new Date().getTime();xmlHttp.open("POST", "/_ajax/ajax.php", true);} // Quote Retrieval
if (opt == 2){var queryString = "method=14&upd=" + new Date().getTime();xmlHttp.open("POST", "/_ajax/ajax.php", true);} // Retrieve Reg. Form

			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlHttp.setRequestHeader("Content-length", queryString.length);
			xmlHttp.setRequestHeader("Connection", "close");
			xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {


if (opt == 1){var ajaxDisplay = document.getElementById('alerttext');ajaxDisplay.innerHTML = xmlHttp.responseText;} // Quote Retrieval
if (opt == 2){var ajaxDisplay = document.getElementById('alerttext');ajaxDisplay.innerHTML = xmlHttp.responseText;reg_makepage('make_new_page_p_title', 'make_new_page_p_text');} // Retrieve Reg. Form


			}
			}
		xmlHttp.send(queryString);
		}
