function varcall( name )
{
	
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = window.location.href;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
  	return results[1];
}

var args = location.search.substr(1).split("?");
var iframeID = "134";

function returnIframe()
{
	var invar = varcall('albumid');
	var invar = unescape(invar);
	document.write("<iframe src='http://" + iframeID + ".iframe.mediak.com/?_reset=1&_products=" + invar + "&_autopickprod=1' width='650' height='550' allowtransparency='true' frameborder='0'></iframe>");
}

function test(){
	flowplayer.stop();
}

function loadVideo2(){
	closeVideo1();
	newflvPlayer2('/retail/flv/ak-lm-tk-sw-loop2.flv', '280', '210', true, "flashcontent2");
	document.getElementById("videoPlayer2").style.display="";
}

function closeVideo2(){
	document.getElementById("videoPlayer2").style.display="none";
	document.getElementById("flashcontent2").innerHTML="";
}

function loadVideo1(){
	closeVideo1();
	closeVideo2();
	newflvPlayer2('/retail/flv/jly.flv', '504', '336', true, "flashcontent1");
	document.getElementById("lyricstext").innerHTML='<a href="javascript:loadVideo3()">Play video with lyrics</a>';
	document.getElementById("videoPlayer1").style.left="-250px";
	document.getElementById("videoPlayer1").style.top="-120px";
	document.getElementById("videoPlayer1").style.display="";
}

function loadVideo3(){
	closeVideo1();
	newflvPlayer2('/retail/flv/jly_wlyrics.flv', '504', '336', true, "flashcontent1");
	document.getElementById("lyricstext").innerHTML='<a href="javascript:loadVideo1()">Play video without lyrics</a>';
	document.getElementById("videoPlayer1").style.left="-250px";
	document.getElementById("videoPlayer1").style.top="-120px";
	document.getElementById("videoPlayer1").style.display="";
}

function closeVideo1(){
	document.getElementById("videoPlayer1").style.display="none";
	document.getElementById("flashcontent1").innerHTML="";
}

function loadVideoType(type){
	if(type=="lyrics"){
		loadVideo3();
	}
	else if(type=="nolyrics"){
		loadVideo1();
	}
}

function newflvPlayer2(inurl, w, h, autoStart, div)
{
	//alert(inurl);
	//document.getElementById(div).innerHTML=inurl;
	//document.getElementById(div).innerHTML='<a href="'+inurl+'">player</a>';
	flowplayer(div,
	{
		src:'/flash/flowplayer-3.1.5.swf',
		width: w,
		height: h,
		allowfullscreen: false,
		align: 'center',
		wmode: 'opaque',
		onStart:{
			autoPlay: false
		}
	}, 
	{clip: {
        url: inurl,
        autoPlay: autoStart
    },
    plugins: {
    	controls:{
    		url:'/flash/flowplayer.controls-3.1.5.swf',
    		//time: false,
    		scrubber: true,
    		fullscreen: false,
    		mute: false
    	}
    }});
	document.getElementById(div).style.border = "solid black 1px";	
	document.getElementById(div).style.backgroundColor = "#ffffff";
}

function returnName(_h,_w)
{
	var invar = varcall('selectedname');
	var invar = unescape(invar);
	if(invar != ""){
		//document.write("Selected name is: " + invar);
		document.write("<iframe src='http://" + iframeID + ".iframe.mediak.com/index.php?query=" + invar + "&submit=Search&action=search' width='" + _w + "' height='" + _h + "' allowtransparency='true' frameborder='0' scrolling='no'></iframe>");
	}
	else{
		document.write("<iframe src='http://" + iframeID + ".iframe.mediak.com' width='" + _w + "' height='" + _h + "' allowtransparency='true' frameborder='0' scrolling='no'></iframe>");	
	}
}

function checkSearch(theForm)
{
	if(theForm.selectedname.value == "")
	{
		alert("Please enter a name");
		theForm.selectedname.focus();
		return false;
	}
}

function checkField(theForm)
{
	if(theForm.q.value == "")
	{
		return false;
	}
}

function flashObject(_p, _w, _h, _vers, _vars, _i){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write('		codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + _vers + '"');
	document.write('		width="' + _w + '"');
	document.write('		height="' + _h + '"');
	document.write('		id="' + _i + '">');
	document.write('	<param name="allowScriptAccess" value="sameDomain"/>');
	document.write('	<param name="movie" value="' + _p + '"/>');
	document.write('	<param name="quality" value="high"/>');
	document.write('	<param name="wmode" value="transparent"/>');
	document.write('    <param name="swLiveConnect" value="true"/>');
	document.write('	<param name="FlashVars" value="' + _vars + '"/>');
	document.write('	<embed wmode="transparent" src="' + _p + '" FlashVars="' + _vars + '" menu="false" quality="high" bgcolor="#ffffff" width="' + _w + '" height="' + _h + '" name="' + _i + '" align="middle" allowScriptAccess="sameDomain" swLiveConnect="true" type="application/x-shockwave-flash" pluginspage="https://www.adobe.com/go/getflashplayer" />');
	document.write('</object>');
}

function swapVideo(url, width, height)
{
		flashembed("flashcontent", {
			src: 'video/FlowPlayerClassic.swf',
			width:width,
			height:height,
			align: 'middle'
		},
		{config: {
			videoFile:url,
			initialScale:'scale',
			showMenu: false, 
			controlsOverVideo: 'ease',
			controlBarBackgroundColor: -1,
			controlBarGloss: 'low'
		}});
		//document.getElementById("flashcontent").style.border = "solid black 1px";	
		document.getElementById("flashcontent").style.backgroundColor = "#ffffff";
}

function playVideo(url, width, height, autoStart)
{
		//alert(url + width + height);
		flashembed("flashcontent", {
			src: 'video/FlowPlayerClassic.swf',
			width:width,
			height:height,
			align: 'middle'
		},
		{config: {
			videoFile:url,
			initialScale:'scale',
			showMenu: false, 
			controlsOverVideo: false,
			controlBarBackgroundColor: -1,
			controlBarGloss: 'low',
			autoPlay: autoStart
		}});
		document.getElementById("flashcontent").style.border = "solid black 1px";	
		document.getElementById("flashcontent").style.backgroundColor = "#ffffff";
}

function email(name){
	document.write('<a href="mailto:' + name + '@mediak.com">' + name + '@mediak.com</a>');
}

function newflvPlayer(inurl, w, h, autoStart, div)
{
	//alert(inurl);
	//document.getElementById(div).innerHTML=inurl;
	//document.getElementById(div).innerHTML='<a href="'+inurl+'">player</a>';
	flowplayer(div,
	{
		src:'/flash/flowplayer-3.1.5.swf',
		width: w,
		height: h,
		allowfullscreen: false,
		align: 'center',
		wmode: 'opaque',
		onStart:{
			autoPlay: false
		}
	}, 
	{clip: {
        url: inurl,
        autoPlay: false
    },
    plugins: {
    	controls:{
    		url:'/flash/flowplayer.controls-3.1.5.swf',
    		//time: false,
    		scrubber: false,
    		fullscreen: false,
    		mute: false
    	}
    }});
	document.getElementById(div).style.border = "solid black 1px";	
	document.getElementById(div).style.backgroundColor = "#ffffff";
}

function buyacdnow(){
	buydiv = document.getElementById("buyacdnow");
	seldiv = document.getElementById("selname");
	//alert("chk");
	if(buydiv){
		if(seldiv){
			buydiv.style.display='none';
			seldiv.style.display='block';
		}
	}
}

function divaction(id,action){
	document.getElementById(id).style.display=action;
}