//Front end Java Script File

//global variables declaration
 imgArray=new Array();
 liArray=new Array();
 aArray= new Array();
 currentImg=0;
 prevImg=null;
 checkLoop=false;
 displayStr='';
 liclick=false;
 var t;

// to store the current page number
var page=1;
// Total Number fo Pages
var totalpages =4;

onloadDynamicUrl=window.location.href;

if(document.domain=='10.0.1.250')
{
	onLoadUrlEcards='http://10.0.1.250/projects/innovatory/geddes-gillmore/ecards/';
	onLoadUrlDownload='http://10.0.1.250/projects/innovatory/geddes-gillmore/downloads/';
}else
{
	onLoadUrlEcards='http://www.geddesandgillmore.com/ecards/';
	onLoadUrlDownload='http://www.geddesandgillmore.com/downloads/';
}


jQuery(document).ready(function()
{
	
	jQuery(".mainmenu").mousemove(function()
	{
		jQuery(".overmenu").slideDown("slow");
	});
	
	jQuery(".storelocator").mouseover(function()
	{	
		jQuery(".overmenu").slideUp("slow");
		jQuery(".overcollection").slideUp("slow");
	});
	jQuery(".stayinformed").mouseover(function()
	{	
		jQuery(".overmenu").slideUp("slow");
		jQuery(".overcollection").slideUp("slow");
	});
	
	jQuery(".contentcontainer").mouseover(function()
	{
		jQuery(".overmenu").slideUp("slow");
		jQuery(".overcollection").slideUp("slow");
	});

	jQuery(".wrapper").mouseover(function()
	{
		jQuery(".overmenu").slideUp("slow");
		jQuery(".overcollection").slideUp("slow");
	});


jQuery(".collectionMenu").mousemove(function()
	{
		jQuery(".overcollection").slideDown("slow");
	});
	

	/* Story Pages JS */
	
	// jQuery('#page_1').css('display','block');
	// jQuery("#page_1").animate({opacity:1},"slow");
	
	// if you click on next button
	jQuery('.nextstory').click(function() 
	{
		//alert(this.id);	
		//jQuery('#page_'+page).hide('slow');
		jQuery('#page_'+page).css('display','none');
		
		page=page+1;
		jQuery("#page_"+page).css({opacity:0.2},"fast");
		jQuery('#page_'+page).css('display','block');
		jQuery("#page_"+page).animate({opacity:1},"slow");
		//jQuery('#page_'+page).slideDown('slow');
		//jQuery('#page_'+page).css('display','block');
		
		if (page == totalpages)
		{
			//alert('next');
			jQuery('.nextstory').css('display','none');
			jQuery('.prevstory').css('display','block');
		}
	});

	// if you click on prev button
	jQuery('.prevstory').click(function() 
	{
		//alert(this.id);
		//jQuery('#page_'+page).hide('slow');
		jQuery('#page_'+page).css('display','none');
		
		page=page-1;
		jQuery("#page_"+page).css({opacity:0.2},"fast");
		jQuery('#page_'+page).css('display','block');
		jQuery("#page_"+page).animate({opacity:1},"slow");
		//jQuery('#page_'+page).css('display','block');
		//alert(page);
		//if (page == 1)	
		//{
			//alert('prev');
			jQuery('.nextstory').css('display','block');
			jQuery('.prevstory').css('display','block');
		//}
	});
	/* End of Story page Js */
});


