/**
 * @author roger
 * Cross Domain Communication Javascript Library
 */

jQ(document).ready(function(){
	var foo = new Date; // Generic JS date object
	var unixtime_ms = foo.getTime(); // Returns milliseconds since the epoch
	unixtime = parseInt(unixtime_ms / 1000);
	unixtime = 'rider'+unixtime+'';
	cdm(document.domain, unixtime);

	//cdm[unixtime] = function(data) {
	cdm.callback = function(data) {	
		//console.log(data);
		data = parseInt(data);
		pageUserId = data;
		if (data != 0) {
			jQ.get('/contentfiles/toolbar.html', function(html){
				jQ('body').css('margin-top', '33px');
				jQ('body').append(html);
			});
		}
		cdm.callback = function(){alert('error');}
		jQ('#riderown_check_frame').remove();
	}
});
var cdm = function(mydomain, handle){
	jQ('body').append('<iframe id="riderown_check_frame" style="display:none;" src="http://www.riderowned.com/cdm.php?mydomain='+mydomain+'&handle='+handle+'" height="0" width="0" border="1"></iframe>');	
}

top.document.cdm = cdm;
