// Java Script Functions
function ajaxFormPageLoading(url,datastr){
	$('#contentdiv').hide('slow');
		$.post(url,datastr,function(data){
				document.getElementById('contentdiv').innerHTML=data;
		});
};
function ajaxPageLoading(url){
		$('#contentdiv').hide('fast');
		
		$('#contentdiv').load(url).ajaxStop(function(){
					$('#Loading1').hide('slow');
					$('#contentdiv').show('slow');
				});
		for(var i=1;i<=10;i++){
			$("#c"+i).hide("slow");
		}


};
function addLoading(index,ite){
	$(index).before('<div id="Loading'+ite+'" class="op_loading" align="right"><img src="images/loading.gif" align="top" />  درحال بارگزاری... لطفا کمی صبر کنید</div>');
}

function cactive(){
	for(var i=1;i<=10;i++){
		$("#m"+i).removeClass("active");
		$("#c"+i).hide("slow");
	}
}
function hcontent(){
	for(var i=1;i<=10;i++){
		$("#c"+i).hide('slow');
	}
}


function op_links(itemid,omid){
    $('#Loading1').show('slow');
	cactive();
	$('#contentdiv').hide('slow');
	//ajaxPageLoading('content.php?task='+itemid);
	$('#c'+omid).show('slow');
	$("#m"+omid).addClass("active");
	$('#Loading1').hide('slow');
	
};

function changestyle(itemid){		
		$.get("addcss.php?style="+itemid,function(data){
				document.getElementById('st1').innerHTML=data;
		});
		$("#purple").removeClass("active");
		$("#blue").removeClass("active");
		$("#green").removeClass("active");
		$("#"+itemid).addClass("active");
};


function uncheckAll()
{
      var links = document.getElementById("op_body").getElementsByTagName("img");
      for (var i=0; i< links.length; i++)
      {
            $(links[i]).removeClass("active");
      }
      var links2 = document.getElementById("op_body").getElementsByTagName("a");
      for (var i=0; i< links2.length; i++)
      {
            $(links2[i]).removeClass("active");
	  }
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});



$(document).ready(function() {
	addLoading('#contentdiv','1');
  $('#Loading1').ajaxStart(function() {
    $(this).show('slow');
  }).ajaxStop(function() {
    $(this).hide('slow');
  });
 $('#Loading1').hide('slow');
});

//-----------------------
