/**
 * @author Jon Richmond Albis
 * @since July 17, 2010
 * @desc functions that uses the modal window
 */

var myDialog;
function createModal(){
	try {
		myDialog = new ModalDialog("myDialog",1000);
	}catch(e) {
		alert("error : " + e);
	}
}
function showMyDialog() {
	try {
		myDialog.show();		 
		//$("#backscreen").css("display","block");
		//setBackScreenHeight();
		 
	}catch(e) {
		alert("Error :: " + e);
	}
}

 
 
function hideMyDialog() {		
	try {
		myDialog.hide();
		$("#backscreen").css("display","none");
	}catch(e) {
		alert("Error :: " + e);
	}
}

function setBackScreenHeight() {
	$("#backscreen").height($(document).height() + "px");
	$("#backscreen").width($(document).width() + "px");
}




var xmlhttp;

function GetXmlHttpObject(){
	if (window.XMLHttpRequest){
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject){
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}


function stateChanged(){
	if (xmlhttp.readyState==4){
		var result = xmlhttp.responseText;
		var tempString = "";
		var tempLocation = "";
		
		for(x = 0; x < 8; x++) {
			tempString += result.charAt(x);
		}
		
		if(tempString == "redirect") {
			for(x = 9; x < result.length; x++) {
				tempLocation += result.charAt(x);
			}
		}
		
		if(tempLocation != "") {
			location.href = tempLocation;
		}else {
			document.getElementById("result").innerHTML=xmlhttp.responseText;
		}
		
	}
}
