if(typeof wz_mobilesiteURL == "undefined") {
	var wz_fullDomain =  location.host.toLowerCase();
	if (wz_fullDomain.substr(0,4)=="www.") wz_fullDomain = wz_fullDomain.substr(4);
	var wz_mobilesiteURL = "http://m."+wz_fullDomain;
}

var wz_navigator_string = navigator.userAgent||navigator.vendor||window.opera;

function wz_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());
}

function wz_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 wz_DetectMobile(n,r)
{
	r = new RegExp("(^alcatel.*$)|(^audiovox.*$)|(^.*android$)|(^1.*$)|(^.*android$)|" +
	"(^0.*$)|(^benq.*$)|(^.*blackberry.*$)|(^cdm-.*$)|(^docomo.*$)|(^.*ericsson.*$)|(^.*ezwap.*$)|" +
	"(^go.web/.*$)|(^htc.*$)|(^.*; htc.*$)|(^.*kddi-.*$)|(^lg.*$)|(^lg-.*$)|(^lge-.*$)|(^.*midp-2.0.*$)|(^mitsu/.*$)|" +
	"(^.*mmp/2.0.*$)|(^.*mobileexplorer.*$)|(^mot-.*$)|(^nec-.*$)|(^.*nokia.*$)|(^.*opera$)|(^mini.*$)|" +
	"(^.*opera$)|(^mob.*$)|(^.*palmsource.*$)|(^panasonic.*$)|(^philips.*$)|(^portalmmm.*$)|(^.*rim$)|" +
	"(^handheld.*$)|(^.*rim$)|(^pager.*$)|(^sagem-.*$)|(^samsung-.*$)|(^sanyo-.*$)|(^sec-s.*$)|(^sie-.*$)|" +
	"(^sharp.*$)|(^.*symbianos.*$)|(^.*symbian$)|(^os.*$)|(^.*up.browser.*$)|(^.*up.link.*$)|(^up/4..*$)|" +
	"(^.*windows$)|(^ce.*$)|(^.*iphone.*$)|(^.*ipod.*$)|(^.*nintendo$)|(^wii.*$)|(^.*playstation$)|(^.*opera mini.*$)|" +
	"(^portable.*$)|(^.*playstation$)|(^3.*$)|(^.*android.*$)","i");
	
	//return true;
	return r.test(wz_navigator_string.substr(0,30));
}

function wz_HandleMobile()
{
	if (wz_getCookie("wz_smobile")=="")
	{
		wz_setCookie("wz_smobile","T");
		if (!wz_getCookie("wz_smobile")=="T") return;
	}
	if (document.referrer && document.referrer.indexOf(wz_mobilesiteURL)==0)
	{
		wz_setCookie("wz_stayonfull", "Y", 1);
	}
	else if (wz_getCookie("wz_stayonfull")!="Y")
	{
		window.stop();
		var s = location.search;
		if (s.search("fuseaction=car")>-1)
			wz_mobilesiteURL+='/usedcars/'+s;
		location = wz_mobilesiteURL;
	}
}

if (wz_DetectMobile()) wz_HandleMobile();

