 //close button function

$(document).ready(function(){
						   
	$(".delete").click(function(){
		$("#content").slideUp(400);
		$(".delete").fadeOut('fast');
		document.location.hash = ("#index");
		return false;
		
	});
 
});

 
 //meter overlay
 
$(document).ready(function(){

$("#status").hide();
	
	$(".meter_overlay").mouseover(function(){
		$("#status").stop(true, true).fadeIn();
	}); 
	
	$(".meter_overlay").mouseout(function(){
	$("#status").stop(true, true).fadeOut();
	});
	

});

$(document).ready(function(){

$(".level").hide();
$(".prof").hide();
	
	$(".skill_hud").hover(function(){
	 $(this).stop(true, true).animate({height:'110px'},{queue:false,duration:300});  
		$(".level", this).stop(true, true).fadeIn(370);
		$(".prof", this).stop(true, true).fadeIn(450);
	},
	function(){
	
	
	$(this).stop(true, true).animate({height:'80px'},{queue:false,duration:300}); 
		$(".level", this).stop(true, true).fadeOut(200);
		$(".prof", this).stop(true, true).fadeOut(200);
	});
	


});




//works scroll

$(document).ready(function(){
						   
	$(".item a").click(function(){
	
		$.scrollTo( '#works', 200 ); return false;
		
	});
 
});


//Thumbnail cover

$(document).ready(function(){  
  
    $('.cover').hide();
 $('.item').hover(function(){  
     $('.cover', this).stop(true, true).fadeIn(300);
	  }, function() {  
      $('.cover', this).stop(true, true).fadeOut(300);
  });  
   
});  

	

	
//loader
/**
 * Original Script by James Padosley for Nettuts.com
 * Updated to be based on his script as of Nov 18, 2009
 *
 * Modified by Patrick Eisenmann to support history and lightbox/PrototypeJS libraries
 *	(peisenmann@gatech.edu)
 *
 * Modified by Andre Bluehs to support PHP (and any other user added extensions)
 *	(contagious@gatech.edu)
 *
 * Farther modyfied by Paweł Durczok and Tomasz Kszos
 */

