$.fn.hoverClass = function(c) {
    return this.each(function(){
        $(this).hover( 
            function() { $(this).addClass(c); },
            function() { $(this).removeClass(c); }
        );
        
    });
};

$.fn.clickClass = function(c) {
    return this.each(function(){
        $(this).click( 
            function() { 
            	if ($(this).attr('class') == c)
    			{
    				$(this).removeClass(c);
    			}
    			else
    			{
    				$(this).addClass(c);
    			}
             }
        );
        
    });
};

$(document).ready(
	
	function() 
	{
		/* KEEP CODE FROM HERE DOWN TO NEXT COMMENT BLOCK ON ALL PROJECTS */
		
		$('input#filename').keyup(function()
		{
			jQuery.ajax(
		   	{
		   		type: "GET",
		   		url: "/page/check_filename.html?filename=" + $(this).val() + '&old_filename='+$('#old_filename').val(),
		   		dataType: "html",
		   		timeout: 15000,
		   		error: function() {},
		   		success: function(r) {
		   								if (r == 'success')
		   								{
		   									$("#filename_status").attr({src: '/images/icons/accept.png'}); 
		   									if ($('input#title').val() != '') 
		   										$("#edit_submit").attr('disabled', false);
		   									$("#filename_text").html('');
		   								}
		   								else
		   								{
		   									$("#filename_status").attr({src: '/images/icons/delete.png'}); 
		   									$("#filename_text").html(r);
		   									$("#edit_submit").attr('disabled', true);
		   								}
		   							}
		   	});
		});
		
		$('input#title').keyup(function()
		{
			if ($(this).val() != '')
			{
				$("#title_status").attr({src: '/images/icons/accept.png'}); 
				if ($("#filename_status").attr('src') == '/images/icons/accept.png')
					$("#edit_submit").attr('disabled', false);
		   	}
		   	else
		   	{
		   		$("#title_status").attr({src: '/images/icons/delete.png'}); 
		   		$("#edit_submit").attr('disabled', true);
		   	}
		});
		
		$('.confirm_anchor').click(function()
		{
			return confirm('Are you SURE you want to do this???');
		});
		
		$('a.new_window').click(function()
		{
			window.open($(this).attr('href'));
			return false;
		});

		/* KEEP CODE FROM HERE UP TO PREVIOUS COMMENT BLOCK ON ALL PROJECTS*/

		$("ul.top_links li").hover(function(){ $("ul", this).fadeIn("fast"); }, function() { $("ul", this).fadeOut("fast"); } );
		$("ul.top_links li").hoverClass ("hover");

		$('#header').flash(null, {version: 7}, function(htmlOptions){
			var gen_phone_number = $(this);
			// Set options
			htmlOptions.src     = gen_phone_number.attr('rel');
			htmlOptions.width   = 946;
			htmlOptions.height  = 218;
			htmlOptions.quality = 'high';
			htmlOptions.wmode   = 'transparent';
			// Embed it!
			gen_phone_number.prepend($.fn.flash.transform(htmlOptions));
		});

		$('#box').cycle({
			fx:      'fade',
			timeout: 7500,
			pause: 1
		});
		
			jQuery('#mycarousel').jcarousel({
        	// Configuration goes here
        	scroll: 1,
        	visible: 4
    	});
    	
    	$('#mycarousel a.photograph').colorbox();
		
});
