<!--

 function SelectAll(x,v) {   
  var oFrm;
  //if (!v) v=true;
  if (!x) x = 'raaga';
  
  if (document.getElementById(x) && document.getElementById(x).nodeName == 'FORM') {
  	oFrm = document.getElementById(x)
  }  
  
  //alert(v);alert(x);alert(oFrm);
  if (oFrm){
	  for (var i=0;i<oFrm.elements.length;i++) { 
		var flds = oFrm.elements[i]; 		
		//alert(flds.name);
		if ((flds.name != 'loop') && (flds.name !='random') && (flds.name !='append') && (flds.name !='selectall')) 
			flds.checked = v;		
	  } 
   }
}


 function InvertSelect(x) { 
  var oFrm;
    if (!x) x = 'raaga';
    if (document.getElementById(x) && document.getElementById(x).nodeName == 'FORM') {
    	oFrm = document.getElementById(x)
    }  		  
  if (oFrm){
	  for (var i=0;i<oFrm.elements.length;i++) 
		{ 
		var flds = oFrm.elements[i]; 
		if ((flds.name != 'loop') && (flds.name !='random') && (flds.name !='append') && (flds.name !='selectall')) {

		  if (flds.checked == 1){
			flds.checked = 0
		  } else {
			flds.checked = 1
		  }
		}


		} 
	}
  } 

var c = 0;
var songlist = new Array;

function getList() {
	getTracks();
	if (c <1){
		SelectAll('raaga',true);
		getTracks();
	} 
	
	if (c) {
		setList();
	}		
}

function getTracks(){
	theForm = this.document.raaga
	if (document.raaga) {
	for (var i=0;i<document.raaga.elements.length;i++) {
		if (document.raaga.elements[i].name == 'pick') {
			if (document.raaga.elements[i].checked) {
			 songlist[c] = document.raaga.elements[i].value;
			 c++;
			}
		}
        }
        }
}

function getDLPids(){
	var pcid = 0;
	var pidList = new Array;
	theForm = this.document.raaga
	if (document.raaga) {
	for (var i=0;i<document.raaga.elements.length;i++) {
		if (document.raaga.elements[i].name == 'dlpid') {
			if (document.raaga.elements[i].value > 0) {
			 pidList[pcid] = document.raaga.elements[i].value;
			 pcid++;
			}
		}
        }
        }
        return pidList;
}


function checkList(){
	SelectAll('raaga',true);
	getList();
}


function setList(){
	sel = songlist[0];
	for (var j=1;j<c;j++) {
		sel += ','+songlist[j];
	}
	//loadClip(sel);
	setList1(sel);
	sel='';
	c=0;	
}


function setList1(x){
	//loadClip(x);
	winW = plyrW;
	winH = plyrH;
	var liststr = plV4Url + '?id='+x+'&mode=100&rand='+Math.random();
    winHandle = doWin(liststr, plyrWin);	
}

function pickThis(x){

	pick = document.raaga.pick;
	pick1 = document.raaga.pick1;
	pickLen = pick.length;

 if( pickLen > 1){
	for(i=0;i<pickLen;i++){
	  if(pick[i].value == x){
		pick1.value=x;
		document.raaga.submit();
		return createTarget(document.raaga);
	  }
	}
 } else {
	pick1.value=x;
	document.raaga.submit;
	return createTarget(document.raaga);
 }
return false
}

function playVideo(x,u){
	var url;
	url = homeUrl + "igc-video.asp?pick=" + x
	popWin(url, u + " Video - Powered by IGCinema.com", 600, 450)
}


function loadVidClip(x,y){
	if (document.getElementById('videoTitle')){
		document.getElementById('videoTitle').scrollIntoView(true);
		document.getElementById('videoTitle').innerHTML = y;
	}
	loadVid(x);
}


function saveList() {
	getTracks();
	if (c <1){
	    alert('Select the songs to add to your collection!');
	}
	else{
	    openAddWin();
	}
}

function saveQLList(ids) {
	liststr = homeUrl+'saveQL.asp';
	sel='';
	c=0;
	popWin(liststr, "My Raaga - Save Quicklist", 400, 450);	
}

function clrQL(){
	if (confirm("This will clear your QuickList. Do you wish to continue?")){
		window.location = homeUrl + "ql-refresh.asp"
	}
}

function openAddWin(){
    sel = songlist[0];
    for (var j=1;j<c;j++) {
		sel += ','+songlist[j];
    }
	liststr = base_url+'channels/myraaga/addToUser.asp?id='+sel;
	sel='';
	c=0;
	
	popWin(liststr, "My Raaga - Add to Playlist", 600, 450);
}

