
show_flg=new Array();
function img_show(id,width,height){
		document.getElementById('video_thumb_'+id).style.width=width+'px';
		document.getElementById('video_thumb_'+id).style.height=height+'px';
		document.getElementById('video_thumb_'+id).style.border='1px solid gray';
}
	
function add_fav(){
	$("#fav_result").load("/favorite_add.php?play_list_id="+encodeURIComponent(document.getElementById("play_list_id_fav").value)+"&movie_id="+encodeURIComponent(document.getElementById("movie_id_fav").value));
}

function quickplay(num,type,id){
	loc=num;
	if(type){
		loc=type;
	}
	if(show_flg[num]==1){
		show_flg[num]=0;
		
		$('#quickplay_'+loc).hide('fast');
		$('#quickplay_'+loc).html('');
		if(type){
			$('#a_quick_text_'+num).html('再生');
		}else{
			$('#a_quick_text_'+num).html('ここで再生');
		}
		
	}else{
		show_flg[num]=1;
		$('#quickplay_'+loc).html('<br>動画を読み込み中です。しばらくお待ちください。<br>');
		$('#quickplay_'+loc).show('fast');
		$.get("/watch_quick.php?id="+id,function(text){
			$('#quickplay_'+loc).html('<iframe src="/watch_embed.html?id='+id+'" width="1" height="1" frameborder="0" border="0"></iframe><br>'+text);
		});
		$('#a_quick_text_'+num).html('閉じる');
	}
}

$(function() {
	$('#container-1 > ul').tabs();
	$('#container-2 > ul').tabs({ selected: 1 });
	$('#container-3 > ul').tabs({ fx: { height: 'toggle' } });
	$('#container-4 > ul').tabs({ fx: { opacity: 'toggle' } });
	$('#container-5 > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
});

$(document).ready(function () {
	$('#searchsitenav').pager('ul', {
	navId: 'nav2', height: '100%' 
	});
});
 // show commnet form id
$(document).ready(function(){
	$(".option").click(function () {
	if ($("#option-form").is(":hidden")) {
	$("#option-form").slideDown("slow");
	} else {
	$("#option-form").slideUp("slow");
	}
	});
});
$(document).ready(function(){
	$(".login").click(function () {
	if ($("#login-form").is(":hidden")) {
	$("#login-form").slideDown("slow");
	} else {
	$("#login-form").slideUp("slow");
	}
	});
});
/* jQuery textarea resizer plugin usage */
$(document).ready(function() {
	$('textarea.resizable:not(.processed)').TextAreaResizer();
});
/* jQuery ContextHighlighting plugin usage */
$(document).ready(function()
{
	$('.content .left, .content input, .content textarea, .content select').focus(function(){
		$(this).parents('.new_user').addClass("over");
	}).blur(function(){
		$(this).parents('.new_user').removeClass("over");
	});
	$('.new_user input, .new_user textarea, .new_user select').focus(function(){
		$(this).parents('.row').addClass("over");
	}).blur(function(){
		$(this).parents('.row').removeClass("over");
	});
});
$(function(){
	$("body *:first-child").addClass("first-child");
	$("#gNav > li > img").parent().each(function(){
		$(this).hover(function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		});
	});
	$("#gNav li ul").hide();
	$("body").click(function(event){
		$("#gNav li.active").removeClass("active");
		$("#gNav li ul:visible").hide();
	});
	$("#gNav li img").click(function(event){
		var parent = $(this).parent();
		if(parent.hasClass("active")){
			parent.removeClass("active");
			$("#gNav li ul:visible").hide();
			event.stopPropagation();
		}else{
			$("#gNav li.active").removeClass("active");
			parent.addClass("active");
			$("#gNav li ul:visible").hide();
			$(this).next().show();
			event.stopPropagation();
		}
	});
});

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	ADxMenu.js - v4 (4.21) - helper script for Internet Explorer, up to version 6
	http://aplus.co.yu/adxmenu/
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2003, 2008, Aleksandar Vacic, aplus.co.yu
		This work is licensed under the CC Attribution 3.0 Unported license
		To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
		send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
