document.write('<script type=\"text/javascript\" src=\"/javascripts/fujiplayer.js\" charset=\"utf-8\"></script>');


function URLOpener() {
}

URLOpener.open = function(url, target, options) {
	
	if ( location.href.indexOf("b_hp") !== -1 && target === "spot" && location.href.indexOf("otn/b_hp") === -1 ) {
		var _oainfo = ( location.href.indexOf("index.html") !== -1 ) ? location.href.replace("index.html", "oainfo.xml"): location.href + "oainfo.xml";
		$.ajax({
			type: "GET", url: _oainfo, dataType: "xml", cache: true, success: function(xml) {
				
							
				$(xml).find("onair").each(function(i) {
					var _x = URLOpener.xml(this);
					fujiplayer.show(_x.mplus.split("=")[1], _x.movie, "spot");
				});
			}
		});

		return;
	}

	if (URLOpener.isSafari()) {
		URLOpener.clickEvent(url, target, options);
		return;
	}

	window.open(url, target, options);
};

URLOpener.xml = function(_this) {
	
	var _oadate ='';
	if( $(_this).find("end").text() == undefined || $(_this).find("end").text() == '' || $(_this).find("end").text() == null ){
		_oadate = $(_this).find("oadate").text();
	}else{
		_oadate = $(_this).find("oadate").text() +' ' +$(_this).find("start").text()+'～'+$(_this).find("end").text();	
	}
	
	var _r = {
		"date": _oadate,
		"title": $(_this).find("title").text(),
		"subtitle": $(_this).find("subtitle").text(),
		"overview": $(_this).find("overview").text(),
		"cast": $(_this).find("cast1").text(),
		"mplus": $(_this).find("mplus").text(),
		"movie": $(_this).find("movie").text()
	}
	return _r;
}

URLOpener.clickEvent = function(url, target, options) {
	var div = document.createElement('div');
	div.onclick = function() {
		window.open(url, target, options);
	};

	var event = document.createEvent('MouseEvents');
	event.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
	div.dispatchEvent(event);
};

URLOpener.isSafari = function() {
	return (
		navigator.userAgent != null &&
		navigator.userAgent.indexOf("Safari") >= 0 &&
		navigator.userAgent.indexOf("Chrome") < 0
	);
};



function NewWindowOpen(Widthss,Heightss,URLss,Namess,Scrollbarss,Resizable){
	URLOpener.open(arguments[2],arguments[3],"location=no,menubar=no,resizable=" + (arguments[5] ? arguments[5] : "yes") + ",scrollbars=" + (arguments[4] ? arguments[4] : "yes" ) + ",status=yes,toolbar=no,fullscreen=no,directories=no,width=" + arguments[0] + ",height=" +  arguments[1] + ",top=" + ((document.getElementById) ? (screen.height / 2) - ( arguments[1] / 2) : 0) + ",left=" + ((document.getElementById) ? (screen.width / 2) - (arguments[0] / 2) : 0));
}

function NewWindowOpenCopyrights(){
	URLOpener.open("http://www.fujitv.co.jp/rights/index.html?1#B","disclaimer","width=540,height=460,toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");
}

function OpenFLValone(flvPath, resizable){

		var W_w = 320;
		var H_h = 224;
		var txtes = "http://www.fujitv.co.jp/GPplayer/e/GPplayerJMe.html?";
		
		if(flvPath.substr(flvPath.lastIndexOf('.'))=='.mp4'){
			txtes += flvPath.substr(0, flvPath.lastIndexOf('.')) + "&type=mp4";
		}else{
			txtes += flvPath + "&type=flv";
		}
		
		URLOpener.open(txtes,"spot",'location=no,menubar=no,resizable=' + resizable +',scrollbars=no,status=no,toolbar=no,fullscreen=no,directories=no,width=' + W_w + ",height=" + H_h + ",top=" + ((document.getElementById) ? (screen.height / 2) - (H_h / 2) : 0) + ",left=" + ((document.getElementById) ? (screen.width / 2) - (W_w / 2) : 0));
}

function OpenFLValone480(flvPath, resizable){

		var W_w = 480;
		var H_h = 292;
		var txtes = "http://www.fujitv.co.jp/GPplayer/e/GPplayerJMe480272.html?";
		
		if(flvPath.substr(flvPath.lastIndexOf('.'))=='.mp4'){
			txtes += flvPath.substr(0, flvPath.lastIndexOf('.')) + "&type=mp4";
		}else{
			txtes += flvPath + "&type=flv";
		}
		
		URLOpener.open(txtes,"spot",'location=no,menubar=no,resizable=' + resizable +',scrollbars=no,status=no,toolbar=no,fullscreen=no,directories=no,width=' + W_w + ",height=" + H_h + ",top=" + ((document.getElementById) ? (screen.height / 2) - (H_h / 2) : 0) + ",left=" + ((document.getElementById) ? (screen.width / 2) - (W_w / 2) : 0));
}

function OpenLoginFLV(playID, resizable) {
	var W_w = 260;
	var H_h = 260;
	resizable = resizable != "yes" ? "no" : "yes";
	var txtes = "https://wwws.fujitv.co.jp/safe/flvplayer/loginPlayer.html?Pathes=" + playID;
	URLOpener.open(txtes,"loginFlvWindow",'location=no,menubar=no,resizable=' + resizable +',scrollbars=no,status=no,toolbar=no,fullscreen=no,directories=no,width=' + W_w + ",height=" + H_h + ",top=" + ((document.getElementById) ? (screen.height / 2) - (H_h / 2) : 0) + ",left=" + ((document.getElementById) ? (screen.width / 2) - (W_w / 2) : 0));
}

function OpenQRC(){
	URLOpener.open("http://www.fujitv.co.jp/b_hp/qrc.html?"+arguments[0],"qrc","width=220,height=135,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes");
}