function saveClip(id){

	if (id == '' ){
        	sel = songlist[0];
        	for (var j=1;j<c;j++) {
			sel += ','+songlist[j];
        	}
        } else {
        	sel = id;	
        }
	liststr = myRaagaUrl +'addToUser.asp?id='+sel;
	sel='';
	c=0;
	
	popWin(liststr, "My Raaga - Add to Playlist", 600, 450)
	//messageObj.setSize(400,450);
	//displayMessage(liststr);
	//winW = 400;
	//winH = 450;

        //MyRaaga = doWin(liststr,'MyRaaga');
}


function validate(form){
	theForm = this.document.raaga
        for (var i=0;i<document.raaga.elements.length;i++) {
                if (document.raaga.elements[i].name == 'pick') {
                        if (document.raaga.elements[i].checked) {
                         songlist[c] = document.raaga.elements[i].value;
                         c++;
                        }
                }
        }
	if (c < 1)
		SelectAll('raaga',true);	
	getList();
	return false;
}

function gotoPage(frmName, pageNum){

	frmObj = eval('document.'+frmName)
	if (frmObj && frmObj.whichpage){
		frmObj.whichpage.value = pageNum;
		frmObj.submit();
	} else {
		return false;
	}	
}

/*function mailSong(x){  
	listStr = 'mailclip.asp?id='+x;
        rmail = window.open (listStr,'rmail','width=400,height=450,resizeable=yes,scrollbars=no,status=no');
}*/

function doSearch(frm){
	
	var actionURL = '';
	lang   = frm.Lang;
	langInd = lang.selectedIndex;
	
	var langDir = new String(lang.options[langInd].text);	
	actionURL = base_url+'channels/'+langDir.toLowerCase()+'/searchresults.asp';
	
	if (actionURL == '' ){
		alert('Please select a language and try again!');
	}
	
	kw = frm.search.value;

	if (kw != '' && kw.length >= 2){
		frm.action = actionURL;
		frm.submit();
	} else {
		alert('Search term needs to have 2 or more letters! Please try again');
	}
}

function selectQL(ids) {
	if (!ids) {
		ids = '';
		getTracks();
		if (c < 1) {
		  if (confirm("Do you wish to add all the tracks to your 'Quicklist'?") ){
			SelectAll('raaga',true);
			getTracks();
		  } else { return; }			
		}
		for (var j=0;j<c;j++) {
			if (j==0)
				ids += songlist[j];
			else
				ids += ','+songlist[j];
		}
	}	
	sel='';
	c=0;
	ajax_loadContent('refreshQLDiv',homeUrl+'addQL.asp?ids='+ids);
	loadClip(ids);
	//alertMsg(qlAddMsg, homeUrl + "msg-quicklist.asp");
}

function rcntP(ids) {
	if (ids == '' )
	getTracks();
	if (ids != '') {
		ajax_loadContent('rcntP',base_url+'channels/home/rcntP.asp?ids='+ids); 
	}	
}

function loadQL(){
	ajax_loadContent('refreshQLDiv',base_url+'channels/home/addQL.asp'); 
}

function modQLList(){
	url = homeUrl +'manageQL.asp?rand='+Math.random()
	popWin(url, "My Quicklist", 590, 500)
}

function openQL(){
	winW = plyrW;
	winH = plyrH;
	
	mode = 0;
	liststr = base_url+'channels/home/openQL.asp';
	    
	sel='';
	c=0;
	rjb = doWin(liststr,plyrWin);
}

function removeQL(){
	var oForm = this.document.rMgrQL;
	var isSelected = '';
	if (oForm.pick){
		for (i=0; i < oForm.pick.length; i++){
			if (oForm.pick[i].checked)
				isSelected = true;

		}

		if (!isSelected) {
			alert('Please select the tracks to be removed and try again');
			return;
		}
		//oForm.target = 'remQLFrme1'
	}
}

var winHandle = null;
var plyrW, plyrH, plyrWin;

plyrW=728; plyrH=663;
plyrWin = 'raaga_media_player_popup';

function loadClip(id){

    winW = plyrW;
    winH = plyrH;
    
    var liststr = plV4Url + '?id='+id+'&mode=100&rand='+Math.random();
    if (winHandle) {
        if ( winHandle.closed ) {
            winHandle = open( liststr, plyrWin, 'toolbar=no,width=728,height=663,status=no,scrollbars=no, resize=no, menubar=no,location=no' );
            winHandle.focus();
        } else {
            winHandle.frames[2].location = plV4Url +'check.asp?id='+id
            alertFtMsg("Track(s) queued to player window!");
        }
    } else {
		winHandle = doWin('', plyrWin);
		wL = new String(winHandle.location);
		pL = new String(parent.location);
		
		if ((winHandle.location == 'about:blank') || (wL.toLowerCase() == pL.toLowerCase())) { // this solution is bound to break at some point, maybe other browsers have a different default Location (URL)
			try{
            	winHandle.location = liststr;
            } catch(e){
            	winHandle = window.open('', plyrWin);//FIX FOR IE8
            	//winHandle.location.href = liststr;
            }
            winHandle.focus();
        } else {
            winHandle.frames[2].location = plV4Url +'check.asp?id='+id
            alertFtMsg("Track(s) added to the player!");
        }
    }
}


