// JavaScript Document
jQuery(document).ready(function(){
	
if (jQuery('#large_images').length > 0) {
		
		jQuery('#large_images').cycle({ 
		    fx: 'fade', 
		    timeout: 0,
			next: '#btn_right',
		    prev: '#btn_left',
		    pager: '#pager',
		    // callback fn that creates a thumbnail to use as pager anchor 
    		pagerAnchorBuilder: function(idx, slide) {
				var thumb_src = my_pics["" + slide.id];
    			//console.log(thumb_src);
        		var pager_item_template =
    			'<li class="pager_item">' + 
        			'<img src="' + thumb_src + '" width="129" height="96" />' + 
        		'</li>'; 
        		
        		return pager_item_template;
            }, 
			after: function () { 
		    	var picture = pic_pos["" + this.id];
				var picture_id = this.id;
				total = jQuery('#large_images').children().length;
				jQuery('#picture_counter p').text(picture + ' of ' + total);
		    	jQuery('#pic_desc').children().hide();
		    	jQuery('#pic_desc .' + picture_id).show();
		    }
		});
		
		
		jQuery('a.thumbnails').toggle( 
			function (e) {
				e.preventDefault();
				jQuery('#thumbnails').slideDown('slow');
				jQuery('#pic_frame').slideUp('slow');
				jQuery('#pic_desc').slideUp('slow');
				jQuery('#picture_counter').slideUp('slow');
				
				jQuery('div.gallery_btns').removeClass('btns_bottom');
				jQuery('div.gallery_btns').addClass('btns_top');
				
				
				jQuery('a.thumbnails').removeClass('thumbnails_up');
				jQuery('a.thumbnails').addClass('thumbnails_down');
				return false;
			},
			function (e) {
				e.preventDefault();
				jQuery('#thumbnails').slideUp('fast');
				jQuery('#pic_frame').slideDown('slow');
				jQuery('#pic_desc').slideDown('slow');
				jQuery('#picture_counter').slideDown('slow');
				
				jQuery('div.gallery_btns').removeClass('btns_top');
				jQuery('div.gallery_btns').addClass('btns_bottom');
				
				jQuery('a.thumbnails').removeClass('thumbnails_down');
				jQuery('a.thumbnails').addClass('thumbnails_up');
				return false;
			}
		);
		
		
		jQuery('.pager_item img').click( function (e) {
			jQuery('a.thumbnails').trigger('click');
		});
		
		}
		
		
			
			
		jQuery('.home_heading').click( function (e) {
			e.preventDefault();	
			var link_id = jQuery(this).get(0).id;
			jQuery('.panel').addClass("hidden");
			jQuery('.panel').removeClass("show");
			jQuery('.' +link_id+'_panel').removeClass("hidden");
			jQuery('.' +link_id+'_panel').addClass("show");
			jQuery('.home_heading').removeClass("heading_active");
			jQuery(this).addClass('heading_active');
			if (link_id == 'tab_1'){
				var color_class = 'pink';
			}
			else if(link_id == 'tab_2'){
				var color_class = 'blue';
			}
			else if(link_id == 'tab_3'){
				var color_class = 'yellow';
			}
			jQuery('div.box').removeClass("box_yellow");
			jQuery('div.box').removeClass("box_pink");
			jQuery('div.box').removeClass("box_blue");
			jQuery('div.box').addClass("box_" +color_class);
		});
		
		
		// required fields asterisk decoration for contact form
		if (jQuery('#Form_Form').length > 0) {
					var labelMarker = '<em>*</em>';
					jQuery('#Form_Form_EditableTextField29, #Form_Form_EditableEmailField30, #Form_Form_EditableTextField31').parent().siblings('label').each(function(){
					jQuery(this).html(jQuery(this).html() + ' <span>*</span>');
																																												}
					);			
		}
		
		//dynamic max-width
		if(jQuery('#content p')){
		jQuery('#content p, #content h1, #content h2, #content h3, #content ul li, #content ol li').each(function(e){
			var p_width = jQuery(e.target).width();	
			if (p_width>420){
				jQuery(this).css("width", 420);
				}
			});
		jQuery('.content_narrow p, .content_narrow h1, .content_narrow h2, .content_narrow h3').css("width", '100%');
		jQuery('#content table li').css("width", '100%');
		jQuery('.service_box p').css("width", '100%');
		jQuery('#thumbnails ul li').css("width", 154);
		jQuery('#content_left p, #content_left h1, #content_left h2, #content_left h3, #content_left ul li').css("width", '100%');
		}
		
		// newsletter subscription form validation
		if(jQuery("#newsletter_form").length > 0){
		jQuery("#newsletter_form").validate();
		}
		
		/**/
		if (jQuery('#banner_home').length > 0) {
			jQuery('#banner_home').cycle({ 
					fx: 'fade', 
					timeout: 4000,
					speed: 3000
				});
			}
		
	
});

jQuery(window).load(function () {

	if (window.location.hash == '#thankyou') {
		alert('Thank you for subscribing!')
	}

});

// input field text reset functions
function resetField(field, value){
	if (field.value==value){
		field.value="";	
		return false;
	}
}

function startValue(field, text){
			if (field.value==""){
			field.value=text;	
			return false;
			}
}




