
//This function is for switching beetwin two condtions of preloader division that you need to
//place in your page here the division name is: loading
function showLoad(show){
	if(show){
		$('loading').style.display="inline";
	}else{
		$('loading').style.display="none";
	}
};
//This is ajax function that you can use inside your page, the only parameter that
//i defined for this function is url, all the content of loaded url would be placed inside
//a division that is ajaxconatiner here. As you see evalscript is true and that is the only
//way that any Javascript can be executedinside the loaded content

function ajaxload(url){
	//call showload function to show preloader
    showLoad(true);
new Ajax(url, {
    //loaded content would be updated inside this division
	update: 'ajaxcontainer',
	//this should be true if you want to execute JS inside the loaded content
	evalScripts: true,
    onComplete:function(r)
    {
    //It sets the type property of the script tag, 
    //then puts the script body inside of the element (between the opening and closing script tags),
    //then injects into the head of the page
	var script = new Element('script')
    script.setProperty('type','text/javascript');
    script.setHTML(r);
    },
    onSuccess:function(){
        //This would disappear preloader div
        showLoad(false);
        //The ajaxlinks function is being called here,I defined this function in footer
        ajaxLinks();
    }
}).request();
}

//this function is for fading any division in our system
function fading(action,div){
FadingFx = new Fx.Style(div, 'opacity', {
	duration: 500, 
	transition: Fx.Transitions.quartInOut
});
	if(action){
        FadingFx.start.pass([1,0], FadingFx).delay(3000);
	}else{
		FadingFx.start.pass([0,1], FadingFx).delay(4000);
	}
}