//	adds support for WCH. if you need WCH, then load WCH.js BEFORE this file
if (typeof(WCH) == "undefined") WCH = null;

//	hide submenus
document.write('<style type="text/css" media="all">.menu ul {visibility:hidden; position:absolute;}</style>');

var ADxMenu = function() {
	var self = this;

	this.Init = function() {
		self.adxmDL.load(Setup);
	};

	function Setup() {
		var aTmp2, i, j, oLI, aUL, aA;
		var aTmp = xGetElementsByClassName("adxm", document, "ul");
		for (i=0;i<aTmp.length;i++) {
			//	add (or remove) "adxie" class, to be used in cases when two different styles are required: one when Javascript is visible and one when it's not
			//	aTmp[i].className += " adxie";
			aTmp[i].className = aTmp[i].className.replace("adxie", "");
			//	setup drop-down goodness
			aTmp2 = aTmp[i].getElementsByTagName("li");
			for (j=0;j<aTmp2.length;j++) {
				oLI = aTmp2[j];
				aUL = oLI.getElementsByTagName("ul");
				//	if item has submenu, then make the item hoverable
				if (aUL && aUL.length) {
					oLI.UL = aUL[0];	//	direct submenu
					aA = oLI.getElementsByTagName("a");
					if (aA && aA.length)
						oLI.A = aA[0];	//	direct child link
					//	li:hover
					oLI.onmouseenter = function() {
						this.className += " adxmhover";
						this.UL.className += " adxmhoverUL";
						if (this.A) this.A.className += " adxmhoverA";
						if (WCH) WCH.Apply( this.UL, this, true );
					};
					//	li:blur
					oLI.onmouseleave = function() {
						this.className = this.className.replace(/adxmhover/,"");
						this.UL.className = this.UL.className.replace(/adxmhoverUL/,"");
						if (this.A) this.A.className = this.A.className.replace(/adxmhoverA/,"");
						if (WCH) WCH.Discard( this.UL, this );
					};
				}
			}	//for-li.submenu
		}	//for-ul.adxm
	};

	/*	xGetElementsByClassName()
		Returns an array of elements which are
		descendants of parentEle and have tagName and clsName.
		If parentEle is null or not present, document will be used.
		if tagName is null or not present, "*" will be used.
		credits: Mike Foster, cross-browser.com.
	*/
	function xGetElementsByClassName(clsName, parentEle, tagName) {
		var elements = null;
		var found = new Array();
		var re = new RegExp('\\b'+clsName+'\\b');
		if (!parentEle) parentEle = document;
		if (!tagName) tagName = '*';
		if (parentEle.getElementsByTagName) {elements = parentEle.getElementsByTagName(tagName);}
		else if (document.all) {elements = document.all.tags(tagName);}
		if (elements) {
			for (var i = 0; i < elements.length; ++i) {
				if (elements[i].className.search(re) != -1) {
					found[found.length] = elements[i];
				}
			}
		}
		return found;
	}
	
	/*	allows instant "window.onload" (DOM.onload) function execution. shortened version, just IE code
		credits: Dean Edwards/Matthias Miller/John Resig/Rob Chenny
		http://www.cherny.com/webdev/27/domloaded-updated-again
	*/
	this.adxmDL = {
		onload: [],
		loaded: function() {
			if (arguments.callee.done) return;
			arguments.callee.done = true;
			for (i = 0;i < self.adxmDL.onload.length;i++) self.adxmDL.onload[i]();
		},
		load: function(fireThis) {
			this.onload.push(fireThis);
			/*@cc_on @*/
			/*@if (@_win32)
			var proto = "src='javascript:void(0)'";
			if (location.protocol == "https:") proto = "src=//0";
			document.write("<scr"+"ipt id=__ADXMie_onload defer " + proto + "><\/scr"+"ipt>");
			var script = document.getElementById("__ADXMie_onload");
			script.onreadystatechange = function() {
			    if (this.readyState == "complete") {
			        self.adxmDL.loaded();
			    }
			};
			/*@end @*/
		}
	};
	
	return this;
}();
//	load the setup function
ADxMenu.Init();

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

