/* FadeIn and FadeOut example */
/* http://malsup.com/jquery/cycle/begin.html */

$(document).ready(function() {	
	
	$("#homeMenu > a > img").each(function(){ 
		if($("#TagTitle").html() == $(this).attr("id")){
			var newsrc = $(this).attr("src").replace(".gif","_over.gif");
			$(this).attr("src", newsrc);
		}
		
	});
		
	$("#homeMenu > a > img").each(function(){ 
		$(this).bind("mouseenter",function(){
			if($("#TagTitle").html() != $(this).attr("id")){
				var newsrc = $(this).attr("src").replace(".gif","_over.gif");
				$(this).attr("src", newsrc);
			}
			
		});
	});

	$("#homeMenu > a > img").each(function(){ 
		$(this).bind("mouseleave",function(){
			if($("#TagTitle").html() != $(this).attr("id")){
				var newsrc = $(this).attr("src").replace("_over.gif",".gif");
				$(this).attr("src", newsrc);
			}
		});
	});
	
	$(".GomaGallery img").each(function(){ 
		$(this).hover(function(){$(this).css("cursor","pointer");});
		$(this).click(function(){
			if($(this).attr("src") != "images/spacer.gif"){
				var newsrc = $(this).attr("src").replace("/thumb/","/lrg/").replace("goma_thumb_","goma_lrg_");
				
				$("#showImgCorp").attr("src", newsrc);
			}
		});
	});
	
		
	$(".BvlgariGallery img").each(function(){ 
		$(this).hover(function(){$(this).css("cursor","pointer");});
		$(this).click(function(){
			if($(this).attr("src") != "images/spacer.gif"){
				var newsrc = $(this).attr("src").replace("/thumb/","/lrg/").replace("bvlgari_thumb_","bvlgari_lrg_");
				
				$("#showImgCorp").attr("src", newsrc);
			}
		});
	});
	
	$(".LibertineGallery img").each(function(){ 
		$(this).hover(function(){$(this).css("cursor","pointer");});
		$(this).click(function(){
			if($(this).attr("src") != "images/spacer.gif"){
				var newsrc = $(this).attr("src").replace("/thumb/","/lrg/").replace("libertine_thumb_","libertine_lrg_");
				
				$("#showImgCorp").attr("src", newsrc);
			}
		});
	});	
	
	$(".WeddingGallery img").each(function(){ 
		$(this).hover(function(){$(this).css("cursor","pointer");});
		$(this).click(function(){
			if($(this).attr("src") != "images/spacer.gif"){
				var newsrc = $(this).attr("src").replace("/thumb/","/lrg/").replace("wed_thumb_","wed_lrg_");
				
				$("#showImgCorp").attr("src", newsrc);
			}
		});
	});
	

	$(".CorpGallery img").each(function(){ 
		$(this).hover(function(){$(this).css("cursor","pointer");});
		$(this).click(function(){
			if($(this).attr("src") != "images/spacer.gif"){
				var newsrc = $(this).attr("src").replace("/thumbs/","/large/").replace("corp_thumb_","corp_lrg_");
				
				$("#showImgCorp").attr("src", newsrc);
			}
		});
	});
	
	$(".BridesGallery img").each(function(){ 
		$(this).hover(function(){$(this).css("cursor","pointer");});	
		$(this).click(function(){
			if($(this).attr("src") != "images/spacer.gif"){
				var newsrc = $(this).attr("src").replace("/thumbs/","/large/").replace("wed_thumb_","wed_lrg_");
				
				$("#showImgCorp").attr("src", newsrc);
			}
		});
	});
	
	$(".GiftsGallery img").each(function(){ 
		$(this).hover(function(){$(this).css("cursor","pointer");});	
		$(this).click(function(){
			if($(this).attr("src") != "images/spacer.gif"){
				var newsrc = $(this).attr("src").replace("/thumbs/","/large/").replace("gifts_thumb_","gifts_lrg_");
				
				$("#showImgCorp").attr("src", newsrc);
			}
		});
	});
	
	
	/*
	$(".hoverImgs").each(
			function(){
				$(this).hover(
					function(e){
						$(this).css("opacity","0.5").show("slow");
						
						var newsrc = $(this).attr("src").replace("/events/","/events/lrg/").replace(".jpg","_lrg.jpg");
						$("#showHoverImg").attr("src",newsrc);
						$("#hoverImg").css("left",(e.pageX + 10) + "px")
						.css("top",(e.pageY-190) + "px")
						.fadeIn("slow")
						.css("display","");
					}
				);
				
				$(this).bind("mouseleave",
					function(){
						$(this).css("opacity","1").show("slow");
						$("#hoverImg").css("display","none");
					}
				);
			}
		);*/

	$("#your_company_name").click(
		function(){
			if($("#your_company_name").val() == "   - Your Company Name & Purchase Order -")
				$("#your_company_name").val("");
		});
		
	$("#your_company_name").blur(
		function(){
			if($("#your_company_name").val() == "") 
				$("#your_company_name").val("   - Your Company Name & Purchase Order -");
	});
	
	$("#flower_perference").click(
		function(){
			if($("#flower_perference").val() == "    -  Type Your Flower Preference Here  -")
				$("#flower_perference").val("");
		});
		
	$("#flower_perference").blur(
		function(){
			if($("#flower_perference").val() == "") 
				$("#flower_perference").val("    -  Type Your Flower Preference Here  -");
	});
	
	$("#arrangement_style_special").click(
		function(){
			if($("#arrangement_style_special").val() == "     - We Will Do Our Best -")
				$("#arrangement_style_special").val("");
		});
		
	$("#arrangement_style_special").blur(
		function(){
			if($("#arrangement_style_special").val() == "") 
				$("#arrangement_style_special").val("     - We Will Do Our Best -");
	});
	
	/*$(".partner_table").css("display","none");
	$(".partner_table").fadeIn("slow").css("display","");
	/*if($("#flower_type").attr("checked"))
		$("#flower_perference").css("display",""); 
	else
		$("#flower_perference").css("display","none"); 
			
	});

	
	var winHeight  = $(document).height(); 
	function doSomething() {  
		var winHeight2  = $(document).height(); 
		
		if(winHeight2 - winHeight > 0 )
			$("#footer").css("padding-top",(winHeight2-(winHeight))+"px");
	}; 
	
	var resizeTimer = null;
	$(window).bind('resize', function() {   
		if (resizeTimer) clearTimeout(resizeTimer);    
			resizeTimer = setTimeout(doSomething, 100);
	});
	*/
	
	$(".partners_img").fadeIn("slow");

});

