function getCookie(c_name){if (document.cookie.length>0)  {  c_start=document.cookie.indexOf(c_name + "=");  if (c_start!=-1)    {    c_start=c_start + c_name.length+1;    c_end=document.cookie.indexOf(";",c_start);    if (c_end==-1) c_end=document.cookie.length;    return unescape(document.cookie.substring(c_start,c_end));    }  }return "";}function setCookie(c_name,value,expiredays){var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());}/*  pick up the query set looking for web=true|false  */function querySt(ji) {var web = getCookie('mobile');if (web=="true"){	//alert("do not override '" + web + "'");	return web;}	else {	//alert("get URLString");	hu = window.location.search.substring(1);	gy = hu.split("&");	for (i=0;i<gy.length;i++) {		ft = gy[i].split("=");		if (ft[0] == ji) {			return ft[1];		}	}	}}function checkWebCookie() {var web = querySt("web");mobile=getCookie('mobile');if (web=="true")  {  //alert('web == '+web+'!');  setCookie('mobile','true',1);	//document.write(web + " cookie has been written <br/>");  }else if (web=="false")  {	setCookie('mobile','false',1);	//alert('web == '+web+'!');	attemptRedirect();  }  else {	//alert('not specified');	if (web!=null || web!="" || web!=="true") {		attemptRedirect();  	}	else {		//alert("no cookie or web = true. No redirect.");	}  }}function attemptRedirect() {	//document.write("Redirect test <br />");		//alert("Redirect Test");		if((navigator.userAgent.match(/iPhone/i)) || 			(navigator.userAgent.match(/iPod/i))) 			{ 			  //alert("Redirect to iphone");			location.replace("http://raq.org.au/mobile/iphone");		}		else if( (navigator.userAgent.match(/Nokia/i)) ||			(navigator.userAgent.match(/Android/i)) ||			(navigator.userAgent.match(/SonyEricsson/i)) ||			(navigator.userAgent.match(/Blackberry/i)) ||			(navigator.userAgent.match(/htc/i)) ||			(navigator.userAgent.match(/Mot/i)) ||			(navigator.userAgent.match(/Blazer/i)) 			) 			{ 			  //alert("Redirect to mobile");			location.replace("http://mobile.raq.org.au/");			}}
