var mediaWindow;

function showInThickboxNewMessage(href, width, height, message) {
	
	showInThickbox(href, width, height);
	self.parent.document.getElementById("TB_ajaxWindowTitle").innerHTML = "<span class=\"tabHeader\">"+message+"</span>";
}

function showInThickbox(href, width, height) {
	parent.document.getElementById('TB_window').style.height = (height+30)+"px";
	parent.document.getElementById('TB_window').style.width = width+"px";
	parent.document.getElementById('TB_iframeContent').style.width = width+"px";
	parent.document.getElementById('TB_iframeContent').style.height = height+"px";
	parent.TB_WIDTH = width;
	parent.TB_HEIGHT = height;
	parent.tb_position();
	location = href;
}

function loadPageFromThickbox(url, newWindow) {
	tb_remove();
	if (newWindow) {
		window.open(url);
	}
	else {
		self.parent.document.location = url;
	}
}

function openWindow(href, width, height) {
	if (mediaWindow && !mediaWindow.closed){
		mediaWindow.focus();
		mediaWindow.resizeTo(width, height+50);
		mediaWindow.location = href;
	} else {
		mediaWindow = window.open(href, "mediaWindow", "width="+width+",height="+height);
	}
	
	if(!mediaWindow) {
		alert("To view GDCVault.com content, please disable your popup blocker for this site.");
	}
}
function videoPlayerPopup(link, windowname, fromIframe) {
   var href;

   if (typeof(link) == 'string')
      href = link;
   else
      href = link.href;
   
   width = 1024;
   height = 700;
   openWindow(href, width, height);
}


function audioPlayerPopup(link, windowname, fromIframe) {
   var href;

   if (typeof(link) == 'string')
      href = link;
   else
      href = link.href;

   width = 1024;
   height = 250;
   openWindow(href, width, height);
}

function pdfPlayerPopup(link, windowname, fromIframe) {
   var href;

   if (typeof(link) == 'string')
      href = link;
   else
      href = link.href;
   
   width = 1028;
   height = 868;
   openWindow(href, width, height);
}

function dsVideoPlayerPopup(link, windowname, fromIframe) {
   var href;
   if (typeof(link) == 'string')
      href = link;
   else
      href = link.href;
   
   width = 1028;
   height = 868;
   openWindow(href, width, height);
}

function loginPopup(redirectUrl) {
	var url = "/login?thickbox=true&TB_iframe=true&thickbox=true&width=400&height=250";
	//var url = "/login?thickbox=true&width=400&height=250";
	
	if (redirectUrl) {
		url += "&url=" + redirectUrl;
	}
	
	tb_show("<span class=\"tabHeader\">Returning Members</span>", url);	
}

function searchPopup(category) {
	var url = "/advanced-search?category=" + category + "&TB_iframe=true&width=600&height=400";
	tb_show("<span class=\"tabHeader\">Advanced Search</span>", url);
}

function sponsorRegPopup(sponsorId, cid, type) {
	var url = '/sponsor_user_register_form.php?sponsor_id=' + sponsorId + '&cid=' + cid + '&type=' + type + '&TB_iframe=true&height=400&width=450';
	tb_show("<span class=\"tabHeader\">Free Content Form</span>", url);
}

function becomeAMemberPopup() {
	if (parent.document.getElementById('TB_window')) {
		showInThickboxNewMessage('/become_a_member.php?thickbox=true', 750, 600, 'Become A Member');
		return;
	}
	var url = "/become_a_member.php?thickbox=true&TB_iframe=true&thickbox=true&width=750&height=575";	
	tb_show("<span class=\"tabHeader\">Become A Member</span>", url);	
}

/* This is kind of like print_r in PHP */
function printObject(object) {
	var str = '';
	for(prop in object) {
		if(object.hasOwnProperty(prop))
			str += prop + " : " + object[prop] + "\n";
	}
	alert(str);
}

