
var FValidateControl = function (control) {
  if (control.value==""){
    control.focus();
    return false;
  }
  return true; 
}
 
var FSubmitValidation = function (talk)
{
  fm = document.getElementById(talk);
  if (!FValidateControl(fm.quote)) return;
  if (!FValidateControl(fm.hiname)) return;
  if (!FValidateControl(fm.hiemail)) return;
 
  fm.submit();
}
 	
	var togcon = function() {
		if ($("#contactForm").is(":hidden")){
			$("#contactForm").slideDown("slow").animate({opacity: "0.9"}, "slow");
			$("#backgroundPopup").css({"opacity": "0.7"});
			$("#backgroundPopup").fadeIn("slow"); 
		}
		else{
			$("#contactForm").animate({opacity: "0.19"}, "slow").slideUp("slow");
			$("#backgroundPopup").fadeOut("slow");  
		}
	};
	
	$(document).ready(
		function()
		{
                var d=300;
                $('#navigation a').each(function(){
                    $(this).stop().animate({
                        'marginTop':'-80px'
                    },d+=150);
                });
 
                $('#navigation > li').hover(
					function () {
						$('a',$(this)).stop().animate({
							'marginTop':'-2px'
						},200);
					},
					function () {
						$('a',$(this)).stop().animate({
							'marginTop':'-80px'
						},200);
					}
				);
 
 
				$('#coform').bind('click', togcon); 
                $('#mysubmit').bind('click', function(){FSubmitValidation('talk'); return false;});               
							  


				var myFile = document.location.toString();
				if (myFile.match('#')) { 				  
				  var myAnchor = myFile.split('#')[1];				  
				  if (myAnchor === 'noemailsent'){					 
                                       $.showMessage("hey stop that mmmkay?");
				  } else if (myAnchor === 'thx'){
                                      $.showMessage("Thanks!");
                                    }
				}



 
            $('#nav > div').hover(
                function () {
                    var $this = $(this);
					var $img = $this.find('img').not('#notrs');
					var wh = $img[0].alt;
					
                    $img.stop().animate({
                        'width'     : wh+'px',
                        'height'    : wh+'px',
                        'top'       :'-25px',
                        'left'      :'-25px',
                        'opacity'   :'0.88'
                    },wh*3,'swing',function(){
                        $(this).parent().find('ul').fadeIn(555);
                    });

                    $this.find('a:first,h2').addClass('active');
                },
                function () {
                    var $this = $(this);
					var $img = $this.find('img').not('#notrs');
					var wh = $img[0].alt;
                    $this.find('ul').fadeOut(500);
                    $img.stop().animate({
                        'width'     :'52px',
                        'height'    :'52px',
                        'top'       :'0px',
                        'left'      :'0px',
                        'opacity'   :'0.25'
                    }, wh*40 );

                    $this.find('a:first,h2').removeClass('active');
                }
            );
			
            $('#imh').mouseenter(
                function () {
                    $('.m2').stop().fadeIn(700);					                   
                }
            ); 
			
            $('#wso').mouseenter(
                function () {
                    $('.m3').stop().fadeIn(1100);					                   
                }
            );  
			 
			$('#showskype').click(function(){
				$('#page_bubb').animate({'left':10,'top':-340},1400,'easeInCirc').delay(7000).animate({'left':10,'top':-321},1000,'easeInCirc');
				$('#page_skype').animate({'left':-500,'top':20},1000,'easeInCirc').delay(300).animate({'left':100,'top':20},1000,'easeInCirc').effect('shake', { times: 2 }, 1000);
			});
			$('#closeskype').click(function(){
				$('#page_bubb').animate({'left':10,'top':-322},1400,'easeInCirc').delay(500).animate({'left':10,'top':1},1000,'easeInCirc').effect('bounce', { times: 3 }, 1000);
				$('#page_skype').animate({'left':-500,'top':20},1000,'easeInCirc').delay(300).animate({'left':-501,'top':20},1000,'easeInCirc');
			}); 
 
 
						 		  
							  
							  
				$("#roll_sky_2").width(0.98 * $(window).width()).css( 'marginLeft', 0 );
 
 				var skymover = function (  ) {				
					var that = {};
					that.hseq = 0;
                    that.prev = -200;
 
 
					that.start = function(q){
					    setTimeout(function() { that.move(q); }, 2500, this);						
					};
					
					that.move = function ( p ) {
						$("#roll_sky_2").animate({ marginLeft: p }, 22000, function() {
							that.hseq++;                                                     
							  
							if (p<0){ that.prev = p; p = 1;  }else{ p=that.prev;} 
                                                        
							if (that.hseq < 22){  
								that.move(p);
							}
						});								
					};
					return that;
				
				}(  ).start(-160);
 
 

 
		}
	);
