function hyvesAuth()
{
	shareHash = Math.round(((new Date()).getTime()-Date.UTC(1970,0,1))/1000);
	window.open('http://217.67.248.105/~droombaby/hyvesAuth.php?shareHash=' + shareHash, 'windowpopup', 'width=500, height=400, toolbar=false');
	getShareData(shareHash);
}

function hyvesAuthResult( hyvesToken, userId )
{
	$$('#bc_viewer')[0].hyvesAuthResult( hyvesToken, userId );
}

function authorizeFB() {
	shareHash = Math.round(((new Date()).getTime()-Date.UTC(1970,0,1))/1000);
	window.open('http://217.67.248.105/~droombaby/authorizefb/index.php?shareHash=' + shareHash, 'windowpopup', 'width=800, height=600, toolbar=false');
	getShareData(shareHash);
}

function authorizeFBResult() {
	$$('#bc_viewer')[0].authorizeFBResult();
}

function getShareData(shareHash) {
	 var request = new Request.JSONP(
	 {
		url: 'http://217.67.248.105/~droombaby/getShareData.php',
		data: {
			shareHash: shareHash
		},
		onComplete: function(response) { 
			if (!$chk(response))
			{
				setTimeout("getShareData(shareHash);",2000);
			}
			else {
				if (response.hyvesId == 0)
				{
					authorizeFBResult();
				}
				else
				{        
					token = response.hyvesToken.replace('%-', '=');
					hyvesAuthResult( token, response.hyvesId );
				}
			}
		   }
	}
	).send();
}

function openTAFMailPreview()
{
	window.open('http://217.67.248.105/~droombaby/mailpreview.html', 'preview', 'status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=640,width=640');
}

function callAdwords()
{
	var xml = new XMLHttpRequest();
	xml.open('GET', 'http://www.googleadservices.com/pagead/conversion/1034330383/?value=2,50&amp;label=zhuqCImIzgEQj8Ka7QM&amp;guid=ON&amp;script=0');
	xml.send();
}
