var bg = new Array();
var currentPic = 0;

$(function(){
	
	 $.ajax({
	   type: "GET",
	   url: "ajax_images.php",
	   success: function(msg){
			
			var i = 0;
			temp = msg.split("|");
			jQuery.each(temp, function(){ 
						bg[i] = new Image();
						bg[i].src = this;					
						i++;
					} );

			setInterval("showNew()", 10000);	
			
	   }
	 });
	
	$("#cform-sbm").bind("click", function(e){
     $("#cform").submit();
    });
	
	$("#terms").bind("click", function(e){
		window.open ("terms.php", "mywindow","status=0,toolbar=0, width=450, height=340"); 
    });
	

});

function showNew()
{
	$('#changeimage').fadeOut("slow", function(){  
		
		currentPic++;
		if(!bg[currentPic])
			currentPic = 0;
		$('#changeimage').attr("src", bg[currentPic].src);
		$('#changeimage').fadeIn("slow");

	});
	
}