/* sliding menus*/
jQuery(document).ready(function() 
{
 	/*jQuery("#mySlideshow").jCarouselLite(
	{
		 btnPrev: ".previous",
		 btnNext: ".next",
		 //this makes it a true carousel rather than a slideshow
		 circular: true
	 });*/
	
//************************************************************* Ecard slide menu **********************************************************************
	if(onloadDynamicUrl!=onLoadUrlEcards) 
	{
		jQuery("#ecardSlideDiv a").mouseover(function()
													{ 
															//setting for ecards menu slow or fast
														  jQuery("#ecardSlideDiv a").animate({left:0+"px"},"fast");	
														  
														  if(onloadDynamicUrl!=onLoadUrlDownload) 
															{
														  jQuery('#downloadSlideDiv a').css({left:-17+'px'},'fast');
															}
														  jQuery('#musicSlideDiv a').css({left:-44+'px'},'fast');
													});
		
		jQuery("#ecardSlideDiv a").mouseout(function()
							{ 
								setTimeout("jQuery('#ecardSlideDiv a').css({left:-17+'px'},'fast')",50);
							});	
	}
	else
	{
		jQuery('#ecardSlideDiv a').css({left:0+'px'},'fast');
	}
	
//************************************************************* Download slide menu **********************************************************************	
	if(onloadDynamicUrl!=onLoadUrlDownload) 
	{
		jQuery("#downloadSlideDiv a").mouseover(function() 
		{ 
			//setting for downloads menu slow or fast	
			jQuery("#downloadSlideDiv a").animate({left:0+"px"},"fast");
			
			jQuery('#musicSlideDiv a').css({left:-44+'px'},'fast');
			
			if(onloadDynamicUrl!=onLoadUrlEcards) 
			{
				jQuery('#ecardSlideDiv a').css({left:-17+'px'},'fast');
			}
		});
												
		jQuery("#downloadSlideDiv a").mouseout(function() { setTimeout("jQuery('#downloadSlideDiv a').css({left:-17+'px'},'fast')",50); });
	}
	else
	jQuery("#downloadSlideDiv a").css({left:0+"px"},"fast");
	
//************************************************************* Music slide menu **********************************************************************	
	jQuery("#musicSlideDiv a").mouseover(function()
	{ 
				//setting for music menu slow or fast
				  jQuery("#musicSlideDiv a").animate({left:0+"px"},"fast");
				 if(onloadDynamicUrl!=onLoadUrlDownload) 
				 {
				  	jQuery('#downloadSlideDiv a').css({left:-17+'px'},'fast');
				 }
				 if(onloadDynamicUrl!=onLoadUrlEcards) 
				 {
				  	jQuery('#ecardSlideDiv a').css({left:-17+'px'},'fast');
				 }
	});
	
	jQuery("#musicSlideDiv a").mouseout(function()
	{ 
		setTimeout("jQuery('#musicSlideDiv a').css({left:-44+'px'},'fast')",50); 
	});
	
	
});



