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 isMobile(alias,itemLevel,itemID) {
	if (getCookie('fullscreen') == 'true') {
		return;	
	}
	if (getQuerystring('fullscreen') == 'true') {
		createCookie();
		return;
	}
	if ( navigator.userAgent.match ( /(android|blackberry|htc|ipaq|iphone|ipad|ipod|kindle|lg|midp|mmp|mobile|mot|nokia|o2|opera mini|palm|pocket|psp|sgh|smartphone|sonyericsson|symbian|treo mini|up.browser|up.link|vodafone|wap)/i) ) {
		location.replace('http://'+alias+'/'+itemLevel+'/'+itemID);
	}
}

function createCookie() {
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + 1);
	var c_value=escape('true') + "; expires="+exdate.toUTCString();
	document.cookie	= "fullscreen=" + c_value;
}
 
function getCookie(c_name) {
	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);
		}
	}
}
 

