// JavaScript Document
$(document).ready(function() {
	/* = HIGHLIGHT CURRENT PAGE
	----------------------------------------------------*/
	var currentfile = jQuery.url.attr("file");
    var currentaction = jQuery.url.param("a");
    var currentdir = jQuery.url.attr("directory");
     
	 $("#navigation li a").each(function (i) {
		if ($(this).attr('href') == "http://"+window.location.hostname+currentdir) {
			$(this).parents("li").addClass('selectednav');          
		}else if($(this).attr('href') == "http://"+window.location.hostname+"/"+currentfile) {
			 $(this).parents("li").addClass('selectednav');
		}
	 });
	 /* = END HIGHLIGHT CURRENT PAGE
	----------------------------------------------------*/
	
	
	/* = SEARCH
	----------------------------------------------------*/
	//clear search box pn focus
	$("#search").focus(function(){
		if($(this).val()=="Search Carnevale Associates, LLC"){
			$(this).val("");	
		}	
	}).blur(function(){
		if($(this).val()==""){
			$(this).val("Search Carnevale Associates, LLC");	
		}	
	});
	
	/* = END SEARCH
	----------------------------------------------------*/
	
	
	/* = PROMOS
	----------------------------------------------------*/
	if($('#slides').length > 0){
	   $('#slides').after('<div class="nav">').cycle({ 
		fx:     'fade', 
		pager: '.nav',
		delay:  -2000,
		timeout: 8000
		});
	}
	
	if($('.nav a').length < 1){
		$('.nav').remove();	
	}
	/* = END PROMOS
	----------------------------------------------------*/
	
	
	/* = LOAD CONTACT FORM
	----------------------------------------------------*/
     if($("#contact_us_form").length > 0){
		$(".contact-form-other").hide();
        $.ajax({
          url: "http://"+window.location.hostname+"/ajax.php",
          data: "action=getcontactform",
          success: function(frm){
              $("#contact_us_form").html(frm);
          }
               
          });    
     }
	 /* = END LOAD CONTACT FORM
	----------------------------------------------------*/
	
	/* = SUBMIT CONTACT FORM
	----------------------------------------------------*/
     $('#contact_form').ajaxForm({target: "#contact_us_form"});
	
	/* = END SUBMIT CONTACT FORM
	----------------------------------------------------*/
	/*x$(".shownavigation").on( "click", function(e){
		$("#content").toggle("fast");
		return false;
	});*/
	 
});

/* = SUBMIT CONTACT FORM
	----------------------------------------------------*/
function submitcontactform(id){
	 $('#'+id).ajaxForm({target: "#"+id});
	/* $('#contactform').ajaxForm({target: "#contactform"});
	 $('#email_form').ajaxForm({target: "#email_form"});*/
}

function shownavigation(){
	$("#content").toggle("fast");
	return false;
}