/*
 * IE PNG Fix v1.4
 *
 * Copyright (c) 2006 Takashi Aida http://www.isella.com/aod2/
 *
 */

// IE5.5+ PNG Alpha Fix v1.0RC4
// (c) 2004-2005 Angus Turnbull http://www.twinhelix.com

// This is licensed under the CC-GNU LGPL, version 2.1 or later.
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/

if (typeof IEPNGFIX == 'undefined') {
//--============================================================================

var IEPNGFIX = {
	blank:  'http://www.isella.com/aod2/images/blank.gif',
	filter: 'DXImageTransform.Microsoft.AlphaImageLoader',

	fixit: function (elem, src, method) {
		if (elem.filters[this.filter]) {
			var filter = elem.filters[this.filter];
			filter.enabled = true;
			filter.src = src;
			filter.sizingMethod = method;
		}
		else {
			elem.style.filter = 'progid:' + this.filter +
				'(src="' + src + '",sizingMethod="' + method + '")';
		}
	},

	fixwidth: function(elem) {
		if (elem.currentStyle.width == 'auto' &&
			elem.currentStyle.height == 'auto') {
			elem.style.width = elem.offsetWidth + 'px';
		}
	},

	fixchild: function(elem, recursive) {
		if (!/MSIE (5\.5|6\.|7\.)/.test(navigator.userAgent)) return;

		for (var i = 0, n = elem.childNodes.length; i < n; i++) {
			var childNode = elem.childNodes[i];
			if (childNode.style) {
				if (childNode.style.position) {
					childNode.style.position = childNode.style.position;
				}
				else {
					childNode.style.position = 'relative';
				}
			}
			if (recursive && childNode.hasChildNodes()) {
				this.fixchild(childNode, recursive);
			}
		}
	},

	fix: function(elem) {
		if (!/MSIE (5\.5|6\.|7\.)/.test(navigator.userAgent)) return;

		var bgImg =
			elem.currentStyle.backgroundImage || elem.style.backgroundImage;

		if (elem.tagName == 'IMG') {
			if ((/\.png$/i).test(elem.src)) {
				this.fixwidth(elem);
				this.fixit(elem, elem.src, 'scale');
				elem.src = this.blank;
				elem.runtimeStyle.behavior = 'none';
			}
		}
		else if (bgImg && bgImg != 'none') {
			if (bgImg.match(/^url[("']+(.*\.png)[)"']+$/i)) {
				var s = RegExp.$1;
				this.fixwidth(elem);
				elem.style.backgroundImage = 'none';
				this.fixit(elem, s, 'scale'); // crop | image | scale

				if (elem.tagName == 'A' && elem.style) {
					if (!elem.style.cursor) {
						elem.style.cursor = 'pointer';
					}
				}

				this.fixchild(elem);
				elem.runtimeStyle.behavior = 'none';
			}
		}
	},

	hover: function(elem, hvImg) {
		var bgImg = elem.style.backgroundImage;

		if (!bgImg && elem.currentStyle) bgImg = elem.currentStyle.backgroundImage;

		if (elem.tagName == 'IMG' && hvImg) {
			var image = elem.src;
			elem.onmouseover = function() {
				elem.src = hvImg;
				IEPNGFIX.fix(elem);
			};
			elem.onmouseout = function() {
				elem.src = image;
				IEPNGFIX.fix(elem);
			};
		}
		else if (bgImg && bgImg != 'none' && hvImg) {
			elem.onmouseover = function() {
				elem.style.backgroundImage = 'url(' + hvImg + ')';
				IEPNGFIX.fix(elem);
			};
			elem.onmouseout = function() {
				elem.style.backgroundImage = bgImg;
				IEPNGFIX.fix(elem);
			};
		}

		IEPNGFIX.fix(elem);
	}
};

//--============================================================================
} // end if (typeof IEPNGFIX == 'undefined')

function getLogin(rd){
	$("#login-form").show("slow");
	$("#login-form").load("/login_ajax.php?rd="+encodeURIComponent(rd));
}
SearchOptionFlg=0;
function getSearchOption(q){
	if(SearchOptionFlg==0){
		var q = document.getElementById("search_q").value;
		$("#option-form").load("/search_option_ajax.php?q="+encodeURIComponent(q));
		$("#option-form").show("slow");
		SearchOptionFlg=1;
	}else{
		closeLogin();
		
	}
}

function closeLogin(){
	SearchOptionFlg=0;
	$("#login-form").hide("slow");
}
function openLogin(rd){
	$("#login-form").show("slow");
	$("#login-form").load("/login_ajax.php?rd="+encodeURIComponent('/watch.php?id='+rd));
	
}
function closeSearchOption(){
	$("#option-form").hide("slow");
}
function toggleTag(){
	$("#countrybox").toggle();
}

function searchSummit(type){
	var q = document.getElementById("search_q").value;
	var share_video=document.getElementById('share_video').style;
	var new_video=document.getElementById('new_video').style;
	var web_video=document.getElementById('web_video').style;
	var pay_video=document.getElementById('pay_video').style;
	var hidden_input=document.getElementById('hidden_input');
	
	var normalFontSize="12px";
	var normalFontWeight="normal";
	var changeFontSize="12px";
	var changeFontWeight="bold";
	
	hidden_input.innerHTML='';
	
	if(type=='video'){
		if(q!=""){
			location.href='/search.php?q='+encodeURIComponent(q);
		}else{
			share_video.fontWeight=changeFontWeight;
			new_video.fontWeight=normalFontWeight;
			web_video.fontWeight=normalFontWeight;
			
			share_video.fontSize=changeFontSize;
			new_video.fontSize=normalFontSize;
			web_video.fontSize=normalFontSize;
			
			pay_video.fontWeight=normalFontWeight;
			
			hidden_input.innerHTML='';
			
		}
	}
	if(type=='newvideo'){
		if(q!=""){
			location.href='/search.php?recent=1&q='+encodeURIComponent(q);
		}else{
			share_video.fontWeight=normalFontWeight;
			new_video.fontWeight=changeFontWeight;
			web_video.fontWeight=normalFontWeight;
			
			share_video.fontSize=normalFontSize;
			new_video.fontSize=changeFontSize;
			web_video.fontSize=normalFontSize;
			
			pay_video.fontWeight=normalFontWeight;
			
			hidden_input.innerHTML='<input type="hidden" name="recent" value="1">';
		}
	}
	if(type=='webvideo'){
		if(q!=""){
			location.href='/search.php?webvideo=1&q='+encodeURIComponent(q);
		}else{
			share_video.fontWeight=normalFontWeight;
			new_video.fontWeight=normalFontWeight;
			web_video.fontWeight=changeFontWeight;
			
			share_video.fontSize=normalFontSize;
			new_video.fontSize=normalFontSize;
			web_video.fontSize=changeFontSize;
			
			hidden_input.innerHTML='<input type="hidden" name="webvideo" value="1">';
			
			pay_video.fontWeight=normalFontWeight;
		}
	}
	if(type=='payvideo'){
		if(q!=""){
			location.href='/search_pay/'+encodeURIComponent(q);
		}else{
			share_video.fontWeight=normalFontWeight;
			new_video.fontWeight=normalFontWeight;
			web_video.fontWeight=normalFontWeight;
			
			share_video.fontSize=normalFontSize;
			new_video.fontSize=normalFontSize;
			web_video.fontSize=changeFontSize;
			http://boi.fooooooo.com/search_pay.php?q=%E3%83%8F%E3%83%AB%E3%83%92&payvideo=1&ranking=1
			
			pay_video.fontWeight=changeFontWeight;
			
			hidden_input.innerHTML='<input type="hidden" name="payvideo" value="1">';
		}
	}

}
