// Build an empty URL structure in which we will store
// the individual query values by key.
var objURL = new Object();
var skipscript = 0
 
// Use the String::replace method to iterate over each
// name-value pair in the query string. Location.search
// gives us the query string (if it exists).
window.location.search.replace(
new RegExp( "([^?=&]+)(=([^&]*))?", "g" ),

// For each matched query string pair, add that
// pair to the URL struct using the pre-equals
// value as the key.
function( $0, $1, $2, $3 ){
objURL[ $1 ] = $3;
}
);

// Note:
// skipscript=0 -> for normal use
// skipscript=1 -> mobile user want to skip imode page and return to HTML page

// Loop over the URL values that we collected.
for (var strKey in objURL)
{
 if (strKey=="skipscript")
 {
	

      document.cookie = "skipscript=true;path = /" + "; expires=";
	  skipscript=objURL[strKey]; 
 }
}

var agt = navigator.userAgent.toLowerCase();
var is_mobile = ( (agt.indexOf("blacknerry") != -1) || (agt.indexOf("blackberry") != -1) || (agt.indexOf("nokia") != -1) || (agt.indexOf("webtv") != -1) || (agt.indexOf("windows ce") != -1) || (agt.indexOf("microsoft pocket internet explorer") != -1) || (agt.indexOf("up") != -1) || (agt.indexOf("smartphone") != -1) || (agt.indexOf("mobile") != -1) || (agt.indexOf("iphone") != -1) || (agt.indexOf("ipod") != -1) || (agt.indexOf("netfront") != -1) );
var imodeCookie = false;

var i,x,y,ARRcookies=document.cookie.split(";");

for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");

  if (x=="skipscript")
  {
   imodeCookie=true;
	i=ARRcookies.length;
    
  }
}

if(imodeCookie==false){
 if(is_mobile && (skipscript==0))
	{
		
		window.location.replace("http://imode.onemotoring.com.sg")
	}
	else
	{
		// for PC user
		// for mobile user want to see HTML page (skipscript=1)
	}
}