//******************************************************* Gallery page effects ************************************************************** 
jQuery(document).ready(function()
{
						
	//get all the images for slide show
	 imgArray = jQuery("#gallery_imageContainer img");
	 liArray = jQuery("#smallThumbs li");
	 aArray= jQuery("#smallThumbs a");
	 smallArray = jQuery("#smallThumbsHidden img");
//alert(smallArray.length);

	if(liclick==false)
	setTimeout("fadeEffect('onload')",0);


	jQuery("#smallThumbs ul li").click(function()
	 {							 			 
		 
		spl_arr=this.id.split('_');
					 
		
		liclick=true;			 			
		 
		currentImg=parseInt(spl_arr[1]);
	
		//document.getElementById("extrainfo").innerHTML= " ul pre"+prevImg+"curr"+currentImg;

		jQuery(imgArray[currentImg]).css('display','block');	
		jQuery(aArray[currentImg]).css("background", "url(../_images/thumb-boxon.gif) no-repeat");
		
		if(prevImg!=null && currentImg!=prevImg)
		{
			jQuery(imgArray[prevImg]).css('display','none');
			jQuery(aArray[prevImg]).css("background", "url(../_images/thumb-box.gif) no-repeat");	
		}
											
		prevImg=currentImg;
		
	//	document.getElementById("extrainfo").innerHTML+=" curr "+currentImg;	
		//setTimeout(fadeEffect,10000);

	});
	
	
//******************************************* Fragrance page default image *********************************************************
	if(document.getElementById('defaultFragranceBackgroundImage'))
	{
			/*document.getElementById('defaultFragranceBackgroundImage').style.display='block';
			jQuery("#defaultFragranceBackgroundImage").animate({opacity:1},"slow", function()
					{*/
						//	setTimeout(fragranceEffects, 2000);															
						fragranceEffects();		
					//});
						
			}
		
//*********************************************************Fragrance page effects *****************************************************
	function fragranceEffects()
	{
			//jQuery("#defaultFragranceBackgroundImage").fadeOut("slow", function()
			//{ 
							
					document.getElementById('fragranceElementsContainer').style.display='block';	
						
					document.getElementById('fragranceWhiteBorder').style.visibility='visible';								
					jQuery("#fragranceWhiteBorder").animate({opacity:1},"fast",function()
					{
						
					});
					document.getElementById('fragranceWhiteImage').style.visibility='visible';								
					
					jQuery("#fragranceWhiteImage").animate({opacity:1},"slow",function()
					{
							
							document.getElementById('fragranceInnerContent').style.visibility='visible';								
							document.getElementById('fragranceMiddle').style.visibility='visible';								
							document.getElementById('fragranceTextContent').style.visibility='visible';	
							
							//alert('white image');
							document.getElementById('fragranceTopText').style.visibility='visible';
							//document.getElementById('fragranceTopText').style.display='block';
								//alert('top text');
							jQuery("#fragranceTopText").animate({opacity:1},"slow", function()
							{		
												
									
								document.getElementById('fragranceRightImage').style.visibility='visible';
								jQuery("#fragranceRightImage").animate({opacity:1},"slow", function()
								{		
										
										document.getElementById('fragranceMiddleText').style.visibility='visible';
										jQuery("#fragranceMiddleText").animate({opacity:1},"slow");		
										
										
										document.getElementById('fragranceBottomText').style.visibility='visible';
										jQuery("#fragranceBottomText").animate({opacity:1},"slow", function()
										{		
										
											document.getElementById('innerTopmiddle').style.visibility='visible';											
											jQuery("#innerTopmiddle").animate({opacity:1},"slow", function()
											{		
																											  
													document.getElementById('fragranceLeftImage').style.visibility='visible';
											
													jQuery("#fragranceLeftImage").animate({opacity:1},"slow", function()
													{
														
														
														document.getElementById('bottomImages').style.display='block';
														
														jQuery("#fragrancerightGiftBox").animate({right:15+"px"},"slow");										
														jQuery("#fragranceleftGiftBox").animate({left:55+"px"},"slow");
													
													}); //end of fragranceLeftImage animate
								
											});	//end  of innerTopmiddleanimate
								}); //end of fragranceBottomText animate
					
							}); //end of fragranceRightImage animate
					});	//end of fragranceTopText animate
					
			});	//end of fragranceWhiteImage
					 
		//}); //end of defaultFragranceBackgroundImage						
	} // End of Function 
});

function fadeEffect(where)
{	
	/*if(document.getElementById("extrainfo"))
	document.getElementById("extrainfo").innerHTML=where+" curr "+currentImg+" pre"+prevImg;	*/
	//if(liclick)
	//currentImg=currentImg+1;
	//if(currentImg!=prevImg)
	//{
	jQuery(imgArray[currentImg]).fadeIn("slow");
	jQuery(aArray[currentImg]).css("background", "url(../_images/thumb-boxon.gif) no-repeat");
	//}
	
	//alert(prevImg);
	if(prevImg!=null && prevImg != currentImg)
	{
		jQuery(imgArray[prevImg]).fadeOut("slow");
		jQuery(aArray[prevImg]).css("background", "url(../_images/thumb-box.gif) no-repeat");	
	}

		
	 checkLoop=false;	
	//alert("curr"+currentImg);
	if(currentImg==(imgArray.length-1))
	{
	//	alert(imgArray.length-1);		
		prevImg=currentImg;
		currentImg=0;
		checkLoop=true;
	}
	else
	prevImg=currentImg;
	
		
	if(currentImg!=(imgArray.length-1) &&  checkLoop==false)	
	{
		currentImg=currentImg+1;
	}

	//if(liclick==false)
	setTimeout("fadeEffect('function')",5000);
}	
var resize = true;

