  //
  // author: chris neglia 8/31/09 for page1solutions
  // Ajax query to ask, is this a mobile device?  expects 0 or 1
  // if 1 is returned (mobile detected), will rip off www and replace with m.
  // otherwise if 0 is returned does nothing.
  
  // -- Credit--
  // The code, "Detecting Smartphones Using PHP" 
  // by Anthony Hand, is licensed under a Creative Commons 
  // Attribution 3.0 United States License.
  //
var newlocation = '';
jQuery(function(){
  
  jQuery.ajax({
    type: "GET",
    url: "detect-mobile.php",
    dataType: "script",
    success:function(returned){
      if (returned==1) {
       if (window.location.host.substr(0,3) == 'www') {
          newlocation = 'http://m.' + window.location.host.substr(4) + window.location.pathname;
        }
        else {
          newlocation = 'http://m.' + window.location.host + window.location.pathname;
        }
        window.location = newlocation;
      }  
    }
  });
});