var base_url = location.protocol+"//"+location.host+"/";
var site_url = base_url;
var accountname = false;
var segs = false;
var usingDomain = true;
var is_mobile = false;
var ajax_available = true;
processSiteUrl();

function processSiteUrl()
{
	//get segments
	segs = window.location+"";
	
	//to get rid of flex debugging only
	if(segs != segs.replace('?debug=true', ''))
	{
		segs = segs.replace('?debug=true', ''); 
		window.location = segs;
		return;
	}
	
	segs = segs.replace(base_url, '/');
	
	
	segs = segs.split('/');
	if(segs.length > 0 && segs[0] == "")
	{
		segs = segs.slice(1);
	}
	
	//if uri includes foliostop
	if((location.host).indexOf('foliostop') >= 0)
	{
		usingDomain = false;
		accountname = segs[0];
		if(accountname[accountname.length-1] == "#")
		{
			accountname = accountname.substr(0, accountname.length-1);
		}
		site_url+= accountname+"/";
		segs = segs.slice(1);
	}
	
	if(segs.length > 0 && segs[0] == "#")
	{
		segs = segs.slice(1);
		page_url = segs.join('/');
	}
	
	if(segs.length > 0 && segs[0] == "")
	{
		segs = segs.slice(1);
		page_url = segs.join('/');
	}
	
	if(typeof(jQuery) == 'function')
	{
		ajax_available = jQuery.support.ajax;
	}
	
	//if segs and not deeplinked
	if(segs.length > 0 && ajax_available)
	{
//		if(navigator.appName == 'Microsoft Internet Explorer')
//		{
//			
//		}
		window.location = site_url + '#/' + segs.join('/');
	}
}

function checkIfMobile()
{
	var mobwrap = $('#mobwrap');
	if(mobwrap.size() > 0)
	{
		is_mobile = true;
	}
}






