$(document).ready(function() {

$('.sm-input').focus(function() {
	$(this).parent('.field').addClass('active');
});

$('.sm-input').focusout(function() {
	$(this).parent('.field').removeClass('active');
});

$('.sm-textarea').focus(function() {
	$(this).parent('.field').addClass('active');
});

$('.sm-textarea').focusout(function() {
	$(this).parent('.field').removeClass('active');
});

	$("div.works").hover(function() { 

		var thumbOver = $(this).find("img").attr("src"); 

		
		$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});

		
		$(this).find("span").stop().fadeTo('normal', 0 , function() {
			$(this).hide() 
		});
	} , function() {
		
		$(this).find("span").stop().fadeTo('normal', 1).show();
	});

});

function updateStyleSheet(filename) {
 
    // Create the CSS file name:
 
    newstylesheet = "/wp-content/themes/sitemedia/css-templates/temp-" + filename + ".css";
 
    // Does the <link> tag (with id:dynamic_css) exist?
    // If not, we need to create it.
 
    if ($("#theme_css").length == 0) {
 
        // The next line will add the
        // <link> tag between the
        // <head> tags.
 
        $("head").append("<link>")
 
        // The next line will select the
        // <link> element you just added.
 
        css = $("head").children(":last");
 
        // The next line will set the
        // attributes of the elements
        // to make it load the CSS file.
 
        css.attr({
          id: "theme_css",
          rel:  "stylesheet",
          type: "text/css",
          href: newstylesheet
        });
 
    // If the <link> element already exists, we
    // simply need to change the value of "href". 
 
    } else {
        $("#theme_css").attr("href",newstylesheet);
    }
 
}
