// JavaScript Document

	
	$(document).ready(function(){ 
		initCycleHome();
		initTwitterApi();
		initTwitterApiUser();
		
		
	


		//add animation			
		
		
		
	
		$(".box_slider").carouFredSel({
				prev: "#gallery_prev",
				next: "#gallery_next",					
				items       : 3,
				direction   : "left",
				circular    : true,
				infinite    : true,
				auto  : {
					play 	: true,
					items	: 1
				},
				scroll  : {
					items	: 1
				}
		});
		
		$(".colorbox").colorbox();	
		
		$('.view_gallery').click(function(){									 
		
			if($(this).next().children().length > 0)
			{
				$(this).next().children().colorbox();	
				$(this).next().find(":nth-child(1)").trigger('click'); 
			}
			return false;
		});
		
		$(".gallery-icon a").colorbox({rel:'group1'});
	
		
		$.preload([''], {
			base: TEMPLATE_URL + '/images/',
			ext:'.png'
		});
		
		/*
		$("#form_more").validate({
				rules: {
					captcha: {
						required: true,
						remote: "/wp-content/themes/andromeda_pedasi/ajaxform/includes/process.php"
					},
					email: {
						required: true,
						email: true
					}
				},
				messages: {
					captcha: "Correct captcha is required. Click the captcha to generate a new one",
					email: "Please enter a valid email address"				
				},
				submitHandler: function() {
					document.forms["form_more"].submit();
				},
				success: function(label) {
					//label.addClass("valid").text("Valid captcha!") 
				},
				onkeyup: false
		});
		
		*/
		

	});

	

	function initCycleHome(){
		/*Home - Slider*/
		$('#slides-home img:first').fadeIn(1000, function() {
			$('#slides-home').cycle({
				fx		:   'fade',		
				next	:   '#next',
				prev	:   '#prev',
				timeout	:	4000  
			});
		});
	}
	
	function _IsEmail(str)
	{
		if (typeof(str)=='undefined')
		{
			return false;
		}
		var expr1 = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
		if (!expr1.test(str)){
			return false;
		}
		return true;
	}

	function _IsNumber(str)
	{
		if (typeof(str)=='undefined')
		{
			return false;
		}
		if (str=='')
		{
			return false;
		}
		var expr1 = /^[\+\-]?[0-9]+(\.[0-9]{0,})?$/;
		var expr2 = /^[\+\-]?(\.[0-9]{0,})?$/;
		if (!expr1.test(str)){
			if (!expr2.test(str)){
				return false;
			}
		}
		return true;
	}
	
	
	/*-- Newsletter Mailchimp --*/
	function validateMailChimp(form){
	
		if(form.first_name.value=='' || form.first_name.value=='First Name')
		{
			alert("Please enter your First Name");
			form.first_name.focus();
			return false;
		}

		if(form.last_name.value=='' || form.first_name.value=='Last Name')
		{
			alert("Please enter your Last Name");
			form.last_name.focus();
			return false;
		}

		if(!_IsEmail(form.email.value))
		{				

			alert("Please enter a valid email address");
			form.email.focus();
			return false;
		}
		
		$("#sending_data").hide();
		$("#response").html('Sending Data...').show();
		$.ajax({
			url:"/wp-admin/admin-ajax.php",
			type:'POST',
			data:'action=send_email&type=mailchimp&email='+form.email.value+'&last_name='+form.last_name.value+'&first_name='+form.first_name.value,
			success: function(data){
				var datos = data.split('|');
				
				$("#sending_data").show();
				
				var info = datos[1].replace('-1','');
				var info = info.replace('0','');
				
				$("#response").html( info ).show();
				
			}	
		});	
		return false;
	}
	

	function trim (myString)
	{
		return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
	}

		
	function displaylightBox(id){
		$("#album_"+id).click();
	}
