$(function(){
// form text fields - remove default value and change css class
	
	$('input[type="text"]').addClass("idleField");  
	$('input[type="text"]').focus(function() {  
		$(this).removeClass("idleField").addClass("focusField");  
		if (this.value == this.defaultValue){  
			this.value = '';  
		}  
		if(this.value != this.defaultValue){  
			this.select();  
		}  
	});  
	$('input[type="text"]').blur(function() {  
		$(this).removeClass("focusField").addClass("idleField");  
		if (this.value == ''){  
			this.value = (this.defaultValue ? this.defaultValue : '');  
		}  
	});
	
//handle mailing list signup
	$('#addressForm').submit(function (e) {
		e.preventDefault();
		var em = escape($('#email').val()),
		f= $('#fname').val(),
		l= $('#lname').val();
		$.post('include/front/signup.inc.php', {
			email:em, fname:f, lname:l},
			function(data) {
				alert(data);
		});
	});
	/*make it visible*/
	
	$("ul#ticker").css('display','');
	$("ul#ticker").liScroll({travelocity: 0.03});
	
});

function prodImg(){
	var onMouseOutOpacity = 0.67;
	$('#thumbs ul.thumbs li').opacityrollover({
		mouseOutOpacity: onMouseOutOpacity,
		mouseOverOpacity: 1.0,
		fadeSpeed: 'fast',
		exemptionSelector: '.selected'
	}); 
	var gallery = $('#thumbs').galleriffic({
        delay:                     3000, // in milliseconds
        numThumbs:                 4, // The number of thumbnails to show page
        preloadAhead:              -1, // Set to -1 to preload all images
        enableTopPager:            false,
        enableBottomPager:         false,
        maxPagesToShow:            7,  // The maximum number of pages to display in either the top or bottom pager
        imageContainerSel:         '#screen', // 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:          false, // Specifies whether the slideshow's Play and Pause links should be rendered
        renderNavControls:         false, // Specifies whether the slideshow's Next and Previous links should be rendered
        playLinkText:              'Play',
        pauseLinkText:             'Pause',
        prevLinkText:              'Previous',
        nextLinkText:              'Next',
        nextPageLinkText:          'Next &rsaquo;',
        prevPageLinkText:          '&lsaquo; Prev',
        enableHistory:             false, // Specifies whether the url's hash and the browser's history cache should update when the current slideshow image changes
        enableKeyboardNavigation:  false, // Specifies whether keyboard navigation is enabled
        autoStart:                 false, // Specifies whether the slideshow should be playing or paused when the page first loads
        syncTransitions:           false, // Specifies whether the out and in transitions occur simultaneously or distinctly
        defaultTransitionDuration: 1000, // If using the default transitions, specifies the duration of the transitions
        onSlideChange:             function(prevIndex, nextIndex) {
        								// 'this' refers to the gallery, which is an extension of $('#thumbs')
        								this.find('ul.thumbs').children()
        								.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
        								.eq(nextIndex).fadeTo('fast', 1.0);
										
        							}, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
        onTransitionOut:           undefined, // accepts a delegate like such: function(slide, caption, isSync, callback) { ... }
        onTransitionIn:            undefined,// accepts a delegate like such: function(slide, caption, isSync) { ... }
        onPageTransitionOut:       undefined, // accepts a delegate like such: function(callback) { ... }
        onPageTransitionIn:        undefined,  // accepts a delegate like such: function() { ... }
        onImageAdded:              undefined, // accepts a delegate like such: function(imageData, $li) { ... }
        onImageRemoved:            undefined  // accepts a delegate like such: function(imageData, $li) { ... }
    });
}

function galImg(){
	var onMouseOutOpacity = 0.67;
	$('#thumbs ul.thumbs li').opacityrollover({
		mouseOutOpacity: onMouseOutOpacity,
		mouseOverOpacity: 1.0,
		fadeSpeed: 'fast',
		exemptionSelector: '.selected'
	}); 
	var gallery = $('#thumbs').galleriffic({
		delay:                     2500,
		numThumbs:                 10,
		preloadAhead:              10,
		enableTopPager:            false,
		enableBottomPager:         true,
		maxPagesToShow:            0,
		imageContainerSel:         '#screen',
		controlsContainerSel:      '',
		captionContainerSel:       '',
		loadingContainerSel:       '',
		renderSSControls:          false,
		renderNavControls:         false,
		playLinkText:              'Play Slideshow',
		pauseLinkText:             'Pause Slideshow',
		prevLinkText:              '&lsaquo; Previous Photo',
		nextLinkText:              'Next Photo &rsaquo;',
		nextPageLinkText:          'Next&rsaquo;',
		prevPageLinkText:          '&lsaquo;Prev',
		enableHistory:             false,
		autoStart:                 false,
		syncTransitions:           false,
		defaultTransitionDuration: 900,
		onSlideChange:             function(prevIndex, nextIndex) {
			// 'this' refers to the gallery, which is an extension of $('#thumbs')
			this.find('ul.thumbs').children()
				.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
				.eq(nextIndex).fadeTo('fast', 1.0);
		},
		onPageTransitionOut:       function(callback) {
			this.fadeTo('fast', 0.0, callback);
		},
		onPageTransitionIn:        function() {
			this.fadeTo('fast', 1.0);
		}
	});
}

function lightbox(){
	$("#zoom").click(function() {
		var lbImage = $('a.advance-link img').attr('src');
		var slash = lbImage.lastIndexOf("/");
		lbImage = "uploads/image/lightbox" + lbImage.substr(slash);
		var lbTitle = $('a.advance-link img').attr('alt');
		$.fancybox({
		//'orig' : $(this),
		'padding' : 0,
		'href' : lbImage,
		'title' : lbTitle,
		'transitionIn' : 'elastic',
		'transitionOut' : 'elastic',
		'overlayColor' : '#000'
		});
	});
}
