jQuery.noConflict();
(function($) { 
	$(function() {
		$(document).ready(function(){
			var cookie = $.cookie("redirect");
			if($.cookie("redirect")){
				var header = '<div style="z-index:1006;width:100%;height:80px;position:absolute;background:#fff;box-shadow: 0 4px 4px -2px #444;-moz-box-shadow: 0 4px 4px -2px #444;-webkit-box-shadow: 0 4px 4px -2px #444;">'
					+'<div style="margin:0px auto;width:320px;text-align:center;font-size:42px;padding:15px 0px 0px 0px;"><a class="mobileRedirect" href="http://m.carpathia.com/">Back to Mobile</a></div>'
				+'</div>';
				
				$("body").prepend(header);
				
				$("a.mobileRedirect").click(function(){
					$.cookie( "redirect", false ,{ path: '/', domain: '.carpathia.com',expires: 1 });
				});
				
			}else{
			
				var deviceIphone = "iphone";
				var deviceIpod = "ipod";
				
				//Initialize our user agent string to lower case.
				var uagent = navigator.userAgent.toLowerCase();
				
				//**************************
				// Detects if the current device is an iPhone.
				function DetectIphone()
				{
				   if (uagent.search(deviceIphone) > -1)
				      return true;
				   else
				      return false;
				}
				
				//**************************
				// Detects if the current device is an iPod Touch.
				function DetectIpod()
				{
				   if (uagent.search(deviceIpod) > -1)
				      return true;
				   else
				      return false;
				}
				
				
				    if (DetectIphone()){
				       window.location="http://m.carpathia.com";
				}
				    else if (DetectIpod()){
				       window.location="http://m.carpathia.com";
				}
				
				var deviceAndroid = "android";
				
				function DetectAndroid()
				{
				   if (uagent.search(deviceAndroid) > -1)
				      return true;
				   else
				      return false;
				}
				
				if (DetectAndroid())
				{
				window.location="http://m.carpathia.com";
				
				}
				
				
				var deviceWinMob = "windows ce";
				
				function DetectWindowsMobile()
				{
				   if (uagent.search(deviceWinMob) > -1)
				      return true;
				   else
				      return false;
				}
				
				
				if (DetectWindowsMobile())
				{
				window.location="http://m.carpathia.com";
				
				}
				
				
				var deviceBB = "blackberry";
				
				function DetectBlackBerry()
				{
				   if (uagent.search(deviceBB) > -1)
				      return true;
				   else
				      return false;
				}
				
				
				if (DetectBlackBerry())
				{
				window.location="http://m.carpathia.com";
				
				}
				
				
				var devicePalm = "palm";
				
				function DetectPalmOS()
				{
				   if (uagent.search(devicePalm) > -1)
				      return true;
				   else
				      return false;
				}
				
				if (DetectPalmOS())
				{
				window.location="http://m.carpathia.com";
				
				}
			
			
			}


	     });
	});
})(jQuery);


