  
  
  var email = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
  var alphabet=/^[a-zA-Z]+$/;
  var alphanumeric =/^[a-zA-Z0-9 ]+$/;
  var numeric = /^[0-9 ]+$/;
function Redirect(n)
     {
       switch(n)
           {
            case 1:
                window.location ='http://www.hindustandainik.com'
                break
            case 2:
                    window.location ='../HTNext/HTNext.aspx'
               break
            case 3:
                window.location ='http://www.fever.fm/'
                break
            case 4:
                window.location ='http://www.htclassifieds.biz/'
                break
            case 5:
                window.location ='http://www.livemint.com/'
                break
            case 6:
                window.location ='http://4242.in/'
                break
            case 7:
                window.location ='http://www.htsyndication.com/'
                break
 			case 8:
                window.location ='http://www.shine.com/'
                break
            default:
                alert("")
                break
           }
     }

  


//Method To Check Max Number of Characters allowed to type in a textbox  
function checkMaxInput()
{
    var txtcomments=document.getElementById(arguments[0]);
	var lblerrormessage =document.getElementById(arguments[1]);
	var maxLen = arguments[2];
	
	if (txtcomments.value.length > maxLen)
	{
	    txtcomments.value = txtcomments.value.substring(0, maxLen);
	    lblerrormessage.innerHTML = "Maximum " + maxLen + " Characters";
	    lblerrormessage.style.className = "error";
	    lblerrormessage.style.visibility = "visible";
	}
}

//To Validate Email Id
// Argument[0] - Control to validate
// Return - success if correct else retuns failure

function emailvalidation(validate)
{
    var controltovalidate = document.getElementById(validate);
    if(controltovalidate.value.search(email)== -1)
    {   
        return "failure";
    }
    return "success";
}

// To validate alphanumeric values
function alphanumericvalidation(validatename)
{
    var controltovalidatename = document.getElementById(validatename);
    if(controltovalidatename.value.search(alphanumeric)== -1)
    {   
        return "failure";
    }
    return "success";
}

// To validate numeric values
function numericvalidation(validatename)
{
    var controltovalidatenumeric = document.getElementById(validatename);
    if(controltovalidatenumeric.value.search(numeric)== -1)
    {   
        return "failure";
    }
    return "success";
}

// trims the left space of a word
function ltrim(str) 
{ 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}

// subfunction for LeftTrim.
function isWhitespace(charToCheck) 
{
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}

// Trimming botht he side of the word
function Trim(str)
{
    while(str.charAt(0) == (" "))
    {
        str = str.substring(1);
    }
    while(str.charAt(str.length-1) == " " )
    {
        str = str.substring(0,str.length-1);
    }
    return str;
}

/* Accepts a string and  Trimout the whitespaces on left and right of the string completely,
 also reduces the whitespaces to one if more than one space occurs between the words */            
function acceptOneSpaceTrim(sString)
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    while(sString.indexOf("  ")!==-1)
    {
        sString=sString.replace("  "," ");
    }
    return sString;
}

function OpenWindow()
{
    var aspxname;
    aspxname=(arguments[0]);	
    window.open(aspxname,'_parent');
    return false;
}
  
function Checkforhtml(htmlchecking)
{
    var controltovalidatehtml = document.getElementById(htmlchecking);
    var reEval = new RegExp("[\<\>|]", "i");
    blnEval = reEval.test(controltovalidatehtml.value)
    if (blnEval)
    {
        return "failure";
    }
    return "Success";
}



function CheckForAlert(wordtocheck)
{
    if(wordtocheck.indexOf("alert(") == -1)
    {
        return "success";
    }
    return "failure";
}

//sharmila - for tabloid search validation and onclick visible false and reenable the text (agonyaunt and pillow talk
function ValidateEmpty()
{   
    var searchword = document.getElementById(arguments[0]);                      
    var lblsucmsg = document.getElementById(arguments[1]);        
    inti = 0;        
    if(searchword.value =="")
    {
       lblsucmsg.innerHTML = "Please enter the text to Search";            
       lblsucmsg.className = "required";
         inti = inti+1;
    }    
    if(inti>0)
    {        
        return false;
    }
    else
    {
        return true;
    }
}
   
function clickButton(event, buttonid)
{
    var bt = document.getElementById(buttonid);
    if (event.keyCode == 13)
     {
        bt.click();
        return false;
     }                   
}  

function Scriptonfocus(id,text)
{
    var x=document.getElementById(id).value
    if(x==text)
    {
      document.getElementById(id).value="";
    }
}
function ScriptmouseOverOut(id,text)
{
    var x=document.getElementById(id).value
     if(x=="")
     {
        document.getElementById(id).value=text;
    }
}
    
function openwindow(text)
{ 
     var openwindow = window.open("","","height=200,left=400,top=200,width=200,scrollbars=no");
     openwindow.document.write(text);
} 

function openWindowWithLink(link)
{ 
     var openwindow = window.open(link,"","height=500,left=400,top=200,width=500,scrollbars=yes,resizable=yes");
} 

var redirectURL; var redirectTime;
function redirectToPage()
{
    redirectURL = arguments[0];
    redirectTime = arguments[1];
    setTimeout("delayredirect()",redirectTime);
}

function delayredirect()
{
    location.href = redirectURL;
}

