/* DVD Explorer common JS */
var dvdexplorer_popInfoWindow;
var dvdexplorer_popCCWindow;
var dvdexplorer_popT123Window;
var dvdexplorer_popJoinWindow;
var dvdexplorer_popJoinWindow;

//popExit
function dxppe(url) {
	return _dvdexplorer_do_pop(dvdexplorer_popExitWindow, 'dvdexplorer_popExitWindow', url, 550, 750);
}
// popInfo
function dxppi(url) {
	return _dvdexplorer_do_pop(dvdexplorer_popInfoWindow, 'dvdexplorer_popInfoWindow', url, 550, 750);
}
// popCC
function dxppcc(url) {
	/* No popups to get the referrer check working to address the cc issues */
	return true;
	/*return _dvdexplorer_do_pop(dvdexplorer_popCCWindow, 'dvdexplorer_popCCWindow', url, 600, 755); // 650*/
}
// popT123
function dxppt123(url) {
	return _dvdexplorer_do_pop(dvdexplorer_popT123Window, 'dvdexplorer_popT123Window', url, 320, 400, true);
}
// popJoin
function dxppj(url) {
	
	width = screen.availWidth - 10;
	height = screen.availHeight - 50;
	handle = window.open(url,'dvdexplorer_popJoinWindow','width=' + width + ', height=' + height + 'top=0, left=0, scrollbars=yes,resizable=yes');
	if (handle && handle.window)
		handle.window.close();
		//alert(handle);
	handle = window.open(url,'dvdexplorer_popJoinWindow','width=' + width + ', height=' + height + 'top=0, left=0, scrollbars=yes,resizable=yes');
	//window.open(url, 'dvdexplorer_popJoinWindow', 'width=' + width + ', height=' + height + ', ' + 'top=0, left=0, scrollbars=yes, resizable=yes');
	return false;
}
// popPreview
function dxppp(url) {
	width = screen.availWidth - 10;
	height = screen.availHeight - 50;
	window.open(url,'dvdexplorer_popJoinWindow','width=' + width + ', height=' + height + 'top=0, left=0, toolbar=yes,scrollbars=yes,resizable=yes');
	//window.open(url, 'dvdexplorer_popJoinWindow', 'width=' + width + ', height=' + height + ', ' + 'top=0, left=0, scrollbars=yes, resizable=yes');
	return false;
}
function _dvdexplorer_do_pop(handle, name, url, height, width, fixed) {
	if (handle && handle.window)
		handle.window.close();
	handle = window.open(url, name, 'width=' + width + ', height=' + height + ', ' + 'top=0, left=0, ' +
					  ((!fixed) ? 'scrollbars=yes, resizable=yes' :
								  'resizable=no') );
	return false;
}
// write favorites link
function dxwf(linktext, login) {
	if (window.external) {
		 document.write("<li><a href='javascript:window.external.AddFavorite(" +
						'"http://www.dvd-explorer.com/?login='+ login + '"  ,"DVD-EXPLORER.COM"'
						 + ");'>"+linktext+"</a></li>");
	}
}
function debug_me(){
		document.write(document.URL + '\<br/\>');
		document.write(window.location + '\<br/\>');
		document.write(window.frames + '\<br/\>');
}
function iFrameHeight(iname) {
	if(document.getElementById && !(document.all)) {
		h = document.getElementById(iname).contentDocument.body.scrollHeight;
		document.getElementById(iname).style.height = h;
	}
	else if(document.all) {
		h = document.frames(iname).document.body.scrollHeight;
		document.all.iframename.style.height = h;
	}
}
function err_handler (msg, url, line) {						
			return true;									
}
function check_framed (){

	window.onerror	= err_handler;
	return (top.location != self.location);
}
function get_join (ccUrl){
	framed = check_framed();
	if (!framed) {
		return 'http://www.dvd-explorer.com/prejoin/redirect/';
	}
	else {
		return ccUrl;
	}
}
function dvdexplorer_gjl (ccUrl, link_txt){
	document.write ("<a href='" + get_join (ccUrl) + "'>" + link_txt + "</a>");
}

function dvdexplorer_scenelink_gjl (fallback_url){
	framed = check_framed();
	
	if (!framed) {
		return 'http://www.dvd-explorer.com/prejoin/redirect/';
	}
	else {
		return fallback_url;
	}

}

function dvdexplorer_redirect_framed (url, link_class) {
	
	str = url;
	str += '&is_framed=';
	if (!check_framed () ) 
		document.write ( '<a href=\''+str+'0'+'\' target=\'_blank\' class=\''+link_class+'\'>');
	else 
		document.write ( '<a href=\''+str+'1'+'\' target=\'_blank\'  class=\''+link_class+'\'>');

}

function dvdexplorer_go_ccurl_link (url){
	if (!check_framed () ) 
		document.write ( '<a href=\'http://www.dvd-explorer.com/prejoin/redirect\' target=\'_blank\'>');
	else 
		document.write ( '<a href=\''+url+'\' target=\'_blank\'>');
}

function dvdexplorer_go_join (fallback_url) {
	
	top.location = dvdexplorer_scenelink_gjl (fallback_url);
}
function dvdexplorer_go (url){
	top.location = url;
}