// Do this when the document loads
$(document).ready(function() {    
    // Id of the tag that will wrap the content
    var contentWrapID = '___content-wrapper';
        
    // Wrapping the content. This will keep us from duplicating the content div
    // This is an important change from James' script because his would not work
    // for Safari
    var wrapDiv = document.createElement("div");
    wrapDiv.id = contentWrapID;
    $('#content').wrap(wrapDiv);
    
    // Once we've loaded the new content, show it
    function showNewContent() {
        // Show the wrapper that contains the content
		
        $("#" + contentWrapID).slideDown(400);
       
        // Hide the ajax loader icon
        $('#load').fadeOut();
		 $('.slider').cycle({ 
		 fx: 'fade',
		 prev:   '#prev', 
			next:   '#next',
			     speed: 500,
				 sync: 1,
        timeout: 0
    });
	
	
	
	
	
         $('.delete').fadeIn('fast');
        // Make Fancyboxes fancy
        $('a.fancybox').fancybox();
		
		
	
		
    }
    
    // Load a page based on a hash (Given from the address bar)
    function pageload(hash) {
        // If the hash is not empty or undefined
        if(hash) {            
            // Hide the content
            $("#" + contentWrapID).slideUp(400,
                function()
                {
                    // Snag the GET parameters
                    var vars = GETVars();
                    var stringVars = "";
                    
                    // Add in GET variables
                    for (var v in vars)
                    {
                        // Have to watch out for Prototype adding junk to the array prototype
                        if (typeof vars[v] != "function")
                        {
                            // Put the vars in the string
                            stringVars += v + "=" + vars[v] + "&";
                        }
                    }
                    // If we actually had any vars
                    if (stringVars.length > 0)
                    {
                        // Prepend the question mark for the query
                        stringVars = "?" + stringVars;
                    }
                    
                    // Load the #content div from page of the mentioned in the hash
                    $("#" + contentWrapID).load(hash + stringVars + " #content",'',function (responseText, textStatus, XMLHttpRequest) {
                        
                        // Don't bother if the hash was busted
                        if (textStatus == "error") return;
                        
                        // This helps show the content only when it's all loaded
                        if($('img:last',this).get(0)) {
                            $('img:last',this).load(function(){
                                showNewContent();
                            });
                        } else {
                            showNewContent();
							
                        }

                    });
                }
            );


        } else {
            // Load this page
            pageload(window.location.href);
			
        }
    }
    // Initialize history
    $.historyInit(pageload);
    
    // Adds the onclick function to the links
    $('#works a').click(function(){
        
        // Get the hash from the link that was clicked
		
        var hash = new String($(this).attr('href'));
        var index = hash.lastIndexOf('/');

        if (index == hash.length-1)
        {
            hash = hash.substr(0, hash.length-1);
            index = hash.lastIndexOf('/');
        }

        if (index != -1)
        {
            hash = hash.substr(index+1, hash.length-index-1)
        }
        if (location.hash == hash || location.hash == '#' + hash)
        {
            return false;
        }

        var qMark = hash.indexOf("?");
        var nSign = hash.indexOf("#");
        if (qMark > -1 && ((nSign > -1 && qMark < nSign) || nSign == -1))
        {
//            hash = hash + "?" + hash.replace(/^.*\?/, '');
        }
        else
        {
            hash = hash.replace(/^.*#/, '');
        }

        // Load this hash with the history plugin
        $.historyLoad(hash);
        
        if(!$('#load').get(0)) {
            $('#loading').append('<span id="load">LOADING...</span>');
			
        }
		$(".delete").fadeOut('fast');
        $('#load').fadeIn('normal');
        return false;
    });
});

// Returns all the GET parameters in url
// Added by Patrick on 04/02/2010
function GETVars()
{
    // Grab the url string
    var loc = document.location.search;         
    var vars = new Array();

    // Split off the parameters
    var sections = loc.split("?");
    // If there were no parameters, return
    if (sections.length < 2)
    {
        return vars;
    }
    // There are some url parameters
    else
    {
        // Get rid of the anchor
        var paramString = sections[1].split("#")[0];
        // Given a URL like http://www.example.com/?var1=lala&var2=3&var3=test&#blog.php
        // we should have just isolated the "var1=lala&var2=3&var3=test&" portion
        
        // Split the variables apart
        var params = paramString.split("&");
        for (p in params)
        {
            // If there wasn't really a parameter here
            if (params[p].length < 1) {continue;}
            
            // Must avoid Prototype's junk
            if (typeof params[p] == "function") {continue;}
            
            // Split the key and value apart
            var keyValue = params[p].split("=");
            
            // If there was only a key
            if (keyValue.length == 1)
            {
                vars[keyValue[0]] = "";
            }
            // If there was a key and value
            else
            {
                vars[keyValue[0]] = keyValue[1];
            }
        }
    }
    // Send back the arrayw
    return vars;
	
	
	
	
}
 
 
//contact
function input_focus(id)
{
	$("#l"+id).addClass('lcurrent');
}

function input_blur(id)
{
	$("#l"+id).removeClass('lcurrent');
}

function sendContact()
{
	// check for email
	var email = $("#email").val();
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(email))	
	{
		$("#email-error").slideDown(500);
		$("#email").focus();
		return false;
	}
	else
		$("#email-error").slideUp(500);
	
	// check for message
	var msg = $("#message").val();
	if(msg.length == 0)
	{
		$("#message-error").slideDown(500);
		$("#message").focus();
		return false;
	}
	else
		$("#message-error").slideUp(500);
		
	// check for captcha
	var captcha = $("#captcha").val();
	if(captcha != captcha_c)
	{
		$("#captcha-error").slideDown(500);
		$("#captcha").focus();
		return false;
	}
	else
		$("#captcha-error").slideUp(500);	
	
	var data = $("#contact_form > form").serialize();

	$.ajax({
		type: "POST",
		url: "sendContact.php",
		data: data,
		cache: false,
		success: function(msg){
		}
	});
	
	$("#formu").fadeOut(500, function() {
		$("#message_sent").fadeIn(500);
	});
	
	
	return false;
}

var captcha_a = Math.ceil(Math.random() * 10);
var captcha_b = Math.ceil(Math.random() * 10);       
var captcha_c = captcha_a + captcha_b;
function generate_captcha(id)
{
	var id = (id) ? id : 'lcaptcha';
	$("#"+id).html(captcha_a + " + " + captcha_b + " = ");
}

 
         $().ready(function () {
            var stickyPanelOptions = {
                topPadding: 0,
                savePanelSpace: false
            };
            $("#menu_wrapper").stickyPanel(stickyPanelOptions);
        });
 
 
 
 
 
 



 
