function showpop(obj1,obj2){
document.getElementById("pop").innerHTML="<ul class='list1'><FORM name='ALLTIMETOP5FORM'>"+document.getElementById("top5").innerHTML+"</form></ul>";
obj2.style.background="#fff";
obj2.style.border="1px solid #666";
obj1.style.border="1px solid #666";
obj2.style.borderBottom="0px solid #666";
obj2.style.color="#777";
obj1.style.color="#fff";
obj2.style.borderLeft="0px solid #666";
obj1.style.background="#666";
}
function showfeat(obj1,obj2){

document.getElementById("pop").innerHTML="<ul class='list2'><FORM name='omSongsList'>"+document.getElementById("recentupdate").innerHTML+"</form></ul>";
obj2.style.background="#fff";
obj2.style.color="#777";
obj1.style.color="#fff";
obj1.style.border="1px solid #666";
obj2.style.border="1px solid #666";
obj2.style.borderBottom="0px solid #666";
obj2.style.borderRight="0px solid #666";
obj1.style.background="#666";

}


var albumName="";
function openCommentWin(url,ind) {

if (ind ==1) {
window.open(url,"RegistrationWin","height=460,width=500,scrollbars=no,resizable=no,toolbar=no,status=no");

}else {

window.open(url,"suggestWin","height=400,width=500,scrollbars=no,resizable=no,toolbar=no,status=no");

}

}
function openAlbum(albumId){
var strURL ="/OMAlbums/GetSongsFromAlbum.php?aid="+albumId;
document.location.href=strURL;
//window.open(strURL,"OMAlbum","height=460,width=500,scrollbars=yes,resizable=no,toolbar=no,status=no");
}
function ManageAlbum(){
var strURL ="/OMAlbums/ManageAlbum.php";
document.location.href=strURL;
//window.open(strURL,"OMAlbum","height=350,width=500,scrollbars=no,resizable=no,toolbar=no,status=no");
}


