$(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
	----------------------------------------------------*/
	
	/* = jQuery UI BUTTONS
	----------------------------------------------------*/
	$(".button").button();	
	
	
	/* = 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_us_form').ajaxForm({target: "#contact_us_form"});
	 /*$('#contactform').ajaxForm({target: "#contactform"});
	 $('#email_form').ajaxForm({target: "#email_form"});*/
	
	/* = END SUBMIT CONTACT FORM
	----------------------------------------------------*/
	
	 
	/* = PROMOS
	----------------------------------------------------*/
	if($('#promoslides').length > 0){
	   $('#promoslides').cycle({ 
		fx:     'fade',
		delay:  -2000,
		timeout: 5000
		});
	}
	/* = END PROMOS
	----------------------------------------------------*/


	/* = EMAIL THIS PAGE
	----------------------------------------------------*/
    $(".opendialog").click(function(){
        var url = $(this).attr("href");
		$("body").append('<div id="modal_dialog"></div>');
        $.ajax({
          url: "http://"+window.location.hostname+"/ajax.php",
          data: "action=getemailform&url="+url,
          success: function(frm){
              $("#modal_dialog").html(frm);
			  
          }
               
          });                           
        $("#modal_dialog").dialog({
            title: "Email this page",
            width: 540,
            height:450,
            modal: true,
            close: function(){
                $("#modal_dialog").dialog('destroy');
				$("#modal_dialog").remove();
            }
        });
        return false;
    });
});


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