﻿$(function(){
    $("#videoList a").click(function(e){
        e.preventDefault();
        var href=$(this).attr("href")
        var filepath=href.substring(href.lastIndexOf("/")+1);
        $("#videoHolder").html(generateVimeoPlayer(filepath,$(this).html()))
    })
	$("#videoList a:first").trigger("click")
    
	$("#audioList a").click(function(e){
        e.preventDefault();
        var href=$(this).attr("href")
       // var filepath=href.substring(href.lastIndexOf("/")+1);
        $("#videoHolder").html(generateAudioPlayer(href,$(this).html()))
    })
	
    $(".MediaList a").click(function(e){
        e.preventDefault();
       // alert($(this).find(".productDetails").html())
        $("#productDetails").html($(this).parent().find(".productDetails").html())
    })
	$(".MediaList a:first").trigger("click")
	
	$(".Reshad .ReshadList a").click(function(e){
		e.preventDefault();
		$(".RightInColonText div").hide();
		$(".subScribe").parent().show();
		$(".RightInColonText "+$(this).attr("href")+", .clirer").show()
	})
	$(".rbform").hide();
	$(".Subscribe .add").click(function(e){
		e.preventDefault();
		//
		var out="";
		$("ul.contactList input").each(function(){
			out+="<input type='hidden' name='"+$(this).attr("name")+"' value='"+$(this).val()+"' />";
		})
		$(".rbform").append(out);
		$(".rbform").submit();
	})
	
	$(".Events .listQ a").click(function(e){
		e.preventDefault()
		$("#eventsWrap").html($(this).parent().parent().next(".eventsContent").html())
	})
	$(".Events .listQ a:first").trigger("click")
	
})

function generateAudioPlayer(filepath,title){
    var out='<span class="infoLine">'+title+'</span><div style="margin-left:40px;"><object width="281" height="78">';
    out+='<param name="allowfullscreen" value="true" />';
    out+='<param name="allowscriptaccess" value="always" />';
	out+='<param name="flashvars" value="pathToFiles=&artistName= &songName= &songURL='+filepath+'" />';
    out+='<param name="movie" value="/preview.swf" />';
    out+='<embed src="/preview.swf" flashvars="pathToFiles=&artistName= &songName= &songURL='+filepath+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="281" height="78">';
    out+='</embed></object></div>';
    return out;
}
function generateVimeoPlayer(filepath,title){
    var out='<span class="infoLine">'+title+'</span><object width="400" height="302">';
    out+='<param name="allowfullscreen" value="true" />';
    out+='<param name="allowscriptaccess" value="always" />';
    out+='<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+filepath+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=&amp;fullscreen=1" />';
    out+='<embed src="http://vimeo.com/moogaloop.swf?clip_id='+filepath+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="302">';
    out+='</embed></object>';
    return out;
}
