/*----------Formulario de Contact ------------*/
function validateForm()
	{
		$("#phone").mask("999.999.9999");
		jQuery("#frmContact").validate({
			errorClass: "invalidField",
			validClass: "validField",
			rules: { 
				name: "required",
				phone: {required: true},
				email: {required: true, email: true},
				message:"required"
			},
			messages: {
				name: "",
				email: "",
				phone: "",
				message: ""
			},
		submitHandler: function() { sendFormContact(); }
		});
	}

function sendFormContact()
	{
		jQuery("#contactFormStage1").fadeTo("slow",0.2,function(){
				jQuery("#contactFormStage2").fadeIn("fast",
					function(){
						jQuery("#frmContact").attr("disabled","true");
						formData = jQuery("#frmContact").serialize();
						
						jQuery.ajax({
							type: "GET",
							url: "php/functions.php",
							data: "method=contact&"+formData,
							success: function(data){
								if(data > 0)
									{
										jQuery("#frmContact")[0].reset();
										alert("Thank you!. We have received your email.");
										jQuery("#contactFormStage2").fadeOut("slow",function(){
										jQuery("#contactFormStage1").fadeTo("slow",1,
											function(){
												jQuery("#btnContact").removeAttr("disabled");
												}
											);
										})
									}
								else
									{
										alert("Please try again");
										jQuery("#contactFormStage2").fadeOut("slow",function(){
										jQuery("#contactFormStage1").fadeTo("slow",10,
											function(){
												jQuery("#btnContact").removeAttr("disabled");
												}
											);
										})
									}							
							},
							 error: function (request, status, error) {
								 alert("Server Error. Please try again");
								}
						});
					}
				);
		});
	}
/*---Fin formulario Contact -----*/
function getGallery(gallery)
	{
		jQuery.ajax({
			type: "GET",
			url: "php/functions.php",
			data: "method=getGallery&gallery="+gallery,
			success: function(data){	
				if(data != 0)
					{
						jQuery("#gallery").html(data);
						enableGallery();
					}
				else
					alert("Server Error. Please try again");	
			},
			error: function (request, status, error) {
				 alert("Server Error. Please try again");
			}
		});
	}
	
function viewImage(url,ruta)
	{
		jQuery.ajax({
			type: "GET",
			url: "php/functions.php",
			data: "method=validFile&ruta="+ruta,
			success: function(data){	
				if(data > 0)
					document.getElementById('imgBig').src=url;
				else
					document.getElementById('imgBig').src='images/transparent.png';				
			},
			error: function (request, status, error) {
				 alert("Server Error. Please try again");
			}
		});		
	}

function enableGallery()
	{
		jQuery(document).ready(function() {
			//jQuery('#mycarousel').jcarousel({scroll: 7});
		});
	}

function changeVideo(op)
	{
		if(op == 1)
			{
				jQuery('#titVideo').html('TV Shows in the USA');
				jQuery('#contVideoRep').load('videos/usa_tv_shows.html');
			}
		else if(op == 2)
			{
				jQuery('#titVideo').html('TV Shows in Latin America');
				jQuery('#contVideoRep').load('videos/levantate.html');
			}
		else if(op == 3)
			{
				jQuery('#titVideo').html('Commercials');
				jQuery('#contVideoRep').load('videos/comercials.html');
			}	
	}

function viewImageTeaching(url,ruta)
	{
		jQuery.ajax({
			type: "GET",
			url: "php/functions.php",
			data: "method=validFileTeach&ruta="+ruta,
			success: function(data){	
				if(data > 0)
					document.getElementById('imgTeach').src=url;
				else
					document.getElementById('imgTeach').src='images/img_class_2.png';				
			},
			error: function (request, status, error) {
				 alert("Server Error. Please try again");
			}
		});		
	}
