jQuery(document).ready(function () { 
	var loaderParm = document.getElementById('loading');
	if (loaderParm == null) {
		//location.href="#top";
	 	 var loader = jQuery('<div id="loading"><div class="image"><img alt="Loading..." src="../../images/globe32.gif"/></div><div class="load">Loading ...</div></div>')
		  //.css({position: "relative", top: "1em", left: "1em"})
		  .hide()
		  .appendTo("body");
		$().ajaxStart(function() {
			loader.show();
		}).ajaxStop(function() {
			loader.hide();			
		});		  
	}
});  
 
 
/* 
 var application = function () {
 // Private functions and data go here.

 return {
   // Public functions and data go here.
   HTTP_CONFLICT: 409,

   // Show the user a quick little message.
   showAjaxNotification: function(text) {
     $("#loading").text(text).show();
	 //document.write('<div id="loading"><div class="image"><img alt="Loading..." src="../../images/ajaxLoading.gif"/></div><div class="load">Loading ...</div></div>');
   },

   // Hide the message.  If possible, use hideAjaxNotificationIfMatches
   // instead.
   hideAjaxNotification: function() {
     $("#loading").hide().text("");
   },

   // Hide the message, but only if it matches the given text.
   hideAjaxNotificationIfMatches: function(text) {
     if ($("#loading").text() == text) {
       application.hideAjaxNotification();
     }
   }
 };
}();

$(document).ready(function() {


	var loadingMessage = jQuery('<div id="loading"><div class="image"><img alt="Loading..." src="../../images/ajaxLoading.gif"/></div><div class="load">Loading ...</div></div>')
	//var loadingMessage = "Loading...";

 // When an Ajax request is being made, tell the user "Loading...".
 $(this).ajaxStart(function() {
   application.showAjaxNotification(loadingMessage);
 });

 // Only if it completes normally do we hide the message.
 $(this).ajaxSuccess(function() {
   application.hideAjaxNotificationIfMatches(loadingMessage);
 });

 // Otherwise, we give the user an error message.
 $(this).ajaxError(function(event, xhr, ajaxOptions, thrownError) {

   // If we get an HTTP_CONFLICT, it means our data is stale.  Reload the
   // page.  To test this functionality, use two tabs in your browser.
   if (xhr.status == application.HTTP_CONFLICT) {
     location.reload();
   }

   // Otherwise, just tell the user something went wrong.
   else {
     application.showAjaxNotification("Request failed: could not contact server");
   }
 });
});
 
 */ 																

/*  $.ajaxSetup({ 'ajaxStart': function(){
  $("#loading").show();
}, 'ajaxStop': function(){
  $("#loading").hide();
}}); */

var please_wait = null;
var xmlHttp = null;

try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
} catch (e) {
    // Internet Explorer
    try {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
}

function open_url(url, target) {
 	if ( ! document.getElementById) {
  		return false;
 	}

 	if (please_wait != null) {
  		document.getElementById(target).innerHTML = please_wait;
 	}

 	if (window.ActiveXObject) {
  		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
 	} else if (window.XMLHttpRequest) {
  		xmlHttp = new XMLHttpRequest();
 	}

 	if (xmlHttp == undefined) {
  		return false;
 	}
 	xmlHttp.onreadystatechange = function() { response(url, target); }
 	xmlHttp.open("GET", url, true);
 	xmlHttp.send(null);
}

function response(url, target) {
 	if (xmlHttp.readyState == 4) {
	 	document.getElementById(target).innerHTML = (xmlHttp.status == 200) ? xmlHttp.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the fallowing errorcode: " + xmlHttp.status;
	}
}

function set_loading_message(msg) {
 	please_wait = msg;
}

function validateForm(idform, actionform, target) {
    var form = document.getElementById(idform);
	form.action = actionform;
	form.submit();
	open_url(actionform, target);
}
function open_url_to_home(pageAction, scriptAction) {
   jQuery.get(pageAction,function(data) {
   $("#banner").css("display","block");
		$("#tableview").html(data);
        jQuery.getScript(scriptAction,function (data) {
        });
   });	  
}
function open_url_to_div(pageAction, scriptAction) {
   jQuery.get(pageAction,function(data) {
   $("#banner").css("display","none");
		$("#tableview").html(data);
        jQuery.getScript(scriptAction,function (data) {
        });
   });	  
}
function open_url_to_div_reg(pageAction, scriptAction) {
   jQuery.get(pageAction,function(data) {
		$("#main").html(data);
		$("#box-login").css("display","none");
        jQuery.getScript(scriptAction,function (data) {

        });
   });	  
}
function open_url_to_div2(pageAction, scriptAction, scriptAction2) {
   var opt = { md:scriptAction2 }
   jQuery.get(pageAction, opt, function(data) {
		$("#tableview").html(data);
        jQuery.getScript(scriptAction,function (data) {
        });
   });	   

}
/*
function backToIndex() {
	url = ""
	var opt = {};
	jQuery.get(url,opt,function(data) {
		$("#container").html(data);
		});   

}
*/

function backToIndex(pageAction) {
   jQuery.get(pageAction,function(data) {
		$("#container").html(data);
		$("#box-login").css("display","none");

   });	  
}



