

jQuery(document).ready(function(){


//swapObject();

//accordian('accordian');

toggleObject('contactForm');
fadeObject();		
activeLink();
displayMenus();
linkToNewWindow();
productLinks();
dateReset();





//initialise the calendar script used in the contact form and product training sections
//also added in a blur on the date fields
jQuery('input.date-pick').datePicker().focus(function(){
	
	jQuery(this).blur();
	
});	



//additional close button linked to the contact form
jQuery('#closeWindow').click(function(){
	
	jQuery('#contactFormHolder').animate({height: 'toggle'}, 500);
});


jQuery('img.addToOrder').click(function(){
	
	jQuery('#orderItem').submit();
	
	});

jQuery('#recalculate').click(function(){
	
	jQuery('#customerOrder').submit();
	
	});	

	

	Galleria.loadTheme('js/jQuery/galleria/themes/classic/galleria.classic.min.js');

	jQuery('a[rel="lightbox"]').colorbox();

	var targ;

	jQuery("#gallery").galleria({
		autoplay: 6000,
		transitionSpeed: 1000,
		transitionInitial: 'fade',
        width: 614,
        height: 322,
		imageCrop: 'width',
		minScaleRatio: 1,
		extend: function() {
            this.bind(Galleria.IMAGE, function(e) {

                jQuery(e.imageTarget).css('cursor','pointer');

			    jQuery(e.imageTarget).click(this.proxy(function() {

					targ = jQuery(e.imageTarget).attr('src');

					jQuery('a[href="'+targ+'"]').click();

			    }));

                //jQuery(e.imageTarget).css('cursor','pointer').click(this.proxy(function() { this.openLightbox(); }));

            });
			
        }

    });	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
// end of initialise
	
});



function productLinks() {
	
jQuery('#featureContainer img.link').mouseover(function(){
	
	//jQuery(this).fadeTo('fast',2);
		
	});
	
jQuery('#featureContainer img.link').mouseout(function(){
	
	//jQuery(this).fadeTo('fast',1);
		
	});
	

jQuery('#featureContainer img.link').click(function(){
		
	jQuery('#featureContainer img.link').each(function(){
		
		jQuery(this).attr('src', 'images/'+jQuery(this).attr('id')+'Off.jpg');
			
	});
	
	
	jQuery(this).attr('src', 'images/'+jQuery(this).attr('id')+'On.jpg');
		
	jQuery('#featureContainer div').hide();
	
	jQuery('#'+jQuery(this).attr('id')+'Details').show();
		
	});	
	
	
}

function activeLink(){
	
jQuery('div.activeLink a').mouseover(function(e){
	
	jQuery(this).find("h2:first").css('color', 'black');	
	jQuery(this).find('img.activeButton').attr('src', ('images/activeButtonFade.png'));	
	e.stopPropagation();
	
});

jQuery('div.activeLink a').mouseout(function(e){
	
	jQuery(this).find("h2:first").css('color', 'white');	
	//jQuery(this).find('img.activeButton').fadeTo('fast', 1);	
	jQuery(this).find('img.activeButton').attr('src', ('images/activeButton.png'));	
	e.stopPropagation();
	
});


}

function toggleObject(objectId) {
	
	jQuery('#' + objectId + 'Button').click(function() {
				
		
	jQuery('#' + objectId + 'Holder').animate({
    height: 'toggle'
  }, 500);
  
  
  	//alert(jQuery('#'+ objectId))

	});	
		
}





function dateReset(){

//clear the defined dates when the radio button is toggled
jQuery('#preferences input').click(function(){
	
	//alert(jQuery(this).attr('Name'))
	
	
	if(jQuery(this).attr('value')=="On-site"){
		
		jQuery('#date2').val('');
		jQuery('#date3').val('');
		
	};	
	
	if(jQuery(this).attr('value')=="Remote"){
		
		jQuery('#date1').val('');
		jQuery('#date3').val('');
		
	};	

	if(jQuery(this).attr('value')=="Training"){
		
		jQuery('#date1').val('');
		jQuery('#date2').val('');
		
	};	
			
	if(jQuery(this).attr('value')=="Products"){
		
		jQuery('#date1').val('');
		jQuery('#date2').val('');
		jQuery('#date3').val('');
		
	};	
	
		
});

}




function accordian(listName) {
	
	//initially hide any child lists of the parent - just as a precaution
	jQuery('#' + listName + ' ul > li')
	.hide()
	
	//open the first list for display initially
	jQuery('#' + listName + ' ul:first li').slideToggle('slow');
	jQuery('#' + listName + ' li img.smallActive:first').attr('src', 'images/activeButtonRotated.png')
	
	//on the click event we do this .........
	jQuery('#' + listName + ' li')
	.click(function(e) {
	//e.stopPropagation()
	
	//any visible answers we need to toggle and hide
	jQuery('#' + listName + ' ul > li').filter(':visible')
	.slideToggle('fast');
	
	//and reset the image to the default arrow image
	jQuery('#' + listName + ' li img.smallActive')
	.attr('src', 'images/activeButtonSmall.png')
	//.css({'left':'33px','top':'2px'});
	
	//if the child list of the line item clicked is hidden then toggle it 
	//(prevents closing and reopening of already open items)	
	if(jQuery(this).find('ul li:first').is(':hidden')){

			jQuery(this).find('ul li').slideToggle(800);
			
			//then replace the arrow image 
			
			jQuery(this).find('img.smallActive').attr('src', 'images/activeButtonRotated.png')
			//.css({'left':'25px','top':'5px'});
			
	}
	
			
	})	
	
	
	//on mouseover and mouseout we change the background image and the font colour of the selected list item
	//jQuery('#' + listName + ' li')
	//.mouseover(function() {
	//	jQuery(this).find('p').css({'background-image':'url(images/greyGradientInvert.jpg)','color':'#87B229'});	
	//})
	//.mouseout(function(){		
	//	jQuery(this).find('p').css({'background-image':'url(images/greyGradientBackground.jpg)','color':'#6C6C6C'});	
	//});

				
}













function checkForAlertMessage()	{
	
	if(alertMessage != "") {
		
		alert(alertMessage)	
		
	
	}		
		
}


function clearInput(obj) {
	
	
	
	if ((obj.value == "Enter contact name") || (obj.value == "Enter email address") || (obj.value == "Your Name") || (obj.value == "Business Name") || (obj.value == "Email Address")) {
		
			obj.value = ""
			
		}
			
	
}