function loadAlbum(aId,t){
    winW = plyrW;
    winH = plyrH;
    
    var liststr = plV4Url + 'album.asp?mid='+aId+'&t='+t+'&mode=100&rand='+Math.random();
    if (winHandle) {
        if ( winHandle.closed ) {
            winHandle = open( liststr, plyrWin, 'toolbar=no,width=728,height=663,status=no,scrollbars=no, resize=no, menubar=no,location=no' );
            winHandle.focus();
        } else {
            winHandle.frames[2].location = liststr +'&ck=1'
            alertFtMsg("Track(s) queued to player window!");
        }
    } else {
		winHandle = doWin('', plyrWin);
		wL = new String(winHandle.location);
		pL = new String(parent.location);
		
		if ((winHandle.location == 'about:blank') || (wL.toLowerCase() == pL.toLowerCase())) { // this solution is bound to break at some point, maybe other browsers have a different default Location (URL)
			try{
            	winHandle.location = liststr;
            } catch(e){
            	winHandle = window.open('', plyrWin);//FIX FOR IE8
            	//winHandle.location.href = liststr;
            }
            winHandle.focus();
        } else {
            winHandle.frames[2].location = liststr +'&ck=1';//plV4Url +'checkAlbum.asp?id='+id+"&t="+t
            alertFtMsg("Track(s) added to the player!");
        }
    }
}


function playAlbum(aId,t){  
   var pAU;pAU = plV4Url +'album.asp?mid='+aId;if (t) pAU = pAU + '&t='+t;winW=plyrW;winH=plyrH;doWin(pAU,plyrWin);//chckPlWin(pAU);
}

function saveAlbum(aId,t){
	var liststr = homeUrl + "saveAlbum.asp?mid="+aId+"&a=1";if (t) liststr = liststr + '&t='+t;popWin(liststr, "My Raaga - Add to Playlist", 600, 450);
}

function quicklistAlbum(aId,t){
	var liststr = homeUrl + "saveAlbum.asp?mid="+aId+"&a=2";
	if (t) liststr = liststr + '&t='+t;
	ajax_loadContent('refreshQLDiv',liststr);
	loadAlbum(aId,t);
	//alertFtMsg("Album added to QuickList!");
}

function quicklistPL(pId){
	var liststr = homeUrl + "savePL_QL.asp?plId="+pId;
	ajax_loadContent('refreshQLDiv',liststr);
	loadAlbum(pId,'PL');
}

function embedAlbum(x,n){
	var t;if (n) { t = "Embed " + n +" - Preview";} else {t = "Embed Album - Preview";}
	var aU = homeUrl +"album-embed.asp?isF=T&aid="+x;popWin(aU, t, 650, 450);
}

function shareAlbum(x,t){
	//aU = homeUrl +"album-embed.asp?"+x;
	//popWin(aU, 'Embed Album - Preview', 650, 450);
	alert("Coming soon");
}

function addFullAlbum(a,an,t){
	var url = shop_url + 'addAlbum.asp?aid='+a;if (t) url = url + '&t='+t;popWin(url, "Download "+an, 524, 230);
}

function addAlbum(){
	var pidList = getDLPids();addTracks(pidList);
}


function playPublicPl(i){
	var u;winW = plyrW;winH = plyrH;
   	u = plV4Url + 'public-pl.asp?mid='+i;
   	doWin(u,plyrWin);
   	//chckPlWin(u);   	
}

function playFavs(){
	var u;winW = plyrW;winH = plyrH;
   	u = plV4Url + 'favorites.asp';
   	doWin(u,plyrWin);
}


function chckPlWin(u){
	winW = plyrW;
	   winH = plyrH;	
	
	   if (winHandle) {
	        if ( winHandle.closed ) {
	            winHandle = open( u, plyrWin, 'toolbar=no,width=728,height=663' );
	            winHandle.focus();
	        } else {
	            winHandle.frames[2].location = u +'&ck=1';
	            alertMsg(plAddMsg, homeUrl + "msg-playadd.asp");
	            //winHandle.focus();            
	        }
	    } else {
		winHandle = doWin('', plyrWin);
		wL = new String(winHandle.location);
		pL = new String(parent.location);
		if ((winHandle.location == 'about:blank') || (wL.toLowerCase() == pL.toLowerCase())) { // this solution is bound to break at some point, maybe other browsers have a different default Location (URL)
	            winHandle.location = u;
	            winHandle.focus();
	        } else {
	            winHandle.frames[2].location = u +'&ck=1';
	            alertMsg(plAddMsg, homeUrl + "msg-playadd.asp");
	            //winHandle.focus();
	        }
    }
}

