﻿function getCookie(c_name)
{
	//alert('one');
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==c_name)
    {
    return unescape(y);
    }
  }
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function checkCookie()
{
	//alert('one');
var useless=getQuerystring('v');
var username=getCookie("nomobile");
//alert('')
if (username!=null && username!="")
  {
	  //alert('one');
  	  //cekmobile_site();
  }
else 
  {
	 if(getQuerystring('v')=='nomobile')
 	{ 
		//alert("oke");
    	setCookie("nomobile","nomobile",1);

 	}else
	{
		//alert("oke");
		cekmobile_site();
	}
  }
}
function getQuerystring(key, default_)
{
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}
function cekmobile_site()
{
	 if((navigator.userAgent.toLowerCase().indexOf('blackberry')>=0))
	   {
	   
    	//alert(navigator.userAgent.toLowerCase().indexOf('blackberry'));
		//window.location = "http://m.haisobat.com/"
	   }else
	   {
 if((navigator.userAgent.toLowerCase().indexOf('safari')>=0) || (navigator.userAgent.toLowerCase().indexOf('mozilla')>=0)|| (navigator.userAgent.toLowerCase().indexOf('mozilla')>=0)|| (navigator.userAgent.toLowerCase().indexOf('ipad')>=0)|| (navigator.userAgent.toLowerCase().indexOf('android')>=0)|| (navigator.userAgent.toLowerCase().indexOf('iphone')>=0))
   {
   if((navigator.userAgent.toLowerCase().indexOf('gt-p1000')>=0)||(navigator.userAgent.toLowerCase().indexOf('ipad')>=0))
   {
  
   }else
   {
	   if((navigator.userAgent.toLowerCase().indexOf('blackberry')>0)||(navigator.userAgent.toLowerCase().indexOf('mobile')>0))
	   {
	   
    	//alert(navigator.userAgent.toLowerCase().indexOf('blackberry'));
		//window.location = "http://m.haisobat.com/"
	   }
	}
   }else
   {
	   
	   //document.write(navigator.userAgent);
	   //window.location = "http://m.haisobat.com/"
   }
   }
}

checkCookie();

