
//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
	window.scrollTo(0,100);
	document.getElementById('ajaxcontainer').innerHTML='';
	

    showLoad(true);
	try
	{
		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');
				try
				{
					script.setHTML(r);
				}
				catch(e)
				{
				
				}
			},
			onSuccess:function(){
				try
				{
					//The ajaxlinks function is being called here,I defined this function in footer
					ajaxLinks();
					//This would disappear preloader div
					iniciaObjeto($('ajaxcontainer'));
					showLoad(false);
					efecto($('ajaxcontainer'));
					
					ajaxloadLeftColumn(url);
				}
				catch(e)
				{	
						
				}				
			}
		}).request();
	}
	catch(e)
	{	
		
	}
}


function ajaxloadLeftColumn(url){
	$('ajaxleft').innerHTML=$('loading2').innerHTML;
	//call showload function to show preloader		
	try
	{		
		url = url.replace('index2.php','mod_left.php');
		new Ajax(url, {
			//loaded content would be updated inside this division
			update: 'ajaxleft',
			//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');
				try
				{					
					script.setHTML(r);
					
				}
				catch(e)
				{
					
				}
			},
			onSuccess:function(){
				try
				{					
					//The ajaxlinks function is being called here,I defined this function in footer					
					ajaxLinks();					
					iniciaObjeto($('ajaxleft'));					
					efecto($('ajaxleft'));
					
				}
				catch(e)
				{	
					
				}				
			}
		}).request();
	}
	catch(e)
	{	
		
	}
}

function iniciaObjeto(obj)
{	obj.style.opacity = 0;
    obj.style.MozOpacity = 0;
    obj.style.KhtmlOpacity = 0;
    obj.style.filter = 'alpha(opacity=' + 0 + ')';
    obj.style.zoom=1;//necesario para Explorer
}
function setOp(obj, value) {
    obj.style.opacity = value/100;
    obj.style.MozOpacity = value/100;
    obj.style.KhtmlOpacity = value/100;
    obj.style.filter = 'alpha(opacity=' + value+ ')';
    obj.style.zoom=1;//necesario para Explorer
	if(value==99)
	{
		obj.style.filter = null;
	}
} 
function efecto(o){
    for (var c=0 ; c < 100; c++) 
        (function(c){
             setTimeout(function(){setOp(o,c);} , 10*c);
        })(c);
		
		
}  