var BalloonImg = AJAX_IMAGES_PATH + "freccia.gif";
var BalloonImg2 = AJAX_IMAGES_PATH + "frecciad.gif";
var LoadingImg = AJAX_IMAGES_PATH + "loadspin.gif";
var OverlayImg = AJAX_IMAGES_PATH + "overlay.png";
var CloseImg = AJAX_IMAGES_PATH + "closepl.gif";

var objspinner = false;
function getXmlHttpRequestObject() {
 if (window.XMLHttpRequest) {
    return new XMLHttpRequest(); //Mozilla, Safari ...
 } else if (window.ActiveXObject) {
    return new ActiveXObject("Microsoft.XMLHTTP"); //IE
 } else {
    //Display our error message
    alert("Your browser doesn't support the XmlHttpRequest object.");
 }
}

//Our XmlHttpRequest object
var receiveReq = getXmlHttpRequestObject();



//Initiate the AJAX request
function makeRequest(url, param) {

   receiveReq.onreadystatechange = function(){


    if(receiveReq.readyState == 0 ){


var image = AJAX_IMAGES_PATH + "loadspin.gif";;

document.getElementById('overlay1').innerHTML ="<div id=\"overlay\" style=\"background-color: #C0C0C0; position: fixed; z-index: 90; width: 100%; height: 100px; bottom: 357px; visibility: visible; left: 0px;\"></div><div style=\"position: absolute; left: 26px; top: 49px; width: 824px; height: 349px; z-index: 91\"><div style=\"position: absolute; width: 131px; height: 131px; z-index: 1; left: 368px; top: 131px; text-align: center;\"><img alt=\"\" src=\"loadspin.gif\" /><br /><br /><br /><br />Loading...</div></div>";



    }
    if(receiveReq.readyState == 4){
	
 
 
 var objOverlay = document.getElementById('overlay');
// var objloading = document.getElementById('loading');
 // var objlightbox = document.getElementById('lightbox');
 //  var objspinner = document.getElementById('spinner');
   
	objOverlay.style.display = 'none';

// objloading.style.display = 'none';
// objlightbox.style.display = 'none';
//objspinner.style.display = 'none';

        var response = receiveReq.responseText;
        document.getElementById('signin').innerHTML = response;
    }
}


	receiveReq.open("POST", url, true);
   receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   //receiveReq.setRequestHeader("Content-length", param.length);

  // receiveReq.setRequestHeader("Connection", "close");

   //Make the request
   receiveReq.send(param);
 //receiveReq.send(parame);
   
}


function getParam(theForm) {
var url = 'index.php?ind=guestbook&op=signin';
var postStr = "";
var names = "";
postStr = theForm.name.name + "=" + encodeURIComponent( theForm.name.value ) + "&";
postStr += theForm.email.name + "=" + encodeURIComponent( theForm.email.value );
var input = document.getElementsByTagName('input');
for (i = 0; i < input.length; i++){
	if(input[i].id == "wino"){
if(input[i].value ==''){
	
if(input[i].name == 'name') {
	
alert(nameerror)	
} 	
if(input[i].name == 'email') {
	
alert(emailerror)	
} 	
if(input[i].name == 'location') {
	
alert(locationerror)	
} 	
if(input[i].name == 'url') {
	
alert(homeerror)	
} 

return false
}
	names += input[i].name +"="+ input[i].value +"&";}
}
if(theForm.message.value ==''){
alert(messerror)
return false
}
if(theForm.shown.checked == true){
names += theForm.shown.name + "= 1&";;
}
if(theForm.shown.checked == false){
names += theForm.shown.name + "= 0&";
}
var selIdx = theForm.gender.selectedIndex;
var newSel = theForm.gender.options[selIdx].value;
names += theForm.gender.name + "=" + encodeURIComponent( newSel )+"&";
names += theForm.message.name + "=" + encodeURIComponent( theForm.message.value );
if(ValidateEmail(theForm.email)==false){
alert(vailderror)
return false
}

//Call the function that initiate the AJAX request
makeRequest(url, names);
}


function ValidateEmail(theinput)
{
	var s=theinput.value
	if(s.search)
	{
		return (s.search(new RegExp('^([-!#$%&\'*+./0-9=?A-Z^_`a-z{|}~'+unescape('%7F')+'])+@([-!#$%&\'*+/0-9=?A-Z^_`a-z{|}~'+unescape('%7F')+']+\\.)+[a-zA-Z]{2,6}$','gi'))>=0)
	}
	if(s.indexOf)
	{
		var at_character=s.indexOf('@')
		if(at_character<=0 || at_character+4>s.length)
			return false
	}
	if(s.length<6)
		return false
	else
		return true
}






var MkUtilsLib = {

	getPageScroll: function()
	{
		var yScroll;
		if(self.pageYOffset)
		{
			yScroll = self.pageYOffset;
		}
		else if(document.documentElement && document.documentElement.scrollTop) // Explorer 6
		{
			yScroll = document.documentElement.scrollTop;
		}
		else if(document.body) // all other Explorers
		{
			yScroll = document.body.scrollTop;
		}
		arrayPageScroll = new Array('',yScroll);
		return arrayPageScroll;
	},

	getPageSize: function()
	{
		var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
	}

}
