// functions

$(document).ready(function(){

	// launch external links
	$('a[rel=external]').click( 
		function() {
			window.open(this.href);
			return false;
		}
	);

	// handle dhtml in main navigation
	//$('#navigation li').hover( 
	//	function() {
	//		$(this).children('ul.subNav').fadeIn(300); 
	//	},
	//	function() { 
	//		$(this).children('ul.subNav').fadeOut(300); 
	//	}
		
	//);
	
	
	
	// contact overlay
	$(".contactOverlay a").colorbox({
		  inline:true
		, href:"#contactForm"
		, opacity: 0.5
		, transition: "fade"
		, onOpen:function(){ $("#cboxWrapper").addClass("contactHover"); }
	});

		$(".close").click(function() { $.fn.colorbox.close();  } );
	
	// contact overlay
	$("a[rel='example']").colorbox({
	});

/* gallery items */
    var gallery = $('#gallery').galleriffic('#thumbs', {
        delay:                  3000, // in milliseconds
        numThumbs:              10, // The number of thumbnails to show page
        preloadAhead:           40, // Set to -1 to preload all images
        enableTopPager:         false,
        enableBottomPager:      true,
        imageContainerSel:      '#body', // The CSS selector for the element within which the main slideshow image should be rendered
        controlsContainerSel:   '', // The CSS selector for the element within which the slideshow controls should be rendered
        captionContainerSel:    '', // The CSS selector for the element within which the captions should be rendered
        loadingContainerSel:    '', // The CSS selector for the element within which should be shown when an image is loading
        renderSSControls:       true, // Specifies whether the slideshow's Play and Pause links should be rendered
        renderNavControls:      true, // Specifies whether the slideshow's Next and Previous links should be rendered
        playLinkText:           'Play',
        pauseLinkText:          'Pause',
        prevLinkText:           'Previous',
        nextLinkText:           'Next',
        nextPageLinkText:       '&raquo',
        prevPageLinkText:       '&laquo;',
        enableHistory:          false, // Specifies whether the url's hash and the browser's history cache should update when the current slideshow image changes 
        autoStart:              false, // Specifies whether the slideshow should be playing or paused when the page first loads 
        onChange:               undefined, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
        onTransitionOut:        undefined, // accepts a delegate like such: function(callback) { ... }
        onTransitionIn:         undefined, // accepts a delegate like such: function() { ... }
        onPageTransitionOut:    undefined, // accepts a delegate like such: function(callback) { ... }
        onPageTransitionIn:     undefined  // accepts a delegate like such: function() { ... }
    });


});



function checkUpload() {
	if((document.upload.uploadedfile.value.lastIndexOf(".jpg")==-1)) {
	   alert("Please upload only .jpg files");
	   return false;
	}
}

function checkProductUpload() {
	if(document.upload.product_name.value == "") {
	   alert("Please enter a product name");
	   return false;
	}
	if(document.upload.product_info.value == "") {
	   alert("Please enter a product description");
	   return false;
	}
	if((document.upload.uploadedfile.value.lastIndexOf(".jpg")==-1)) {
	   alert("Please upload only .jpg files");
	   return false;
	}
	
}

function confirmDelete() {
	var answer = confirm ("Are you sure you want to delete this image?")
	return answer;
}

function confirmDeleteProduct() {
	var answer = confirm ("Are you sure you want to delete this Product?")
	return answer;
}

