$(document).ready(function(){
	$(document).pngFix();
	$('#navigation li').hover(
		function(){
			var ul = $(this).find('.sub:eq(0)');
			
			if(ul.length == 0) return;
			
			ul.show();
			$(this).find('a:eq(0)').addClass('active2');
		},
		function(e){
			$(this).find('.sub:eq(0)').hide();
			$(this).find('a:eq(0)').removeClass('active2');
		}
	);
	
	
	$('.forms input, .forms textarea')
		.focus(function(){ $(this).addClass('focus-field'); })
		.blur(function(){ $(this).removeClass('focus-field'); })
		
	
	/** SIFR **/	
	/*
	$.sifr({path:'js/fonts'});
	$('h1 .sifr').sifr({font: 'gotham-htf.swf'});
	*/
	
	$('#content a.img').hover(
		function(){ $(this).addClass('img-hover'); },
		function(){ $(this).removeClass('img-hover'); }
	);
	
	if( $.browser.safari ) {
		$('textarea').each(function(){ $(this).addClass('safari-textarea'); });
	}
	
	
});


var WEB_CATS = [ 'Website Design', 'Banner Design', 'Advertisement', 'Promotional Design', 'Newsletter Design', 'Web Maintenance', 'Flash Design', 'Icon Design'];
var PRINT_CATS = [ 'Identity / Logo Design', 'Publication Design', 'Stationery Design', 'Brochure Design', 'Postcard Design', 'Flyer Design', 'Business Card Design', 'Advertisement', 'Promotional Design', 'Invitation Design', 'Banner Design', 'Newsletter Design'];

function _set_cat( $cat ) {
	var cats = WEB_CATS;
	if( $cat == 'print' )
		cats = PRINT_CATS;
	
	var html = '<option value="">Choose one...</option>';
	for( var i in cats ) {
		html += '<option value="' + cats[i] + '">' + cats[i] + '</option>';
	}
	html += '<option value="Other">Other</option>';
	
	
	$('#project-type').html( html ).focus();
}



/** sIFR 3 **/
var gotham = { src: 'js/fonts/gotham-htf-new.swf' };
sIFR.activate(gotham);


sIFR.replace(gotham, { 
	selector: '.sifr',
	wmode: 'transparent',
	css: [
		'.sIFR-root { color: #646464; letter-spacing: -1 }',
		'a { text-decoration: none; }',
		'a:link { color: #46C5E3; }',
		'a:hover { color: #46C5E3; }'
	]
});

sIFR.replace(gotham, { 
	selector: '.sifr-blue',
	wmode: 'transparent',
	css: [
		'.sIFR-root { color: #46C5E3; letter-spacing: -1 }',
		'a { text-decoration: none; }',
		'a:link { color: #46C5E3; }',
		'a:hover { color: #46C5E3; }'
	]
});



/*** VALIDATE ***/

function validate_send_form( form_name ) {
	
	var fields = $('#' + form_name + ' .required');
	var has_error = false;
	
	fields.each(function(){
		has_error = false;
		
		
		var f = $(this);
				
		if( f.hasClass('valid-mail') ) {
			if( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(f.attr('value'))==false ) {
				alert('Please, enter valid email address.');
				f.focus();
				has_error = true;
				return false;
			}
		}
		
		if( f.attr('type').toLowerCase() == 'radio' ) {
			if ( $('input[name='+f.attr('name')+']:checked').length == 0 ) {
				alert('Please select ' + f.attr('name').replace('-', ' ') + '.');
				has_error = true;
				return false;
			}
		}
		
		if( f.attr('value') == '' ) {
			var label = $('label[for=' + f.attr('id') + ']');
			var msg = label.attr('title');
			if( label.attr('title') == '' ) {
				msg = 'Please enter your ' + label.html().replace(':', '').replace('*', '').toLowerCase() + '.';
			} else {
				msg = label.attr('title');
			}
			
			alert(msg);
			f.focus();
			has_error = true;
			return false;
		}
	});
	
	if( !has_error ) {
		$('#' + form_name).submit();
	}
	
}

