﻿/*
Watermarks

This does the watermarking for input boxes, use the watermark class on
labels, watermarkJS is added so you can position the label over the input
*/

$(function(){

	$('label.watermark').addClass("watermarkJS");
	$('label.watermark').each(function(index,label){
	    eleInput = $('#'+$(label).attr("for"))[0];
	    
	    if(eleInput.value != "")
	    {
	        $(label).hide();
	    }
	    
	    $(eleInput).blur(function(){
	        eleInput = $('#'+$(label).attr("for"))[0];
	        if(eleInput.value == "")
	        {
	            $(label).show();
	        }
	    });
	    $(eleInput).focus(function(){
	        eleInput = $('#'+$(label).attr("for"))[0];
	        $(label).hide();
	    });
	    
	});
	
});     
/*
End Watermarks
*/


// AJAX enable in-line gallery module
jQuery(function($){
	$('.moduleType_Images:has(.type-inline)').each(function(index,section){ // all inline sections
		$('.gallerylist li a',section).click(function(){
			thumbpath = $('img',this).attr('src');
			imgID = thumbpath.substring(thumbpath.lastIndexOf("_")+1);
			imgID = imgID.substring(0,imgID.indexOf('.'));
			//console.log(imgID);
			$('.image-inline',section).attr('src','/UserFiles/Image/images_full_'+imgID+'.jpg')
			$('.image-inline',section).attr('alt',$('img',this).attr('alt'))
			$('.gallerylist li.selected',section).removeClass('selected');
			$(this).parent().addClass('selected');
			
			$('.image-description',section).load($(this).attr('href')+' #'+$(section).attr('id')+' .image-description *' );
			if((typeof pageTracker)!="undefined")
			{
				// don't neglect analytics!
				pageTracker._trackPageview($(this).attr('href'));
			}
			return false;
		});
	})
});


$(function() {

	function rgbToHex(rgb) {
		var parts = rgb
				.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)
		;
		// parts now should be ["rgb(0, 70, 255", "0", "70", "255"]
		delete (parts[0]);
		for (var i = 1; i <= 3; ++i) {
			parts[i] = parseInt(parts[i]).toString(16);
			if (parts[i].length == 1) parts[i] = '0' + parts[i];
		}
		return parts.join('');
	} 

	$('.Top .RightCol ul').cycle({
		fx: 'fade',
		speed: 2000,
		timeout: 9000
		
	});
	
	$('.Sub .Top .LeftCol ul').cycle({
		fx: 'fade',
		speed: 2000,
		timeout: 9000
		
	});
	


$('.Sub .Top .LeftCol #slideshow').after('<ul id="nav">').cycle({ 
    fx:     'fade', 
    speed:  'fast', 
    timeout: 9000, 
    pager:  '#nav',
     
    // callback fn that creates a thumbnail to use as pager anchor 
    pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="#"><img src="' + slide.src.replace("HeaderImage","ThumbImage") + '"   /></a></li>'; 
    } 
});

	
	/*
	$('.Sub .Top .LeftCol #project ul').cycle({ 
    fx:     'scrollLeft', 
    speed:  'fast', 
    timeout: 0, 
    pager:  '#projectnav', 


     
    // callback fn that creates a thumbnail to use as pager anchor 
    pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="#"><img src="' + <% slide.firstChild.src.replace("HeaderImage","ThumbImage")%> + '/></a></li>'; 
    } 
});
*/	


});