function searchArtistPL(a){
	winW = plyrW;
   	winH = plyrH;
   	if (!a) {
   		if (document.getElementById('plSrchFld')){
   		a = document.getElementById('plSrchFld').value;
   		
   		lO = document.getElementById('plSrchLangFld')
   		l  = lO.options[lO.selectedIndex].value;
   		//bO = document.getElementById('plSrchByFld')
   		//b  = bO.options[bO.selectedIndex].value;
   		gO = document.getElementById('plSrchGenreFld')
   		g  = gO.options[gO.selectedIndex].value;
   		
   		}
   	}
   	if (a==""){
   		alert("Enter a valid search term and try again!")
   		return;
   	}
	doWin(plV4Url +'search-pl.asp?a='+a+'&l='+l+'&g='+g)
}

function makePublic(cid){	
	url = myRaagaUrl + 'publish_pl.asp?cid='+cid;
	popWin(url, "My Raaga - Make Playlist Public", 524, 230)
	//messageObj.setSize(504,180);
	//displayMessage(url);
}

function addTracks(x){
	if (x == '') {
		alert("Downloads not currently available for the tracks selected");
		return;
	}
	
	popWin(shop_url + 'addTracks.asp?pids='+x, "Downloading Album", 524, 230)
}

function addTrack(x){
	if (x == '') {
		alert("Please select a track to download");
		return;
	}	
	popWin(shop_url + 'addTrack.asp?productId='+x, "Downloading Track", 524, 230)
}

function launchPlayer(x){setList1(x)}

function launchPL(cidV){
	winW = plyrW;
	winH = plyrH;

	if (!cidV) {
		cidV = getCIDV();
	}
	
	if (cidV && cidV != "-1" && cidV != "-2" ){
		doWin(plV4Url+'launchPL.asp?cid='+cidV,plyrWin);
	} else {
		alert("Please select a playlist and try again");
	}
}

function previewPL(dId, cidV){
	if (document.getElementById(dId)){
		if (!cidV) cidV = getCIDV();
		if (cidV && cidV != "-1" && cidV != "-2" ){
			toggleSlideAjax(dId,'viewplsummary.asp?dId='+dId+'&cid='+cidV,550,350);
		} else {
			alert("Please select a playlist to preview");
		}
	}
}

function getCIDV(){
	var cidV1
	var cid = document.getElementById("cidDD");	
	if (cid.value){
		cidV1 = cid.value
	} else {
		cidV1 = cid.options[cid.selectedIndex].value
	}
	return cidV1
}

function publishPL(){
	var cid = document.getElementById("cidDD");
	var cidMode = document.getElementById("cidMode");
	var cidV;
	if (cid.value){
		cidV = cid.value
	} else {
		cidV = cid.options[cid.selectedIndex].value
	}
	
	var cidModeV = cidMode.options[cidMode.selectedIndex].value;
	if (cidV != "" && cidModeV != "" ){
		document.getElementById("makePblcFrme").src = "publish_pl_post.asp?cid="+cidV+"&cidMode="+cidModeV;
	} else {
		alert("Please select a valid collection and try again");
	}
}

function alertMsg(x,u){
	if (x){
		var a = readCookie(x);
		if (a!="true"){
			messageObj.setSize(500,250);
			displayMessage(u);
		}
	}
}

function alertFtMsg(m){
	var msgftraltdiv = document.getElementById('msgftraltdiv');
		if (msgftraltdiv){
			msgftraltdiv.style.display = 'block';
			msgftraltdiv.innerHTML = '<span class="black">'+ m +'</span>'
			blinkit('msgftraltdiv');
			setTimeout("hideFtAlertMsg()",15000)
	}
}

function hideFtAlertMsg(){ if (document.getElementById('msgftraltdiv')) msgftraltdiv.style.display = 'none';}

function setMsgFlag(x,y) {
	if(x){
		createCookie(x,y,365);
	}
	closeMessage();
}

function validateInvite(x){
  var selUsr;
  selUsr = 0;
  if (x){
	  for (var i=0;i<x.elements.length;i++) { 
		var flds = x.elements[i]; 		
		if (flds.name == 'selUsr' && flds.checked) 
			selUsr = 1;
	  } 
   }
   if (selUsr == 0){
   	alert("Select a friend and try again");
   	return false;
   } else {
   	x.submit();
   }
	
}
//-->