jQuery(document).ready(function()
{		
	
	jQuery('#smallThumbs ul li').mouseover(function()
		{
		//alert(this.id);
		idArr=this.id.split('_');
		
		hoveredElem=idArr[1];
		
		firstElem=parseInt(hoveredElem)-1;
		secondElem=parseInt(hoveredElem)-2;
		nextElem=parseInt(hoveredElem)+1;
		lastElem=parseInt(hoveredElem)+2;		

		displayStr='<ul>';
		
		if(hoveredElem==0 && nextElem>0 && lastElem>0)
		{
			//alert('first elem 0');
		displayStr+='<li id="dynamicThumbsLi_'+hoveredElem+'"><a href="#"><img src='+smallArray[hoveredElem].src+'></a></li>';				
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(nextElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[nextElem].src+'></a></li>';			
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(lastElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[lastElem].src+'></a></li>';
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(lastElem+1)+'"><a href="#"><img class="fadeimg" src='+smallArray[parseInt(lastElem+1)].src+'></a></li>';
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(lastElem+2)+'"><a href="#"><img class="fadeimg" src='+smallArray[parseInt(lastElem+2)].src+'></a></li>';
		
		}		
		else if(firstElem==0 && secondElem<0 && nextElem>0 && lastElem>0)
		{
			//alert('firstElem==0 && secondElem<0 && nextElem>0 && lastElem>0');
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(firstElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[firstElem].src+'></a></li>';
		

		displayStr+='<li id="dynamicThumbsLi_'+parseInt(hoveredElem)+'"><a href="#"><img src='+smallArray[hoveredElem].src+'></a></li>';						
		
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(nextElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[nextElem].src+'></a></li>';
		
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(lastElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[lastElem].src+'></a></li>';
		
	//alert(parseInt(nextElem));
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(lastElem+1)+'"><a href="#"><img class="fadeimg" src='+smallArray[lastElem+1].src+'></a></li>';
		}
		else if(firstElem>0 && secondElem>=0 && nextElem>0 && lastElem<=(smallArray.length-1))
		{
		//	alert('firstElem>0 && secondElem>=0 && nextElem>0 && lastElem<=(smallArray.length-1)');
					
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(firstElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[firstElem].src+'></a></li>';
		

		displayStr+='<li id="dynamicThumbsLi_'+parseInt(secondElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[secondElem].src+'></a></li>';						
		
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(hoveredElem)+'"><a href="#"><img src='+smallArray[hoveredElem].src+'></a></li>';
		
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(nextElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[nextElem].src+'></a></li>';
		
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(lastElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[lastElem].src+'></a></li>';
		
		}
		else if(firstElem>0 && secondElem>0 && nextElem<=(smallArray.length-1) && lastElem>=smallArray.length)
		{
		//alert('last before');
			
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(firstElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[firstElem].src+'></a></li>';
		

		displayStr+='<li id="dynamicThumbsLi_'+parseInt(secondElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[secondElem].src+'></a></li>';						
		
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(hoveredElem)+'"><a href="#"><img  src='+smallArray[hoveredElem].src+'></a></li>';
		
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(nextElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[nextElem].src+'></a></li>';
		
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(0)+'"><a href="#"><img class="fadeimg" src='+smallArray[0].src+'></a></li>';
		
		}
		else if(firstElem>0 && secondElem>0 && nextElem>=smallArray.length && lastElem>=smallArray.length)
		{
		//alert(hoveredElem);
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(firstElem-2)+'"><a href="#"><img class="fadeimg" src='+smallArray[firstElem-2].src+'></a></li>';		
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(firstElem-1)+'"><a href="#"><img class="fadeimg" src='+smallArray[firstElem-1].src+'></a></li>';
		
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(firstElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[firstElem].src+'></a></li>';
		

		displayStr+='<li id="dynamicThumbsLi_'+parseInt(secondElem)+'"><a href="#"><img class="fadeimg" src='+smallArray[secondElem].src+'></a></li>';						
		
	
		displayStr+='<li id="dynamicThumbsLi_'+parseInt(hoveredElem)+'"><a href="#"><img src='+smallArray[hoveredElem].src+'></a></li>';			
	
		
		}
		
		//alert(idArr[1]+" innerelem"+ smallArray[hoveredElem].src);
		jQuery("#smallThumbsVisible").css('display','block');
		jQuery("#smallThumbsVisible").animate({opacity:1},"slow", function(){});

		//alert(displayStr);
	//	document.getElementById("smallThumbsVisible").innerHTML='<li><a><img src='+smallArray[hoveredElem].src+'></a></li>';
		document.getElementById("smallThumbsVisible").innerHTML=displayStr+'</ul>';
		
				jQuery("#smallThumbsVisible ul li").click(function()
				 {				
					
				spl_arr=this.id.split('_');							 
				
				liclick=true;			 			
				 
				currentImg=parseInt(spl_arr[1]);
			
			//	document.getElementById("extrainfo").innerHTML= " ul pre"+prevImg;
		
				jQuery(imgArray[currentImg]).css('display','block');
				jQuery(aArray[currentImg]).css("background", "url(../_images/thumb-boxon.gif) no-repeat");
				
				if(prevImg!=null && currentImg != prevImg)
				{
					jQuery(imgArray[prevImg]).css('display','none');
					jQuery(aArray[prevImg]).css("background", "url(../_images/thumb-box.gif) no-repeat");	
				}
													
					prevImg=currentImg;
					//document.getElementById("extrainfo").innerHTML+=" curr "+currentImg;	
					document.getElementById("smallThumbsVisible").style.display='none';
					
				 });

		});

	jQuery("#smallThumbs ul li").mouseout(function()
	{		
		
		t=setTimeout(dynamicThumbsOut,10000);
		//var int=setInterval("dynamicThumbsOut()",10000);
		
	});

	jQuery("#smallThumbsVisible").mouseover(function()
	{		
		//
		//alert(t);
		//setTimeout(dynamicThumbsOut, 5000);
		//clearInterval(int);
		clearTimeout(t);
		//document.getElementById("extrainfo").innerHTML= " clear timeout";

	});




});

function dynamicThumbsOut()
{
	//clearTimeout(t);
	jQuery("#smallThumbsVisible").fadeOut("slow");
		//	document.getElementById("extrainfo").innerHTML= " timeout";
	//	document.getElementById("smallThumbsVisible").style.display='none';
}




//jQuery(document).ready(function()
///{

jQuery(document).ready(function()
{
	
	
/*	opacity:0.4;
filter:alpha(opacity=40);
-moz-opacity:0.4;
background:#242C30;*/

	jQuery(".previous").mouseover(function()
										   {

											 jQuery(".previous").css('opacity',0.6);
											 jQuery(".previous").css('background','#242C30');
											 
											});
	
	jQuery(".previous").mouseout(function()
										   {
	
											 jQuery(".previous").css('opacity',0.2);

										  });
	
	
	jQuery(".next").mouseover(function()
										   {
	
											 jQuery(".next").css('opacity',0.6);
											 jQuery(".next").css('background','#242C30');
											 
											});
	
	jQuery(".next").mouseout(function()
										   {
	
											 jQuery(".next").css('opacity',0.2);

											});
	
	jQuery(".previous").click(function()
										   {
	
											 jQuery(".previous").css('opacity',0);

											});
	
	jQuery(".next").click(function()
										   {
	
											 jQuery(".next").css('opacity',0);

										   });
	
	if(document.getElementById("summerCollectionLogo"))
	document.getElementById("summerCollectionLogo").style.display='none';
	/*
	jQuery("#defaultGalleryImage").css('display','block');
	jQuery("#defaultGalleryImage").animate({opacity:1},"slow", function()
																		{
																																																										
																			galleryFadeOut();
																	});*/

//********************************************************* gallery effects ******************************************************************
	
//	jQuery("#defaultGalleryImage").animate({opacity:1},"slow");
/*function galleryFadeOut()
{
	
	jQuery("#defaultGalleryImage").fadeOut("slow", function(){
															document.getElementById("smallThumbs").style.display='block';
														});
	
}*/

//********************************************************* collection effects ******************************************************************
	/*jQuery("#defaultCollectionImage").css('display','block');
	jQuery("#defaultCollectionImage").animate({opacity:1},"slow", function(){
																		 	 setTimeout(collectionFadeOut, 2000);
																		  });
	
	function collectionFadeOut()
	{
	jQuery("#defaultCollectionImage").fadeOut("slow", function()
															   {
																 
																 document.getElementById("summerCollectionLogo").style.display='block';
																   
																 jQuery(".maincontent").css('display','block');
																 collectionSlideEffect();
															   });
	}*/
	
	if(document.getElementById("summerCollectionLogo"))
	{
	document.getElementById("summerCollectionLogo").style.display='block';
	   
	 jQuery(".maincontent").css('display','block');
	 collectionSlideEffect();
	}

});

function collectionSlideEffect()
{
	
	
jQuery("#mySlideshow").jCarouselLite({
			 btnPrev: ".previous",
			 btnNext: ".next",	
			 beforeStart:function()
			 {
				 //jQuery(".previous").css('opacity',1);
			 },
			afterEnd: function(a){
			jQuery(a[0]).css({"opacity":"0.2"},"fast");
			jQuery(a[2]).css({"opacity":"0.2"},"fast");

											

				jQuery(a[1]).animate({opacity:"1"},"slow",function(){
				$allListItems = jQuery("#mySlideshow ul li");
					
					for(var $i=0;$i<$allListItems.length;$i++){
						if($allListItems[$i]!=a[1]){
							jQuery($allListItems[$i]).css({"opacity":"0.2"},"fast");
						}
					}
					//jQuery("#collectionLi_2 a").css({"opacity":"0.4"},"fast");
				});	
				
			 }
		});
}

//});

var newwindow='';
function popitup(url_test)
{
	//alert(url_test);
	
	if (!newwindow.closed && newwindow.location) {
		newwindow.location.href = url_test;
	}
	else {
		newwindow=window.open(url_test,'g_and_g','height=10,width=10');
		if (!newwindow.opener) newwindow.opener = self;
	}
	//if (window.focus) {newwindow.focus()}
	return false;
}



jQuery(document).ready(function()
{
	
	jQuery.ajax({
		url: w3_path_prefix+"_functions/default_background.php",
		type:'POST',
		data:{},
		success: function(res) 
		{
			//alert(document.body.background);			
		if(document.getElementById('bodybgIndex'))
		{
			//document.getElementById('bodybg1').style.backgroundImage="url("+w3_path_prefix+res+")";
			document.getElementById('bodybgIndex').style.backgroundColor="#000";
		}
		
		if(document.getElementById('bodybg1'))
		{
			//alert(res);
		//	document.getElementById('bodybg1').style.backgroundImage="url("+w3_path_prefix+res+")";
		jQuery("#bodybg1").css('background-image','url("'+w3_path_prefix+res+'")');
			//document.getElementById('bodybg1').style.backgroundColor="#000";
		}
		

		},
		error: function (){ alert('something went wrong');}
		});	
	
	
});