cSongId		=	false;

function isLogged2() {
	var isLogged = (getCookieValue("name") && getCookieValue("c"));
	return			isLogged;
}

function gE(e) {
	return	document.getElementById(e);
}

function	copyClipboard(id) {

var	t		= document.formPlayList.elements[id];
	code	= t.value;

	if (code.length>0) {
		if (window.clipboardData) {
				window.clipboardData.setData("Text", code);
				alert("Your code has been copied to the ClipBoard! \n\n Simply PASTE (Ctrl+V) this into your html document.");
		}else{
				t.focus();
				t.select();
				alert("Use Right Mouse Button & Select COPY!");
		}
	} else
			alert("You do not have anything to Copy!");
}
function clearPlayList() {
	gE("topTitle2").style.display = "none";
	setCookie("playlist","","/","");
	reindexPlayList();
}
function cPlayList() {
	var		playList	=	getCookieValue("playlist");
	return					playList ? playList.split(",") : new Array();
}
function setCookiePl(n) {
	var	pLP	=	cPlayList();
	var	p	=	"";
	for(var i=0; i<pLP.length; i++) {
		if(pLP[i] == n)  {
			reindexPlayList();
			return;
		}
		p			+=	pLP[i] + ",";
	}
	p				+=	n;
	setCookie("playlist",p,"/","");
	reindexPlayList();
}
function removePlayList(n) {
	var	pLP	=	cPlayList();
	var	p			=	"";
	for(var i=0;i<pLP.length;i++) {
		if(pLP[i]	==	n) continue;
		p			+=	pLP[i]+",";
	}
	p				=	p.substring(0,p.length-1);
	setCookie("playlist",p,"/","");
	reindexPlayList();
}
function reindexPlayList() {
	var		pLP		=	cPlayList();
	var 	h		=	"";
	var		added	=	false;
	for(var i=0; i<pLP.length; i++) {
		var listN		=	pLP[i];
		if(cSongId == listN) {
			added							=	true;
			gE("addedVideo").style.display	=	"block";
			gE("addVideo").style.display	=	"none";
		}
		h				+=	'<span href"#">'+listN+'</span>'+" "+'<a href="#" onclick="'+"removePlayList('"+listN+"')"+'">x</a><br>';
	}
	if(!added) {
	if(cSongId) {
		gE("addedVideo").style.display	=	"none";
		gE("addVideo").style.display	=	"block";
	}
	}
	var	l							=	pLP.length;
	gE("playListCount").innerText	=	l;
	gE("playListCount").textContent	=	l;
	var t							=	gE("topTitle2");
	if(l)
		t.style.display			=	"inline";
	else {
		t.style.display			=	"none";
	if(document.formPlayList && document.formPlayList.taPlayList) {	//	Очистка getsong.php TextArea:
		document.formPlayList.taPlayList.value		=	"";
		//document.formPlayList.taPlayList2.value	=	"";
	}
	}
}

function getCookieValue(sName) {
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++) {
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0])
			return unescape(aCrumb[1]);
	}
	return null;
}

function setCookie(cN, cV, cP, cE) {
	cV = escape(cV);
	if (cE == "") {
		var nowDate = new Date();
		nowDate.setHours(nowDate.getHours() + 12)
		cE = nowDate.toGMTString();
	} if (cP != "") {
		cP = ";Path=" + cP;
	}
	document.cookie = cN + "=" + cV + ";expires=" + cE + cP;
}

function vTrim(str) {
	str						=	str.replace(/^\s+/,'');
	str						=	str.replace(/\s+$/,'');
	return						str;
}

function checkMail() {
	var f					= document.formFriend;
	var wrong				= true;
	var wrong1				= true;
	if(vTrim(f.name.value).length<2) {
							alert("Please input \"Your Name:\" ");
							return  false;
	}
	for(var n=0;n<6;n++) {
	var i		=	n?n:"";
	var v		=	vTrim(f["email"+i].value);
	if(!v)			continue;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(v)) {
			wrong	=	true;
						break;
	} else {
		if(n==0)wrong1	=	false;
		else	wrong	=	false;
	}
	}
	if(wrong1) {
		alert("You must fill \"Your Email\" address !");
		return false;
	}
	if(wrong) {
		alert("You must fill \"Friend's Email\" address !");
		return false;
	}
	gE("tableMail2").style.display	=	"";
	gE("tableMail").style.display	=	"none";

	return			true;
}
function	addToPlayList() {
	setCookiePl(cSongId);
}

function ucwords(str) {
     return str.toLowerCase().replace(/\w+/g,function(s){
          return s.charAt(0).toUpperCase() + s.substr(1);
     })
}

function getLink13() {
		return		"<style>li {padding:5px 0px}</style><style>.hov:hover{background-color:yellow}</style><div id='Title' style='font:bold 11px verdana'><h1 style='font:bold 13px;display:inline'>Watch Videos:</h1><a class='hov' title='Click here to play video' style='display:block;width:300px;border:solid 2px black;padding:10px' href=\"http://www.videocodezone.com"+chSong+"\" target='_blank'>"+ucwords(cSongName)+" ("+ucwords(cBandName)+")</a> <a href='http://www.videocodezone.com/' >Video Codes by VideoCodeZone.Com</a></div>";
}
function getLink1() {
	var	check	=	document.formPlayList.chbox.checked;
	var	check3	=	document.formPlayList.chbox3.checked;

	var	t		=	check?"autostart='true'":"autostart='false'";
	var	t2		=	check3?cSongName+" ("+cBandName+")<p>":"";
		t		=	"<style>.hov:hover{background-color:yellow}</style><div id='Title' style='font:bold 11px verdana'><a class='hov' style='display:block;width:300px;border:solid 2px black;padding:5px' href=\"http://www.videocodezone.com"+chSong+"\" target='_blank'>"+t2+"<embed name='RAOCXplayer' src='http://www.videocodezone.com"+cASX+"' type='application/x-mplayer2' width='300' height='300' "+t+" ShowControls='1' ShowStatusBar='0' loop='true' EnableContextMenu='0' DisplaySize='0' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/'></embed></a><p style=\"margin:3px 0px\"><a href='http://www.videocodezone.com/'>Video Code provided by VideoCodeZone.Com</a></p></div>";

		return		t;
}

function setTxtArea2() {
	var	check				=	document.formPlayList.chbox2.checked;
	var tA					=	document.formPlayList.link1;
		if(check)	tA.value=	getLink13();
		else		tA.value=	getLink1();
}
function setTxtArea() {
	var	check			=	document.formPlayList.chbox2.checked;
	if(!check) {
		var	tA			=	document.formPlayList.link1;
			tA.value	=	getLink1();
	}
}