var indice_visible = -1;
var indice_visible_detail = -1;

function nuevoAjax(){
        var xmlhttp=false;
        try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
                try {
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }catch(E){
                        xmlhttp = false;
                }
        }       
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
}

function get_work_images(work_id) {
   	   c = $('.slider_wrap');

       ajax=nuevoAjax();

       c.html('Loading images... Please wait');
 
       ajax.open("GET", "php/get_work_images.php?work_id="+work_id,true);
       ajax.onreadystatechange=function() {
		   if (ajax.readyState==4) {
			   c.html(ajax.responseText);
				$("#images_count").html($(".slider_wrap ul li").length);

				if ($(".slider_wrap ul li").length == 1) {	
					$(".navigation").hide();
				} else {
					$(".navigation").show();
					$("li.next_btn").removeClass('disabled');
					$("li.prev_btn").addClass('disabled');
					indice_visible_detail = -1;
				}

		   }	
       }
       ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	   ajax.send();
}


function send_contact() {

	if (valida_form()) {   
       //variable=documenet.nombre_del_form.nombre_del_control.value
       emis=$('#edtMail').val();
       dest='acid.morph@gmail.com';
       men='Message from: ' + $('#edtName').val() + ': '+$('#edtMessage').val();
   	   c = $('#contact_wrap');

       ajax=nuevoAjax();

       c.html('Sending Message... Please wait');
 
       ajax.open("POST", "php/send_mail.php",true);
       ajax.onreadystatechange=function() {
       if (ajax.readyState==4) {
	       c.html(ajax.responseText);
       }	

//       borrarCampos()
       }
       ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
       ajax.send("destinatario="+dest+"&emisor="+emis+"&mensaje="+men);
	}
}

function valida_form() {
	if ($('#edtName').val() == '') 
	{
		$('#name_warning').hide();
		$('#name_warning').removeClass('hidden');
		$('#name_warning').show('normal');
		$('#edtName').addClass('warning');
		$('#edtName').focus();
		return (false);
	} else {
				$('#edtName').removeClass('warning');	
				$('#name_warning').hide('normal');
				if ($('#edtMail').val() == '') 
				{ 
					$('#email_warning').hide();
					$('#email_warning').removeClass('hidden');
					$('#email_warning').show('normal');
					$('#edtMail').addClass('warning');
					$('#edtMail').focus();
					return (false);
				} else {
							$('#edtMail').removeClass('warning');
							$('#email_warning').hide('normal');
							if ($('#edtMessage').val() == '') 
							{ 
								$('#msg_warning').hide();
								$('#msg_warning').removeClass('hidden');
								$('#msg_warning').show('normal');
								$('#edtMessage').addClass('warning');
								$('#edtMessage').focus();
								return (false);
							} else {
										$('#edtMail').removeClass('warning');
										$('#msg_warning').hide('normal');
										return(true);
									}
						}									
							
			}
}

