var baseURL = "";
indx = location.href.indexOf("pro");    
baseURL = location.href.substr(0,indx);
var url=location.href;
if(url&&url.length>0&&url.indexOf('/pro')!=-1)
	baseURL=url.substr(0,url.indexOf('/pro')+1);
else if(url&&url.length>0&&url.indexOf('\\pro')!=-1)
	baseURL=url.substr(0,url.indexOf('\\pro')+1);
else if(url&&url.length>0&&url.indexOf('\\index.php')!=-1)
	baseURL=url.substr(0,url.indexOf('\\index.php')+1);
else if(url&&url.length>0&&url.indexOf('/index.php')!=-1)
	baseURL=url.substr(0,url.indexOf('/index.php')+1);
else if(url&&url.length>0&&url.lastIndexOf('/')!=-1)
	baseURL=url.substr(0,url.lastIndexOf('/')+1);
else if(url&&url.length>0&&url.lastIndexOf('\\')!=-1)
	baseURL=url.substr(0,url.lastIndexOf('\\')+1);

var isReady = false;
var homePageReadyCalled = false;


function GetBaseURL()
{
	return baseURL;
}

function watchitoo_OnLogin(username, nickname, certificate, accountType) 
{
		alert('you are loged in as '+accountType);
}

function watchitoo_OnLogout() {
	window.location="/";
}

function watchitoo_OnLoginFailed(errorCode, description) {
	window.location="/";
}

function watchitoo_OnStateChange(state) {
	//alert("state="+state);
	if(state=="loggedOut")
	{
		// added these lines to ensure logout gets processed
		self.parent.clearWelcome();
		//getSWF("HomePage").Signout();
	
		// added this line to create a guest account if not logged in
		//setTimeout("CreateGuestAccount()",100);
	}
}

function watchitoo_OnRegister(params) {
	//getSWF("HomePage").onRegisterResult('success','', params);
	// redirect to member page
	window.location="/pro/";
}

function watchitoo_OnRegisterError(errorCode, description, params) {
	//getSWF("HomePage").onRegisterResult('error', description, params);
}

function watchitoo_OnError(text) {
	alert(text);
}

$(document).ready(function() {
	//this is jQuery's init function - being run when the DOM is ready. (before the images are loaded)
	$('#signout').click(function(){
		// added these lines to ensure logout gets processed
		self.parent.clearWelcome();
		Logout();
		//login.logout();
	});

});

