// DOM Loaded 
$(function(){ 

    // 'structural' form labels 
   $('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 ($.trim(this.value == '')){
        	this.value = (this.defaultValue ? this.defaultValue : '');
    	}
    }); 
	 
    // homepage cycles 
    $('#feature_gallery .bigimg').wrapAll('<div class="bigimgs">').parents('#feature_gallery').prepend('<ul class="menu" id="feature_gallery_pager">').cycle({ 
        fx:'scrollLeft', 
        easing: 'easeOutBounce', 
        inDelay:    250, 
        drop:       40, 
        timeout:    5000, 
        pause:      true,
		before:  onBefore,
        slideExpr: '.bigimg', 
        pager:      '#feature_gallery_pager', 
        pagerAnchorBuilder: function(idx, slide) { 
          
            return '<li><a href="#"><img src="'+slide.id+'" class="thumb"><span></span></a></li>';  
        } 
		
    });
	
function onBefore() { 
    $('#out').html(this.title); 
}
 	
$('#page-list ul li.page_item ul').hide();
//when navigate to a child page show all pages
$('#page-list ul li.current_page_item').parent("ul").show();
//show page list when toggle
$('#page-list ul li.active ul').show();
$('#page-list ul li.current_page_item ul').show();

	 $('#page-list ul li').click(function() { 
$(this).addClass("active");
                    $(this).children('ul').slideToggle("slow"); 
            });
    //validate forms 
    $('#contact_form').validate(); 
     
    // add back button for iphone 
    var iphone = (ua.indexOf("iphone")>=0 || ua.indexOf("ipod")>=0 || ua.indexOf("android")>=0) ? true : false; 
    if(iphone) { 
       $('#footer').after('<div style="font-size:40px; padding:10px 0 50px; background:#003042;"><a href="/?toggle_site">Back to Mobile Site</a></div>'); 
    } 
	  document.write('<style type="text/css">');    
  document.write('div.domtab div{display:none;}<');
  document.write('/s'+'tyle>'); 
}); 
 


 
