/* ======================== Weiche SCRIPT ============================ */
/* Mobile User Agent JavaScript Weiche für www.skrapid.at
Benedikt Dell'mour
IQ mobile 2010 */


// Define User Agent
var user_agent=navigator.userAgent;

// Define Mobi Location
web_loc = "http://www.iq-mobile.at"; 
mobi_loc ="http://www.iq-mobile.mobi";

// Define Referer
referer = document.referrer; 

// Clear Device Variable
device = "";

function eregi(needle,haystack)
{
    haystack=haystack.toLowerCase();
    needle=needle.toLowerCase();
    Ergebnis=haystack.search(needle);
    if(Ergebnis != -1)
    {
        return true;
    }
    else return false;
}


// Check if the User Agent contains defined words
if(eregi("Windows CE",user_agent)){device = "mobile";}
if(eregi("Blazer",user_agent)){device = "mobile";}
if(eregi("Palm",user_agent)){device = "mobile";}
if(eregi("BlackBerry",user_agent)){device = "mobile";}
if(eregi("SonyEricsson",user_agent)){device = "mobile";}
if(eregi("Smartphone",user_agent)){device = "mobile";}
if(eregi("Nokia",user_agent)){device = "mobile";}
if(eregi("Symbian",user_agent)){device = "mobile";}
if(eregi("MMP",user_agent)){device = "mobile";}
if(eregi("RIM",user_agent)){device = "mobile";}
if(eregi("Netfront",user_agent)){device = "mobile";}
if(eregi("WAP",user_agent)){device = "mobile";}
if(eregi("Samsung",user_agent)){device = "mobile";}
if(eregi("AvantGo",user_agent)){device = "mobile";}
if(eregi("Jbrowser",user_agent)){device = "mobile";}
if(eregi("Mitsu",user_agent)){device = "mobile";}
if(eregi("T-Mobile",user_agent)){device = "mobile";}
if(eregi("iPhone",user_agent)){device = "mobile";}

// to stay on the current version if coming from the mobi site
if (eregi (mobi_loc,referer) ) {device = '';}

// Checks if the device is a "mobile" device and changes to the Mobi Site
if (device == 'mobile') { document.location.href=mobi_loc;}

/* ==================== Weiche SCRIPT Ende ======================= */
