﻿Cufon.replace('.contentNav, .leftNavContainer span, .contactWrapper p', { fontFamily: 'Gotham Light', hover: true });
Cufon.replace('h2, .newsWrapper h4, .contactWrapper h4', { fontFamily: 'Gotham Book', hover: true });
Cufon.replace('.footerNav', { fontFamily: 'OceanSans Book', hover: true });
Cufon.replace('.navigation', { fontFamily: 'Gotham Medium', hover: true, textShadow: '#514a3c 2px 1px' });



$(function(){
	$(".mFields").live('click',function(){   
		if($(this).val() == $(this).attr('title')){   
			$(this).val("");
		}
	});
		 
	$('.mFields').blur(function(){
		if($(this).val() == ""){
			$(this).val($(this).attr('title'));
		}
	});
		
	$('.date-pick').datePicker({clickInput:true});
	
	$(".time-pick").timePicker({
		clickInput:true,
		startTime:'09:00',
		step: 15,
		endTime: new Date(0, 0, 0, 20, 45, 0)
	});
		
	$('.navigation li').last().addClass('degree360');
		
	$(".colorbox").colorbox();
	
	//Form Validaton Check
	$('form').live('submit', function(){
		var errors;
		var myElem;
		
		$(this).find('.required').each(function(){
			if(jQuery.trim($(this).val()).length == 0){
				$(this).addClass('error');
				errors = true;
			}else{
				if($(this).attr('title') != $(this).val()){
					$(this).removeClass('error');
					
					if($(this).attr('type') == 'checkbox'){
						if(!$(this).is(':checked')){
							errors = true;
							$(this).addClass('error');
						}
					}
					
					if($(this).hasClass('emailField')){
						var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
						if(reg.test($(this).val()) == false){
							errors = true;
							$(this).addClass('error');
						}
						}
				}else{
					errors = true;
					$(this).addClass('error');
				}
				
				if(errors != true){
					errors = false;
				}else{
					errors = true;
				}
			}
			
		});
			
		formName = $(this).attr('id');
		if(!errors){
			$('#'+formName+' .errorContainer').fadeOut();
			$('#'+formName+' .loadingForm').fadeIn();
			formSubmitUrl = $(this).attr('action');
			form = $(this);
			$.ajax({
				type: "POST",
				url: formSubmitUrl,
				data: $(this).serialize(),
				success: function(data){
					if(data == true)
						$('#'+formName+' .loadingForm, #'+formName+' .errorContainer').fadeOut('fast', function(){$('#'+formName+' .successForm').fadeIn('fast', function(){ $('#'+formName+' .formContainer').slideUp(); }); });
					else
						$('#'+formName+' .loadingForm').fadeOut('fast', function(){$('#'+formName+' .errorContainer').fadeIn(); });
				}
			});
			return false;
		
		}else{
			$('#'+formName+' .errorContainer').fadeIn();
		}
		
		return false;
	});
	
	//Form Only Allowed Letters Validate
	$("#firstName, #lastName").live('keypress', function(e){ return alpha(e,letters); }); //Type id's or some simple class  (onlyLetters) that will allow only letters.
	$("#phone").live('keypress', function(e){ return alpha(e,numbers); }); //Type id's or some simple class (onlyNumbers) that will allow only numbers.
});

//Contact Input Filters
var letters=' ABCÇDEFGĞHİIJKLMNOÖPQRSŞTUÜVWXYZabcçdefgğhıijklmnöopqrsştüuvwxyz'
var numbers='1234567890'
var signs=',.:;@-\''
var mathsigns='+-=()*/'
var custom='<>#$%&?¿'

function alpha(e,allow) {
	var unicode=e.charCode? e.charCode : e.keyCode;
	if(unicode!="9"){
		if(unicode != "8"){
			var k;
			k=document.all?parseInt(e.keyCode): parseInt(e.which);
			return (allow.indexOf(String.fromCharCode(k))!=-1);
		}
	}
}
