
/* 
 	To exclude a device from the mobile detector:

	Enter comma seperated list of strings to exclude from mobile filter (in all lower case)
	The exclusion string must appear in the device's UserAgent string
 
	Example, to exclude iPad & Android tablet:
  
	var MBLexclude=['ipad','android 3'];
*/

var MBLexclude=[];
var MBLi=false,MBLa=false,MBLmobile=false;
function MBLaddLoad(){
	if(!document.getElementById||typeof document.createElement=='undefined'){
		return;
	}
	if(window.addEventListener){
		document.addEventListener("DOMContentLoaded",initMBL,false);
	}
	else if(window.attachEvent){
		document.write("<script id=ie_MBL defer src=\"//:\"><\/script>");
		document.getElementById("ie_MBL").onreadystatechange=function(){
			if (this.readyState=="complete"){
				initMBL();
			}
		};
	}
}
MBLaddLoad();
function initMBL(){
	var mb;
	if(MBLi){
		return;
	}
	MBLi=true;
	mb=MBLisMobile();
	if(mb){
		MBLsetClass(document.getElementsByTagName('BODY')[0],'mobile');
		MBLmobile=true;
	}
	else{
		MBLsetClass(document.getElementsByTagName('BODY')[0],'desktop');
	}
}
function MBLsetClass(ob,cl){
	if(ob){
		var cc,nc,r=/\s+/g;
		cc=ob.className;
		nc=cl;
		if(cc&&cc.length>0){
			if(cc.indexOf(cl)==-1){
				nc=cc+' '+cl;
			}
			else{
				nc=cc;
			}
		}
		nc=nc.replace(r,' ');
		ob.className=nc;
	}
}
function MBLisMobile(){
	var i,m=false,ua=navigator.userAgent.toLowerCase();
	var dv=['iphone','ipad','ipod','android','windows ce','iemobile','windowsce','blackberry','palm','symbian','series60',
	'armv','arm7tdmi','opera mobi','opera mini','polaris','kindle','midp','mmp/','portalmmm','smm-mms','sonyericsson','zune'];
	for(i=0;i<dv.length;i++){
		if(ua.search(dv[i])>-1){
			m=dv[i];
			break;
		}
	}
	if(m&&MBLexclude.length){
		for(i=0;i<MBLexclude.length;i++){
			if(ua.search(MBLexclude[i])>-1){
				m=false;
			}
		}
	}
	return m;
}

