$(document).ready(function() {

	var inside;
	var curr_pic;
	curr_pic=1;
	
	
	current_pic(1);
	$("#h_image").ajaxStart(function(){
	$("#h_image").html("<div id=\"loader\"><img src=\"images/21-1.gif\"></div>");
	});
	
	$("#loading").ajaxComplete(function(){
	$("#loading").text("loaded");
	});
	

	$(function() {
        $('#gallery a').lightBox();
       		// $("#orderdiv").show("fast");
       		// $("#aboutdiv").show("fast");
			// $("#collectiondiv").show("fast");
			// $("#collectiondiv").slideToggle("slow");
     		// $("#navigation").hide("fast");
			//$("#header").hide("fast");
			//$("#colmid").hide("fast");
			//$("#colright").hide("fast");
			//$("#col2wrap").hide("fast");
			//$("#col1wrap").hide("fast");
			//$("#col1").hide("fast");
			//$("#col2").hide("fast");
			//$("#col3").hide("fast");
			//$("#footer").hide("fast");
			//$("#nextpicture").hide("fast");
			//$("#mask").hide("fast");
    });
    
    setTimeout(function() {$("#overtext").fadeOut("slow");}, 3000);

  
  	
  	$("#slidenext").click(function(){
  	$("#h_image").fadeOut("fast", taketext);
  	});
  	
  	$("#slideprev").click(function(){
  	$("#h_image").fadeOut("fast", taketextprev);
  	});
  	
    function taketext(){
    if (curr_pic==15) {curr_pic=0;}
    curr_pic++;
    
    $("#h_image").load("something.php?currpic="+encodeURIComponent(curr_pic));
  	$("#h_image").fadeIn("fast");
  		
  	
  	//alert(curr_pic);
  
    }
    
    function taketextprev(){
    if (curr_pic==1) {curr_pic=16;}
    curr_pic--;
    
    $("#h_image").load("something.php?currpic="+encodeURIComponent(curr_pic));
  	$("#h_image").fadeIn("fast");
  		
  	
  	//alert(curr_pic);
  
    }
    
  
    
    
    function current_pic(inside){
    //alert(inside);
    
    }
    
    
  /*
  	$(function() {
        $('a.lightbox').lightBox();
    });
*/
  
  	/*

 	$('a[rel*=lightbox]').lightBox({
	overlayBgColor: '#FFF',
	overlayOpacity: 0.6,
	containerResizeSpeed: 350,
	txtImage: '',
	txtOf: ''
   }); 
*/
    
 

  
   $("#display").click(function() {
   	givealert();
     //$("p.neat").addClass("ohmy").show("slow");
     //toggleit("p.neat");
     
   });
   
   $("#about").click(function(){
   		$("#aboutdiv").toggleFade("slow");
  		$("#collectiondiv").hide("slow");
   		$("#orderdiv").fadeOut("slow");
   });
   
   $("#collection").click(function(){
   		$("#aboutdiv").fadeOut("slow");
   		$("#collectiondiv").slideToggle("slow");
   		$("#orderdiv").fadeOut("slow");
   });
   
   $("#order").click(function(){
   		$("#aboutdiv").fadeOut("slow");
  		$("#collectiondiv").hide("slow");
   		$("#orderdiv").toggleFade("slow");
   		
   });
   
   $("a#close_this").click(function(){
   		$("#aboutdiv").fadeOut("slow");
   		$("#orderdiv").fadeOut("slow");
   				
   });
    $("a#close_this1").click(function(){
   		$("#aboutdiv").fadeOut("slow");
   		$("#orderdiv").fadeOut("slow");
   				
   });
   
   
   $("#send_new").click(function(){
alert("aa");

});
   
   function givealert(){
   //$("#display").html("something inside");	
   //$("p.neat").slideToggle("slow");
   //$("#bigdiv").hide("slow");
  
   }
   
   function toggleit(input){
	var inputis="inside"+input;
	$("#"+inputis+"").slideToggle("slow");
}

(function($) {
  $.fn.toggleFade = function(settings)
  {
  	settings = jQuery.extend(
  		{
        speedIn: "normal",
        speedOut: settings.speedIn
  		}, settings
  	);
  	return this.each(function()
  	{
  	  var isHidden = jQuery(this).is(":hidden");
      jQuery(this)[ isHidden ? "fadeIn" : "fadeOut" ]( isHidden ? settings.speedIn : settings.speedOut);
    });
  };
})(jQuery);


function recoverscreen() {
$("#message").text("");
$("#message").hide("fast");
$("#h_image").html("<img src=\"banners/b1.jpg\">");
}


//mail sending
//recoverscreen();



$("#sendit").click(function(){	
					   				   
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
		
var emailToVal = 'orders@stereocle.com';
		if(emailToVal == '') {
			$("#emailTo").after('<span class="error">You forgot to enter the email address to send to.</span>');
			hasError = true;
		} else if(!emailReg.test(emailToVal)) {	
			$("#emailTo").after('<span class="error">Enter a valid email address to send to.</span>');
			hasError = true;
		}

		
		var emailFromVal = $("#emailFrom").val();
		if(emailFromVal == '') {
			$("#emailFrom").after('<span class="error">You forgot to enter the email address to send from.</span>');
			hasError = true;
		} else if(!emailReg.test(emailFromVal)) {	
			$("#emailFrom").after('<span class="error">Enter a valid email address to send from.</span>');
			hasError = true;
		}
		
		var subjectVal = "order from the site";
		
		
		var messageVal = $("#message").val();
		if(messageVal == '') {
			$("#message").after('<span class="error">You forgot to enter the message.</span>');
			hasError = true;
		}
		
		
		if(hasError == false) {
			
			$(this).hide();
			$("#sendEmail li.buttons").append('<img src="/wp-content/themes/default/images/template/loading.gif" alt="Loading" id="loading" />');
			//alert(emailFromVal);
			
$.post("js/mail/now.php",
   				{ emailTo: emailToVal, emailFrom: emailFromVal, subject: subjectVal, message: messageVal },
   					function(data){
   					
   					
						
						$("#sendEmail").slideUp("normal", function() {				   
						
							$("#sendEmail").before('<h1>Success</h1><p>Your email was sent.</p> If you want to send one more mail, please reload the page.');	
							$("#orderdiv").fadeOut("slow");
															
						});
   					}
				 );
				 recoverscreen();
		}
		
		return false;
	});		

   
 });