$(document).ready(function(){
	
	$("form#sendAppAndroid").hide();		
	$("form#sendAppPalm").hide();		
	
	 $('a#linkAndroid').click(function() {
     $('form#sendAppAndroid').fadeIn(300);
	   $('form#sendAppPalm').fadeOut(200)
	 return false;
  });
	 
	  $('a.closeForm').click(function() {
     $('form#sendAppAndroid').fadeOut(300);
	  $('form#sendAppPalm').fadeOut(300);
	 return false;
  });
	     
	 
	 $('a#submit1').click(function() {
     $('form#sendAppAndroid').fadeOut(500);
	  $(this).remove();
	 return false;
  });
	
	$('a#linkPalm').click(function() {
     $('form#sendAppPalm').fadeIn(300);
	  $('form#sendAppAndroid').fadeOut(200)
	 return false;
  });
	 $('a#submit2').click(function() {
     $('form#sendAppPalm').fadeOut(500);
	 return false;
  }); 

 $('#sendEmail input').bind('keypress', function(e) {
     if(e.keyCode==13){
  	 popupform('http://m.yp.ca/sms/sms.php', 'sms');
	 return false;
    }
});
 
 $('#sendAppAndroid input').bind('keypress', function(e) {
     if(e.keyCode==13){
  	 $('form#sendAppAndroid').hide();
	 popupform('http://m.yp.ca/sms/sms.php', 'sms');
	 return false;
    }
});
 
 $('#sendAppPalm input').bind('keypress', function(e) {
     if(e.keyCode==13){
  	 $('form#sendAppPalm').hide();
	 popupform('http://m.yp.ca/sms/sms.php', 'sms');
	 return false;
    }
});

}); 

// Slider 
  function formatText(index, panel) {
		  return index + "";
	    }
    
        $(function () {
        
            $('.anythingSlider').anythingSlider({
                easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 5000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 600,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
        		startText: "Go",             // Start text
		        stopText: "Stop",               // Stop text
		        navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
            });
            
            $("#slide-jump").click(function(){
                $('.anythingSlider').anythingSlider(6);
            });
            
        });
		
// Switch lang

function switchMobileAppLanguage(){

   var loc = document.location.href;
   
   var frenchDomain = "http://mobile.pj.ca";
   var englishDomain = "http://mobile.yp.ca";
   
   if (document.location.href.indexOf("dev2.yp1.ca") > -1){
	   var frenchDomain = "http://mobile.pj.dev2.yp1.ca";
	   var englishDomain = "http://mobile.yp.dev2.yp1.ca";
   }
   
   if (document.location.href.indexOf("yellowpages.ca") > -1 || document.location.href.indexOf("pagesjaunes.ca") > -1){
	   var frenchDomain = "http://mobile.pagesjaunes.ca";
	   var englishDomain = "http://mobile.yellowpages.ca";
   }
   

   if (loc.indexOf(englishDomain ) > -1){
       loc = loc.replace(englishDomain , frenchDomain );
   } else {
       loc = loc.replace(frenchDomain , englishDomain );
   }

   document.location.href = loc;
}

