$(document).ready(function(){
	$(".client-logo").mouseover(function(){
		var src = $(this).attr("src");
		$(this).attr("src",src.substring(0,src.indexOf(".jpg"))+"h.jpg");
	});
	$(".client-logo").mouseout(function(){
		var src = $(this).attr("src");
		$(this).attr("src",src.substring(0,src.indexOf("h.jpg"))+".jpg");
	});
	
	$(".menu-item").mouseover(function(){
		var src = $(this).attr("src");
		$(this).attr("src",src.substring(0,src.indexOf(".jpg"))+"h.jpg");
	});
	$(".menu-item").mouseout(function(){
		var src = $(this).attr("src");
		$(this).attr("src",src.substring(0,src.indexOf("h.jpg"))+".jpg");
	});
});

function sendForm(){
	$('#form').hide();
	$('#overlay').show();
	if($('#name').val()&&$('#email').val()&&$('#msg').val()){
		$.ajax({
			type: "POST",
			url: "form.php",
			data: "name="+$('#name').val()+"&email="+$('#email').val()+"&phone="+$('#phone').val()+"&msg="+$('#msg').val(),
			success: function(msg){
				if (!msg) {
					$('#overlay').html('<p>Gracias por contactarnos.<br/>En la brevedad le responderemos su consulta.</p>')
				}
				else {
					var errors = msg.split(',');
					for($i=0;$i<errors.length;$i++){
						switch(errors[$i]){
							case 'invalidemail':
								$('#email').removeClass('noerror');
								$('#email').addClass('error');
							break;
							case 'email':
								$('#email').removeClass('noerror');
								$('#email').addClass('error');
							break;
							case 'name':
								$('#name').removeClass('noerror');
								$('#name').addClass('error');
							break;
							case 'msg':
								$('#msg').removeClass('noerror');
								$('#msg').addClass('error');
							break;
						}
					}
					$('#overlay').hide();
					$('#form').show();
				}
			}
		});
	}
	else {
		if(!$('#email').val()){
			$('#email').removeClass('noerror');
			$('#email').addClass('error');
		} else {
			$('#email').addClass('noerror');
			$('#email').removeClass('error');
		}
		if(!$('#name').val()){
			$('#name').removeClass('noerror');
			$('#name').addClass('error');
		} else {
			$('#name').addClass('noerror');
			$('#name').removeClass('error');
		}
		if(!$('#msg').val()){
			$('#msg').removeClass('noerror');
			$('#msg').addClass('error');
		} else {
			$('#msg').addClass('noerror');
			$('#msg').removeClass('error');
		}
		$('#overlay').hide();
		$('#form').show();
	}
}

$(document).ready(function(){
  $('#client-site-link').click(function() {
      nextSite($('#client-site-link').attr('href'));
  });
  $('#client-site-backlink').click(function() {
      nextSite($('#client-site-backlink').attr('href'));
  });
  if($(location).attr('hash')!=""){
    nextSite($(location).attr('hash'));
  }
});

