//Copyright "Ali Karimabadi" Email: Akarimabadi@gmail.com
//System Work indicator
var myGlobalHandlers = {
	onCreate: function(){
		if (window.innerHeight && window.scrollMaxY) {
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else {
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		if ($('systemWorking')) {
			$('systemWorking').style.top = '0 px';
			$('systemWorking').style.left = '0 px';
			$('systemWorking').style.height = (yScroll + 'px');
			$('systemWorking').style.width = (xScroll + 'px');
			$('systemWorking').innerHTML='<br><div align="center" dir="rtl" style="background-color:#FFFFFF;color:black;font-size:11px;font-family:verdana;border:1px solid #333333;padding-top:5px;padding-bottom:5px;"><b> لطفا چند لحظه صبر نمائید ... </b><br><img src="./images/progress1.gif" border="0"></div>';
			Element.show('systemWorking');
			new Effect.BlindDown('systemWorking');
		}
	},onComplete: function(){
			new Effect.BlindUp('systemWorking');
			//if(Ajax.activeRequestCount == 0){new Effect.BlindUp('systemWorking');}
	}
};
Ajax.Responders.register(myGlobalHandlers);

//window.onerror = function(){return true;} 

LoadPage=function(url,idl){var pars = '';
	$(idl).innerHTML='<div align="center" dir="ltr" style="font-size:11px"><b>Please Wait Loading... </b><br><img src="./images/progress.gif" border="0"></div>';
	var myAjax = new Ajax.Updater(idl, url, {method: 'get', parameters: pars,evalScripts:true, onFailure: function(t) {alert('Error in internet Connection: ' + t.status + ' -- ' + t.statusText);}});
}

sub_com=function(){
			var poststr='';
			for(var k=0;k<CF.elements.length;k++){
				poststr+='&'+CF.elements[k].name+'='+encodeURI(CF.elements[k].value);
			}

		var Proccess_comnt = {
		    // Use POST
		    method: 'post',
		    // Send this lovely data
		    postBody: 'AJAXED=1'+poststr,
		    // Handle successful response
		    onSuccess: function(t) {
		    },
		    // Handle 404
		    on404: function(t) {
		        alert('Error 404: location "' + t.statusText + '" was not found.');
		    },
		    // Handle other errors
		    onFailure: function(t) {
		        alert('Error ' + t.status + ' -- ' + t.statusText);
		    }
		}
		comnt_win.setDestroyOnClose();
		comnt_win.getContent().innerHTML='<center>Please Wait Loading...</center>';
		comnt_win.setAjaxContent('./acomment.php', Proccess_comnt, true, true);
		return false;
}

show_com=function(url){
		var Proccess_comnt = {
		    // Use POST
		    method: 'get',
		    // Send this lovely data
		    parameters: 'AJAXED=1',
			evalScripts:true,
		    // Handle successful response
		    onSuccess: function(t) {
		    },
		    // Handle 404
		    on404: function(t) {
		        alert('Error 404: location "' + t.statusText + '" was not found.');
		    },
		    // Handle other errors
		    onFailure: function(t) {
		        alert('Error ' + t.status + ' -- ' + t.statusText);
		    }
		}
		if (!$('comnt_win')) {
			comnt_win = new Window('comnt'+Math.round(100000*Math.random()), {className: "alphacube", title: "Comments", 
		                                              top:70, left:100, width:450, height:350,
		                                              resizable: true,showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff, showEffectOptions: {duration:1}});
		}
		comnt_win.setDestroyOnClose();
		comnt_win.getContent().innerHTML='<center>Please Wait Loading...</center>';
		comnt_win.setAjaxContent(url, Proccess_comnt, true, true);
		return false;
}

Load_img=function(url){
	if (!$('gallery_im_win')) {
		gallery_im_win = new Window('gallery'+Math.round(100000*Math.random()), {className: "alphacube", title: "View image", 
	                                              top:70, left:100, width:500, height:500,
	                                              resizable: true,showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff, showEffectOptions: {duration:1}});
	}
	gallery_im_win.setDestroyOnClose();
	gallery_im_win.getContent().innerHTML='<center><img src="'+url+'" border="0"></center>';
	gallery_im_win.showCenter(true);
}
sub_com2=function(){
			var poststr='';
			for(var k=0;k<CF.elements.length;k++){
				poststr+='&'+CF.elements[k].name+'='+encodeURI(CF.elements[k].value);
			}

		var Proccess_comnt = {
		    // Use POST
		    method: 'post',
		    // Send this lovely data
		    postBody: 'AJAXED=1'+poststr,
		    // Handle successful response
		    onSuccess: function(t) {
		    },
		    // Handle 404
		    on404: function(t) {
		        alert('Error 404: location "' + t.statusText + '" was not found.');
		    },
		    // Handle other errors
		    onFailure: function(t) {
		        alert('Error ' + t.status + ' -- ' + t.statusText);
		    }
		}
		center.innerHTML='<div align="center" dir="ltr" style="font-size:11px"><b>Please Wait Loading... </b><br><img src="./images/progress.gif" border="0"></div>';
		var myAjax = new Ajax.Updater('center', 'qa.php',Proccess_comnt );
		return false;
}
