var redirURL = '';
var Functions = {
	load: function(d){
		$('#'+response_div).html('');
		$('html, body').animate({scrollTop: $('#site').offset().top},
			function(){
				$('#'+content_div).animate({height:'hide'},
					function(){
						$('#'+loader_div).fadeIn(
							function(){
								$('#'+response_div).html('');
								$('#'+content_div).animate({height:'hide'},
									function(){
										$.get(cf+'.php?action='+d,
											function(p){
												$('#'+loader_div).fadeOut(
													function(){
														$('#'+content_div).html(p).animate({height:'show'});
													});
											},'script');
									});
							});
					});
			});
	},
	form_send:function(v){
		$('#'+response_div).html('');
		$('#'+content_div).animate({height:'hide'},
			function(){
				$('#'+loader_div).fadeIn(
					function(){
						$('#'+content_div).animate({height:'hide'},
							function(){
								$.getJSON(cf+'.php?'+v,
									function(d){
										$('#'+loader_div).fadeOut(
											function(){
												if(d.status == 1){
													$('#'+response_div).html(d.msg);
													$('#'+response_div).animate({height:'show'});
													if(d.call == 'reload'){
														Functions.reload_it();
													}
													if(d.call != 'reload'){
														setTimeout("Functions.load('"+d.call+"');",1000);
													}
												}
												if(d.status == 0){
													$('#'+response_div).html(d.msg);
													$('#'+response_div).animate({height:'show'},
													function(){
														$('#'+content_div).animate({height:'show'});
													});
												}
											});
									});
							});
					});
			});
	},
	frame_send : function(a){
		$('html, body').animate({scrollTop: $('#main').offset().top},
			function(){
				$('#'+content_div).animate({height:'hide'},
					function(){
						$('#'+loader_div).fadeIn(
							function(){
								Functions.goto(cf+'.php?'+a,'iframe');	
							});
					});
			});
	},
	framed_response : function(d){;
		$('#'+response_div).hide();
		$('#'+loader_div).fadeOut(
			function(){
				$('#'+response_div).html(d.msg).animate({height:'show'});
				if(d.call){
					setTimeout("Functions.load('"+d.call+"');",1000);
					setTimeout("$('#"+response_div+"').fadeOut();",1000);	
				}
		});
	},
	goto:function(_url, _target) {
		window.open(_url, _target);
	},
	redirect:function() {
		this.goto(redirURL, '_self');
	},
	reload_it:function() {
		document.location.reload();
	}
}