function preload(arrayOfImages) {
  $(arrayOfImages).each(function(){
    $('<img/>')[0].src = this;
  });
}
function nextSite(anchor){

preload([
    'images/givelocally.jpg',
    'images/meribel.jpg',
    'images/afm.jpg',
    'images/irl.jpg',
    'images/letsgo.jpg',
    'images/delcaropreso.jpg',
    'images/credicoop.jpg'
]);

  
  switch(anchor){
    case '#givelocally': //GiveLocally LLC
      $('#client-id').val('2');
      $('#client-name').fadeOut(400,function(){
	$('#client-name').text("Give Locally");
        $('#client-name').fadeIn(100);}
      );
      $('#client-site-description').fadeOut(400,function(){
	$('#client-site-description').text("Front-end design slicing and coding. \
	Cross-browser HTML/CSS coding. \
	Back-end functions.");
        $('#client-site-description').fadeIn(100);}
      );
      $('#client-site-technologies').fadeOut(400,function(){
	$('#client-site-technologies').text("PHP5, MySQL, HTML, CSS, JS");
        $('#client-site-technologies').fadeIn(100);}
      );
      $('#client-img').fadeOut(400,function(){
	$('#client-img').attr('src','images/givelocally.jpg');
	$('#client-img').attr('alt','Give Locally');
        $('#client-img').fadeIn(100);}
      );
      $('#client-site-url').attr('href','http://www.givelocally.net');
      setTimeout("$('#client-site-link').attr('href','#meribel')",1);
      setTimeout("$('#client-site-backlink').attr('href','#credicoop')",1);
   break;
    case '#meribel': //Meribel
      $('#client-id').val('3');
      $('#client-name').fadeOut(400,function(){
	$('#client-name').text("Meribel");
        $('#client-name').fadeIn(100);}
      );
      $('#client-site-description').fadeOut(400,function(){
	$('#client-site-description').text("Extensive fixes from a previous development to release the final site. \
	New administration panels for different functions of the site.\
	Translations between english and russian.");
        $('#client-site-description').fadeIn(100);}
      );
      $('#client-site-technologies').fadeOut(400,function(){
	$('#client-site-technologies').text("PHP5, Symfony, Doctrine, MySQL, HTML, CSS, JS");
        $('#client-site-technologies').fadeIn(100);}
      );
      $('#client-img').fadeOut(400,function(){
	$('#client-img').attr('src','images/meribel.jpg');
	$('#client-img').attr('alt','Meribel');
        $('#client-img').fadeIn(100);}
      );
      $('#client-site-url').attr('href','http://www.meribel-import.com');
      setTimeout("$('#client-site-link').attr('href','#afm')",1);
      setTimeout("$('#client-site-backlink').attr('href','#givelocally')",1);
   break;
    case '#afm'://AFM
      $('#client-id').val('4');
      $('#client-name').fadeOut(400,function(){
	$('#client-name').text("Advanced Financial Markets");
        $('#client-name').fadeIn(100);}
      );
      $('#client-site-description').fadeOut(400,function(){
	$('#client-site-description').text("Development of the user administration panel.\
	Refferal system to increase investors.\
	Developed with Java: JSP.");
        $('#client-site-description').fadeIn(100);}
      );
      $('#client-site-technologies').fadeOut(400,function(){
	$('#client-site-technologies').text("Java, JSP, MySQL, HTML, CSS, JS");
        $('#client-site-technologies').fadeIn(100);}
      );
      $('#client-img').fadeOut(400,function(){
	$('#client-img').attr('src','images/afm.jpg');
	$('#client-img').attr('alt','Advanced Financial Markets');
        $('#client-img').fadeIn(100);}
      );
      $('#client-site-url').attr('href','http://www.afmfxespanol.com');
      setTimeout("$('#client-site-link').attr('href','#irl')",1);
      setTimeout("$('#client-site-backlink').attr('href','#meribel')",1);
   break;
   case '#irl'://IRL
     $('#client-id').val('5');
      $('#client-name').fadeOut(400,function(){
	$('#client-name').text("iPhone Racing Live");
        $('#client-name').fadeIn(100);}
      );
      $('#client-site-description').fadeOut(400,function(){
	$('#client-site-description').text("Analysis, design, and development of the site.\
	Automatic scripts to play the game with a robot.\
	Web interface for the iPhone/iPod game.");
        $('#client-site-description').fadeIn(100);}
      );
      $('#client-site-technologies').fadeOut(400,function(){
	$('#client-site-technologies').text("PHP5, Symfony, Propel, MySQL, xHTML, CSS, JS");
        $('#client-site-technologies').fadeIn(100);}
      );
      $('#client-img').fadeOut(400,function(){
	$('#client-img').attr('src','images/irl.jpg');
	$('#client-img').attr('alt','iPhone Racing Live');
        $('#client-img').fadeIn(100);}
      );
      $('#client-site-url').attr('href','http://iphoneracinglive.com');
      setTimeout("$('#client-site-link').attr('href','#letsgo')",1);
      setTimeout("$('#client-site-backlink').attr('href','#afm')",1);
   break;
   case '#letsgo'://Let'sGo
     $('#client-id').val('6');
      $('#client-name').fadeOut(400,function(){
	$('#client-name').text("Let's Go Viajes - Travel Agency");
        $('#client-name').fadeIn(100);}
      );
      $('#client-site-description').fadeOut(400,function(){
	$('#client-site-description').text("Analysis, design, and development of the site.\
	Administration panel to update site and generate newsletters.");
        $('#client-site-description').fadeIn(100);}
      );
      $('#client-site-technologies').fadeOut(400,function(){
	$('#client-site-technologies').text("PHP5, MySQL, xHTML, CSS, PHP GD Library, JS");
        $('#client-site-technologies').fadeIn(100);}
      );
      $('#client-img').fadeOut(400,function(){
	$('#client-img').attr('src','images/letsgo.jpg');
	$('#client-img').attr('alt','Let\'s Go Viajes');
        $('#client-img').fadeIn(100);}
      );
      $('#client-site-url').attr('href','http://letsgoviajes.com');
      setTimeout("$('#client-site-link').attr('href','#delcaropreso')",1);
      setTimeout("$('#client-site-backlink').attr('href','#irl')",1);
   break;
   case '#delcaropreso'://DelCaropreso
     $('#client-id').val('7');
      $('#client-name').fadeOut(400,function(){
	$('#client-name').text("DelCaropreso English Bulldog Breeder");
        $('#client-name').fadeIn(100);}
      );
      $('#client-site-description').fadeOut(400,function(){
	$('#client-site-description').text("Analysis, design, and development of the site.\
	Administration panel to update site.");
        $('#client-site-description').fadeIn(100);}
      );
      $('#client-site-technologies').fadeOut(400,function(){
	$('#client-site-technologies').text("PHP5, Symfony, Doctrine, MySQL, xHTML, CSS, JS");
        $('#client-site-technologies').fadeIn(100);}
      );
      $('#client-img').fadeOut(400,function(){
	$('#client-img').attr('src','images/delcaropreso.jpg');
	$('#client-img').attr('alt','DelCaropreso');
        $('#client-img').fadeIn(100);}
      );
      $('#client-site-url').attr('href','http://www.bulldogdelcaropreso.com');
      setTimeout("$('#client-site-link').attr('href','#credicoop')",1);
      setTimeout("$('#client-site-backlink').attr('href','#letsgo')",1);
   break;
   case '#credicoop'://Credicoop
   default:
     $('#client-id').val('1');
      $('#client-name').fadeOut(400,function(){
	$('#client-name').text("Banco Credicoop");
        $('#client-name').fadeIn(100);}
      );
      $('#client-site-description').fadeOut(400,function(){
	$('#client-site-description').text("Development of the site for mobile phone platforms (WAP).\
	Tested with many WAP emulators and real phones.");
        $('#client-site-description').fadeIn(100);}
      );
      $('#client-site-technologies').fadeOut(400,function(){
	$('#client-site-technologies').text("Java, JSP, Struts, WML:Struts, Hibernate, Oracle 10g, JUnit");
        $('#client-site-technologies').fadeIn(100);}
      );
      $('#client-img').fadeOut(400,function(){
	$('#client-img').attr('src','images/credicoop.jpg');
	$('#client-img').attr('alt','Banco Credicoop');
        $('#client-img').fadeIn(100);}
      );
      $('#client-site-url').attr('href','http://wap.bancocredicoop.coop');
      setTimeout("$('#client-site-link').attr('href','#givelocally')",1);
      setTimeout("$('#client-site-backlink').attr('href','#delcaropreso')",1);
   break;
  }
}

