
//************************************************************************
//Project: Indian-Music.com
//Author: Gudipudi Srikanth
//Program Name: Validations
//Purpose of file: To Check/Validate the user entry in while filling forms
//Date: Sunday, October 28, 2001
//************************************************************************






function vmail(text)
{
	var flag=true;
	var flag1=0
	var flag3
	var l=0
	
	flag=valsplchars(text);
	if(flag==false)
		return false;
	if(text.substring(0,1)=="@" || text.substring(0,1)=="." || text.substring(text.length-1,text.length)=="@" ||  text.substring(text.length-1,text.length)==".")
		return false;
	for(i=0;i<text.length;i++){
		if(text.substring(i,i+1)=="@"){
			l=i
			flag1=flag1+1
		}
		if(text.substring(i,i+1)==flag3 && text.substring(i,i+1)==".")
			return false;	
		flag3=text.substring(i,i+1)			
	}
	if(flag1!=1)
		return false;
	l=(text.indexOf(".",l))
	if(l==-1)
		return false
	if(l+3>text.length)
		return false;	
	return(flag);
}

function valsplchars(text)
{	
	
	var flag=true;
	for(j=0;j<text.length;j++)
	{
		if((text.substring(j,j+1)=="!") ||
		   (text.substring(j,j+1)=="~") ||
		   (text.substring(j,j+1)=="#") ||
		   (text.substring(j,j+1)=="$") ||
		   (text.substring(j,j+1)=="%") ||
		   (text.substring(j,j+1)=="^") ||
		   (text.substring(j,j+1)=="'") ||
		   (text.substring(j,j+1)=="&") ||
		   (text.substring(j,j+1)=="*") ||
		   (text.substring(j,j+1)=="(") ||
		   (text.substring(j,j+1)=="|") ||
		   (text.substring(j,j+1)=="=") ||
		   (text.substring(j,j+1)==")") ||
		   (text.substring(j,j+1)=="{") ||
		   (text.substring(j,j+1)=="}") ||
		   (text.substring(j,j+1)=="[") ||
		   (text.substring(j,j+1)=="]") ||
		   (text.substring(j,j+1)==":") ||
		   (text.substring(j,j+1)=="\"")||
		   (text.substring(j,j+1)==",") ||
		   (text.substring(j,j+1)=="<") ||
		   (text.substring(j,j+1)==">") ||
		   (text.substring(j,j+1)=="?") ||
		   (text.substring(j,j+1)=="/") ||
		   (text.substring(j,j+1)=="\\")||
		   (text.substring(j,j+1)=="+"))
		{
			flag=false;
			break;
		}
	}
	return(flag);
	}


	
	function stripSpaces(x) {
    while (x.substring(0,1) == ' ') x = x.substring(1);
    return x;
}

function empty(x) { if (x.length > 0) return true; else return false; }


function tarealength(tareaval) 
{ 
return (tareaval.length) 
}

function countit(what){

//Character count script

formcontent=what.form.content.value
what.form.displaycount.value=formcontent.length
}

//text fading effect on homepage for lyrics

function setupFadeLinks() {
  arrFadeLinks[0] = "http://lyrics.indian-music.com/hindi/";
  arrFadeTitles[0] = "View Hindi and Telugu Lyrics";
  arrFadeLinks[1] = "http://lyrics.indian-music.com/hindi/";
  arrFadeTitles[1] = "Request your Favourite Lyrics";
  arrFadeLinks[2] = "http://lyrics.indian-music.com/hindi/";
  arrFadeTitles[2] = "Submit Lyrics";
  arrFadeLinks[3] = "http://lyrics.indian-music.com/hindi/";
  arrFadeTitles[3] = "Search Lyrics by Category";
  arrFadeLinks[4] = "http://lyrics.indian-music.com/hindi/";
  arrFadeTitles[4] = "Lyricist Profiles";
}

// You can also play with these variables to control fade speed, fade color, and how fast the colors jump.

var m_FadeOut = 255;
var m_FadeIn=0;
var m_Fade = 0;
var m_FadeStep = 3;
var m_FadeWait = 1900;
var m_bFadeOut = true;

var m_iFadeInterval;

window.onload = Fadewl;

var arrFadeLinks;
var arrFadeTitles;
var arrFadeCursor = 0;
var arrFadeMax;

function Fadewl() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
  arrFadeLinks = new Array();
  arrFadeTitles = new Array();
  setupFadeLinks();
  arrFadeMax = arrFadeLinks.length-1;
  setFadeLink();
}

function setFadeLink() {
  var ilink = document.getElementById("fade_link");
  ilink.innerHTML = arrFadeTitles[arrFadeCursor];
  ilink.href = arrFadeLinks[arrFadeCursor];
}

function fade_ontimer() {
  if (m_bFadeOut) {
    m_Fade+=m_FadeStep;
    if (m_Fade>m_FadeOut) {
      arrFadeCursor++;
      if (arrFadeCursor>arrFadeMax)
        arrFadeCursor=0;
      setFadeLink();
      m_bFadeOut = false;
    }
  } else {
    m_Fade-=m_FadeStep;
    if (m_Fade<m_FadeIn) {
      clearInterval(m_iFadeInterval);
      setTimeout(Faderesume, m_FadeWait);
      m_bFadeOut=true;
    }
  }
  var ilink = document.getElementById("fade_link");
  if ((m_Fade<m_FadeOut)&&(m_Fade>m_FadeIn))
    ilink.style.color = "#" + ToHex(m_Fade);
}

function Faderesume() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
}

function ToHex(strValue) {
  try {
    var result= (parseInt(strValue).toString(16));

    while (result.length !=2)
            result= ("0" +result);
    result = result + result + result;
    return result.toUpperCase();
  }
  catch(e)
  {
  }
}