function seasons_innerFad(){
	$('#seasons_img').innerfade({ 
		fx:     'fade', 
		speed:   1000,
		timeout: 4000
	});		
	$(".seasons_table").fadeIn("slow");
}

function checkForm(){
	var result="true";
	
	$("submit").click(function(){
	if($("your_company_name").text() == "         - Your Company Name -")
		alert("This field is required!");
	});
}

function startTime(){
		$(".eventTable").css("display","none");
		setTimeout('startRotate1()',100);
		setTimeout('startRotate2()',200);
		setTimeout('startRotate3()',300);
		setTimeout('startRotate4()',400);		
		setTimeout('fadeIn()',350);
	}
function fadeIn(){
	//$('.disapper').hide();
	$(".eventTable").fadeIn(300);
}
function startRotate1(){
	$('#event_goma').innerfade({ 
		fx:     'fade', 
		speed:   1000,
		timeout: 5000
	});

}

function startRotate2(){
	$('#events_bvlgari').innerfade({ 
		fx:     'fade', 
		speed:   1000, 
		timeout: 5000
	});

}

function startRotate3(){
	$('#events_weddings').innerfade({ 
		fx:     'fade', 
		speed:   1000, 
		timeout: 5000 
	});
}


function startRotate4(){
	$('#events_libertine').innerfade({ 
		fx:     'fade', 
		speed:   1000, 
		timeout: 5000 
	});
}

function startTime2(){
		$(".eventTable").css("display","none");
		
		$('#hampers').innerfade({ 
		fx:     'fade', 
		speed:   1000, 
		timeout: 5000 
		});
		setTimeout('startRotate_1()',0);
		setTimeout('startRotate_2()',100);
		setTimeout('fadeIn()',350);
	}
function startRotate_1(){
	$('#GiftsImg').innerfade({ 
		fx:     'fade', 
		speed:   1000, 
		timeout: 5000 
	});
}

function startRotate_2(){
	$('#plants').innerfade({ 
		fx:     'fade', 
		speed:   1000, 
		timeout: 5000 
	});
}

function startContact(){

	$('#rotateImg').innerfade({ 
		fx:     'fade', 
		speed:   1000,
		timeout: 4000
	});
	setTimeout('fadeIn2()',100);
}
function fadeIn2(){
	//$('.disapper').hide();
		$(".contact_table").fadeIn(100);
}

function checkForm(){
	var result= true;
	var str="";
	
	if($("#customer_name").val() == ""){
		str+="*Please enter your Name!\n";
		result = false;
	}
	
	if($("#customer_mobile").val() == ""){
		str+="*Please enter your Mobile Number!\n";
		result = false;
	}
	else{
		if(!IsNumeric($("#customer_mobile").val())){
			str+="*Please enter a valid Mobile Number!\n";
			result = false;
		}
	}
	
	if($("#customer_email").val() == ""){
		str+="*Please enter your Email Address!\n";
		result = false;
	}
	else{
		if(!isValidEmail($("#customer_email").val())){
			str+="*Please enter a valid Email Address!\n";
			result = false;
		}
	}
	
	if(!result)
		//$.popup.show("Warming", str);
		alert(str);
		
	return result;
}

function checkContact(){
	var result= true;
	
	if($("#contact_mail").val() == ""){
		alert("*Please enter your Email Address!");
		result = false;
	}
	else{
		if(!isValidEmail($("#contact_mail").val())){
			alert("*Please enter a valid Email Address!");
			result = false;
		}
	}

	return result;
}

function IsNumeric(sText){
   var ValidChars = "0123456789. +";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
			IsNumber = false;
         }
      }
   return IsNumber;
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0 && str.indexOf(".") != str.indexOf("@")+1 && str.indexOf(".") < str.length-1);
}
