
$(document).ready(function()
{
  $("#loading").bind("ajaxSend", function() {
    $(this).show();
 	}).bind("ajaxComplete", function() {
  $(this).hide();
 	});
})


// Load a URL with an XML-http request, with parameters passed to this URL, using AJAX & JQuery, with a fading animation.
//  function loadAJAX (file,object) {
// $("#"+object).hide();
// $("#"+object).load (file, function(){
//  $("#"+object).fadeIn("slow");
//  }); 
//  return file;
//  return object;
//  }
function loadAJAX (file,object) {
//  $(document).ready(function() {
//    $.get(file, function(contents){
//    var div = document.getElementById(object);  
//      //div.innerHTML = contents;
//      var x = contents.getElementsByTagName("script");
//		  var h = document.getElementsByTagName("head")[0];
//		  for(var i=0;i<x.length;i++) {
//			var s = document.createElement("script");
//			s.type="text/javascript";
//			if(x[i].src != '') {
//       s.src = x[i].src;
//			}
//			h.appendChild(s);
//		/	s.text=x[i].text;
//		}
//   });
//  });
  
 $("#"+object).hide();
 $("#"+object).load (file, function(){
  $("#"+object).fadeIn("slow");
  document.getElementById("loader_anim").style.display='none';
  });
  $("#"+object).load (file, function() {
    $("#"+object+" :select").uniform();
  	$("#"+object+" :radio").uniform();
  	$("#"+object+" :checkbox").uniform();
  });
  return file;
  return object;
}

// Same function as above, but without the fading animation, to avoid z-index and textarea focus issues, with TinyMCE and other libraries/editors.
function loadAJAX_no_anim (file,object) { 
  $("#"+object).load (file);
  return file; 
  return object; 
}

// Post data to a URL and then load this URL, using AJAX & JQuery.
function postAJAX(postdata,file,object){
  $("#"+object).hide();
   $.ajax({
   type: "POST",
   url: file,
   data: postdata,
   success: function(msg){
     $("#"+object).html(msg);
     $("#"+object).fadeIn();
   }
 });
}


// Same function as above, without the fading animation
function postAJAX_noanim(postdata,file,object){
   $.ajax({
   type: "POST",
   url: file,
   data: postdata,
   success: function(msg){
     $("#"+object).html(msg);
     return file; 
     return object
   }
 });
}


// Clients login function
function do_login() {
  var username = document.getElementById("username").value;
  var password = document.getElementById("password").value;
  var post_data = "username="+username+"&password="+password;
  var post_url = "mini_login.php";
  var post_login_div_element = 'mini_login';
  //loadAJAX('http://www.imonline.gr/images/loading.php',post_login_div_element);
  postAJAX(post_data,post_url,post_login_div_element);
}


// Load the "Coverflow"
function loadcoverflow () {
  $("#coverflow_inside").html('<iframe id="coverflow_scroller" scrolling="no" frameborder="0" topmargin="0" leftmargin="0" style="0px #000000 solid; overflow: hidden; width: 1000px; height: 309px; background-color: transparent;" allowtransparency="true"></iframe>');
  $('#coverflow_scroller').attr('src', 'http://mbs.edu.gr/includes/3rd_party/xflow/xflow.php');
}

