$(document).ready(function(){
/*			var video = $('#other')[0];
			var video_other = $('#entier')[0];
			var canPlay = !!document.createElement('video').canPlayType;
*/

var canPlay  = false;
			
			$(".show_cvupload").click(function(){
					$("#login_panel").hide("fade",300,function(){
						$("#info").hide("fade",300,function(){
							$("#contact").hide("fade",300,function(){												
								$("#upload_cv").show("fade",300);									   
							});									
						});										   
					});		
				return false;
											   
			});


			$(".watch_video").click(function(){
					$(".video_panel").hide("fade",200,function(){
						$("#overlayer").show("fade",200,function(){
							$("#video_1").show("fade",200,function(){
								if (canPlay) {
									video.pause();
									video_other.play();
								}
							});										 
						});										   
					});
				return false;
			}).mouseover(function(){
					$("#video_desc").html("Watch : Time to re-invent consulting?");
			}).mouseout(function(){
					$("#video_desc").html("Watch our videos to find out what makes Entier different...");		
			});	
			
			$("a[rel=1]").click(function(){
				if (canPlay) {
					video.pause();
				}
			});
			
			$(".watch_entier").click(function(){	
				$(".video_panel").hide("fade",200,function(){
					$("#overlayer").show("fade",200,function(){
						$("#video_2").show("fade",200,function(){
							if (canPlay) {
								video_other.pause();
								video.play();
							}									   
						});										 
					});										   
				});
			return false;
			}).mouseover(function(){
						$("#video_desc").html("Watch : Entier Values.");
			}).mouseout(function(){
						$("#video_desc").html("Watch our videos to find out what makes Entier different...");		
			});	
			
			$(".show_login").click(function(){
				if ($(this).hasClass('show')) {
					$(this).removeClass('show');
					$(this).addClass('hide');
					$(this).parent().parent().find(".icon").attr('src','imgs/cross.png');
					$(this).html('Close Login');
					$("#info").hide("fade",300);
					$("#upload_cv").hide("fade",300,function(){
						$("#contact").hide("fade",300,function(){	
							$("#login_panel").show("fade",300);										   
						});
					});
				} else {
					$(this).removeClass('hide');
					$(this).addClass('show');
					$(this).parent().parent().find(".icon").attr('src','imgs/lock.png');
					$(this).html('Associate Login');
					$("#login_panel").hide("fade",300);
					$("#upload_cv").hide("fade",300,function(){
						$("#contact").hide("fade",300,function(){					
							$("#info").show("fade",300);									   
						});
					});
					}
			});
			
			$(".contact").click(function(){
				$("#login_panel").hide("fade",300);
				$("#upload_cv").hide("fade",300,function(){
					$("#info").hide("fade",300,function(){
						$("#contact").show("fade",300);								
					});										 
				});
				
				return false;
			});
			
			$("input[value=Send]").click(function(){
				var n = $("input[name=name]");
				var e = $("input[name=email]");
				var msg = $("textarea[name=msg]");
				
				$.ajax({
						url: '/default.asp',
						data : {'m' : 'send_msg','n' : n.val(),'msg' : msg.val(),'e' : e.val()},
						success: function(data) {
							n.val('');
							e.val('');
							msg.val('');
							$("#contact").html('<strong>Message sent, one of our staff will be in touch shortly.</strong>');
						},
						error: function(data) {
							alert("error message not send.")	;
						}
					});					 
			});	
			
			function closevids() {
				if (canPlay) {
					video.pause();
					video_other.pause();
				}
				$("#overlayer").fadeOut();
				$("#video_1").fadeOut();
				$("#video_2").fadeOut();
				}
					
			$("#overlayer,.close_videos").click(function(){
					closevids();
					return false;
			});
			
			// for IE compatability
			if (canPlay) {
			  if (!video.addEventListener) {
				  video.attachEvent("ended", function() {												  
					  closevids();
				  });
			  }
			  else {
				  video.addEventListener('ended', function() {												  
					  closevids();
				  });
			  }
			  
			}
			
		$(".greyed").click(function(){
			if ($(this).hasClass("greyed")) {
				$(this).val('');
				$(this).removeClass('greyed');
			}							
		});

		});
