
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 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'); 
}

}


// 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