function createCookie(name,value,days,domain)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/" + ((domain) ? "; domain=" + domain : "") ;

}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (readCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function clearPlayList(){
var songs = readCookie('songsCook');
var totalSongs = readCookie('totalSongs');
if (songs=="" || songs==null){
   alert('There are no songs in your Play List'); 
      
}else {
  // delete the cookies
  if(confirm("Are U Sure Removing Your Play List")){
    deleteCookie('songsCook',"/",false);
    deleteCookie('totalSongs',"/",false);
    ResetCheckBoxes(false);
  } 

}
 
} // end of function

function playPlayList(){
var strURL="/omplayer/media.php?";
var playListURL = formURLFromPlayList();
  if (playListURL !="" && playListURL !=null){
    strURL = strURL+ playListURL;
    createCookie('OMPLOC',readCookie('OMPlayer'),0,'.odiamusic.com');
    window.open(strURL,"omplayer","height=242,width=450,scrollbars=no,resizable=no,toolbar=no,status=no");
    
  }else{
    alert ('No song in your Play List !! Add songs to Play List and retry');
  }
} // end of function

function saveCheckedSongs(){
var did=0;
var w ="omSongsList";
var songs = readCookie('songsCook');
var totalSongs = readCookie('totalSongs');
var playListExists =0;
if (songs == null){
   songs ='0';
   totalSongs ='0';
   playListExits =0;
} else {
  playListExists =1;

}
// read all the checked songs...from the documents.

     for(i=0;i<document[w].elements.length;i++){
      if(document[w].elements[i].checked){
        did =1;
        songs += ',' + document[w].elements[i].value;
        totalSongs = parseInt(totalSongs) + 1;
      } // if block
     } // for loop
   
    if(parseInt(totalSongs)  > 10 ) {
      alert(" You Can't choose more than 10 Songs ");
        
    } else {
     
       if(did) {
       // update the cookie
          createCookie('songsCook',songs,0,'.odiamusic.com');
          createCookie('totalSongs',totalSongs,0,'.odiamusic.com');
          if(!playListExists) {
           alert('A New PlayList Has Been Created \nAnd Songs Are added');
           ResetCheckBoxes(false); 
          }
          else {
           alert('Your Song(s) are Added to PlayList');
           ResetCheckBoxes(false);
          }
       }else {
           alert("Please select atleast one song to add to PlayList"); 
       }
       
    }

}


function openMailSongWin(id) {
var url;
url = "/MailSong.php?id="+id;
window.open(url,"MailSongWin","height=350,width=500,scrollbars=no,resizable=no,toolbar=no,status=no");

}


function formURLFromPlayList(){
  var urlStr="";
  var songs = readCookie('songsCook'); 
  if (songs !=null) {
   var myString = new String(songs);
   var splitString = myString.split(",");
   for (i=1 ; i < splitString.length ; i++){

    urlStr +="pl"+i+"="+splitString[i]+"&";

   }
   return urlStr;
  } else {
  
   return "";

  }
  

}

function openCommentWinGet(var1,queryString) {
var url;
if (var1== 1 ) {
   url = "/CommentForm.php?"+queryString;
   window.open(url,"commentWin","height=270,width=470,scrollbars=no,resizable=no,toolbar=no,status=yes");
} else {
url = "/ReadComment.php?"+queryString;
window.open(url,"readCommentWin","height=500,width=550,scrollbars=yes,resizable=no,toolbar=no,status=yes");

}

}



// Function for  adding songs to the albums

function addSongsToAlbum(var1){
var strURL;
	strURL="/OMAlbums/AddSongAlbum.php?";
      var w ="omSongsList";
      var did=0;
      var aid="";
if (!var1) {
  for(i=0;i<document[w].elements.length;i++){
   if(document[w].elements[i].checked ){
   
       if ( document[w].elements[i].type=="checkbox") {
         did=1;
         strURL += document[w].elements[i].name+'='+document[w].elements[i].value+'&';
       }else if ( document[w].elements[i].type=="radio") {
         aid = document[w].elements[i].value;
       }     
     }
   }
// create the album cookie for the same.
  if ( did==1) { 
   
   if ( aid !="")
    createCookie('aid',aid,0,'.odiamusic.com');
   else {
    alert("Please select the Album to which you want to add songs");
    return;
   }
  }
}

if(did || var1){
if(var1)
strURL="/OMAlbums/AddSongAlbum.php?";
//window.open(strURL,"OMAlbum","height=400,width=500,scrollbars=yes,resizable=no,toolbar=no,status=yes");


document.location.href=strURL;
}else{
   alert("Please select atleast one song to add to your Album");
}

}


// Function for reseting the checkboxes
function ResetCheckBoxes(value) {
var w ="omSongsList";
     for(i=0;i<document[w].elements.length;i++){
      if (document[w].elements[i].type =="checkbox")
          document[w].elements[i].checked=false;
   }
}

 
function openOMWin(url,width,height){
var winName = "OMWin"+ width + height ;
var winObj = window.open(url,winName,'height='+height+',width='+width+',scrollbars=no,resizable=no,toolbar=no,status=no');
if (winObj ==null){
alert('Please Switch off the Pop-up Blocker of your browser and Retry'); 
}
}


function openOMWinScroll(url,width,height){
var winName = "OMWin"+ width + height ;
var winObj = window.open(url,winName,'height='+height+',width='+width+',scrollbars=yes,resizable=no,toolbar=no,status=no');
if (winObj ==null){
alert('Please Switch off the Pop-up Blocker of your browser and Retry'); 
}

}

function SelectAllSongs() {
var w ="omSongsList";
     for(i=0;i<document[w].elements.length;i++){
      if (document[w].elements[i].type =="checkbox")
          document[w].elements[i].checked=true;
   }
}

// function to add items to cart
function addAlbumToCart(itemId){

var omCartCook = readCookie('OMCART');
var cookieValue = "";

var playListExists =0;
if (omCartCook == null){
     cookieValue = itemId;
   } else {
     cookieValue  = omCartCook + "," + itemId ;

   }
createCookie('OMCART',cookieValue,0);
alert('This Album is added to your OM Shop Cart');
}

function searchSong(){
if (document.findSong.sc.value.length > 0)
document.findSong.submit();
else
alert('Please type in for a song');
}


// input param : form name and emailid
function validateData(w,e){
did=0;

  for(i=0;i<document[w].elements.length;i++){
    if(document[w].elements[i].value.length <=0 ){
     alert('Invalid Data !! Please Retry');
     document[w].elements[i].focus();
     did=0;  
     break;
    }else{
     did=1;
    }
  }

if(did) {

if(e==null) return true;

if(ValidateForm(w,e) )
return true;
else 
return false;
}


}// function closing bracket



function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}


//Functin to validate email id data

function ValidateForm(w,e){
        
	var emailID=document[w].elements[e];
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }


// Function to validate Password
function validatePassword(w){
 if(document[w].pwd.value.length > 5 && document[w].pwd.value.length < 11 ) {
   if (document[w].pwd.value == document[w].pwd2.value) { 
    return true;
   }else {
   alert ("Password & Confirm password doesn't match"); 
    return false;
   }
 }else {
  alert ("Password must be 6 to 10 Char Long");
  return false;
 }
}


function performCookieTest(cookieName){
var testCookie = readCookie(cookieName);
 if (testCookie ==null || testCookie==""){
   alert ('You must enable the cookie feature of your browser. Click FAQ Section for information');
 }
}




function addfav(){
if (document.all)
window.external.AddFavorite("http://www.odiamusic.com","ODIA Music");
else if (window.sidebar)
window.sidebar.addPanel("ODIA Songs & Music", "http://www.odiamusic.com", "")
}


// functions to find the value of checked radio buttons




