$(function(){
	$('div.round').each(function() {
    	var q = $(this).corner("rounded 5px");
    	eval(q);
    });

	$('a.round').each(function() {
    	var q = $(this).corner("rounded 5px");
    	eval(q);
    });

	$('button.round').each(function() {
    	var q = $(this).corner("rounded 5px");
    	eval(q);
    });

	var hasReqestedVersion = DetectFlashVer(10, 1, 0);
	if(!hasReqestedVersion)
	{
		$(".mp4-link").each(function(i,v) {
			$(this).attr("rel",null);
			var href = $(this).attr("href");
			console.log(href);
			href = href.match(/path=([^&]+)/i);
			if(href)
				$(this).attr("href", href[1]);
			else
				$(this).attr("href", "#");
		});
	}

	$(".action").click(function(e) {
		var vid = $(this).parent().find(".element").get(0);
		console.log(vid);
		if($(this).hasClass("pause")) {
			vid.pause();
			$(this).removeClass("pause");
		} else {
			vid.play();
			$(this).addClass("pause");
			timeoutHide(this);
		}
	});
	$(".mute").click(function(e) {
		var vid = $(this).parent().find(".element").get(0);
		if($(this).hasClass("un")) {
			vid.volume = 1;
			$(this).removeClass("un");
		} else {
			vid.volume = 0;
			$(this).addClass("un");
		}
	});
	$(".video").bind("touchend", function(e) {
		var vid = $(this).find(".element").get(0);
		timeoutShow(vid);
		if(vid.paused) {
			return;
		}
		setTimeout(timeoutHide, 2000, vid);
	});
	
});

function timeoutHide(obj) {
	var vid = $(obj).parent().find(".element").get(0);
	if(!vid.paused) {
		$(".action, .mute", $(obj).parent()).fadeOut(250);
	}
}

function timeoutShow(obj) {
	$(".action, .mute", $(obj).parent()).fadeIn(250);
}
