/**************************************
Script name: site.js

Script location: http://www.wattzup.com/js/site.js

Script functionality: Control basic and advanced
functions of the WattzUp Web Design Website

License: GNU Public Use

Table of contents:
@styling functions

***************************************/

$(function(){
	//Styling functions.
	//Making CSS3 Cross browser
	
	//Rotation
	$("[data-rot]").each(function() {
		var rotation = $(this).attr("data-rot");
		$(this).css({ '-moz-transform': 'rotate('+rotation+'deg'+')', '-webkit-transform': 'rotate('+rotation+'deg'+')' });
	});
	
	//Gradients
	$("[data-grad]").each(function() {
		var grad = $(this).attr("data-grad");
		var color = grad.split(',');
		
		var bgWebkit = '-webkit-linear-gradient(top, '+ color[0] +', '+ color[1] +')';
		var bgMoz = '-moz-linear-gradient(top, '+ color[0] +', '+ color[1] +')';
		var bgMs = '-ms-linear-gradient(top, '+ color[0] +', '+ color[1] +')';
		var bgOpera = '-o-linear-gradient(top, '+ color[0] +', '+ color[1] +')';
		
		$(this).css('background-image', bgWebkit);
		$(this).css('background-image', bgMoz);
		$(this).css('background-image', bgMs);
		$(this).css('background-image', bgOpera);

	});
	
	document.createElement("figure");
	document.createElement("figcaption");
	
	
	$(document).scroll(function() {
		if ($(document).scrollTop() > 60 && $('nav').css('position') == 'absolute') {
			$('nav').css({ top: '-50px', position: 'fixed', background: 'rgba(48,48,48,0.7)' }).animate({ top: '0px' });
		}
		else if ($(document).scrollTop() < 60) {
			$('nav').css({ position: 'absolute', background: 'rgb(48,48,48)' });
		}
	});
	
//	var expandBox = $(document).find(".expand-box");
//	jQuery.each(expandBox, function(i, e) {
//		var box = $(this);
//		$("<a class='expand' data-box='"+ i +"' href='#'><sup>"+ (i+1) +"</sup></a>").insertBefore($(this));
//		$('a.expand[data-box='+i+']').click(function() {
//			$(box).toggle( function() {
//				$(this).css({ 'display': 'inline-block' });
//			}, function() {
//				$(this).css({ 'display': 'none' });
//			});
//			
//			return false;
//		});
//	});
	
		$("nav").hover(function() {
			if ($('nav').css('position') == 'fixed') {
				$(this).css({ background: 'rgb(48,48,48)' });
			}
				}, function() {
					if ($('nav').css('position') == 'fixed') {
						$(this).css({ background: 'rgba(48,48,48,0.7)' });
					}
		});
		
	$(".search-field").bind('focus blur', function() {
		var cur = $(this).val();
		if (cur == 'Search...') {
			$(this).val('');		
		}
		else if (cur == '') {
			$(this).val('Search...');
		}
		else {
		// Do nothing
		}
	});
	$("#mailListText").bind('focus blur', function() {
		var cur = $(this).val();
		if (cur == 'Email Address') {
			$(this).val('');		
		}
		else if (cur == '') {
			$(this).val('Email Address');
		}
		else {
		// Do nothing
		}
	});
	
	
	var curPage = window.location.pathname;
	if (curPage == '/') {
		curPage = "/index.php";
	}
	curPage = curPage.replace('/','');
	
	$("nav").find('a[href$="'+curPage+'"]').addClass('activePage');
	
	console.log(curPage);
	
	
	/* END NAV */
	
	
	
	
	
});



















