﻿function valPwd(source, arguments)//Password Length Validation
{
  if(arguments.Value.length > 5)
       arguments.IsValid = true;
  else
       arguments.IsValid = false;
}
function valMessageTxtMIN(source, arguments)//Checking length of MessageUs Box(Minimum Length)
{
  if(arguments.Value.length > 9)
       arguments.IsValid = true;
  else
       arguments.IsValid = false;
}
function valMessageTxtMAX(source, arguments)//Checking length of MessageUs Box(Maximum Length)
{
  if(arguments.Value.length < 251)
       arguments.IsValid = true;
  else
       arguments.IsValid = false;
}
function valStatus(source, arguments)//Checking Status Text in GridView
{
  if(arguments.Value=='Active')
       arguments.IsValid = true;
  else if(arguments.Value=='InActive')
       arguments.IsValid = true;
  else if(arguments.Value=='Closed')
       arguments.IsValid = true;
  else
       arguments.IsValid = false;
}
function valLanguage(source, arguments)//Checking Language Text in GridView Edit Mode[Admin-->Movies.aspx]
{
  if(arguments.Value=='Telugu')
       arguments.IsValid = true;
  else if(arguments.Value=='Hindi')
       arguments.IsValid = true;
  else if(arguments.Value=='Tamil')
       arguments.IsValid = true;
  else
       arguments.IsValid = false;
}
function valtheLanguage(source, arguments)//Checking Language Text in GridView Edit Mode[Admin-->Downloades.aspx]
{
  if(arguments.Value=='Telugu')
       arguments.IsValid = true;
  else if(arguments.Value=='Hindi')
       arguments.IsValid = true;
  else if(arguments.Value=='Tamil')
       arguments.IsValid = true;
  else if(arguments.Value=='English')
       arguments.IsValid = true;
  else if(arguments.Value=='Instrumentals')
       arguments.IsValid = true;
  else
       arguments.IsValid = false;
}
function valVideoType(source, arguments)//Checking VideoType Text in GridView Edit Mode [Admin-->OnlineVideos.aspx]
{
  if(arguments.Value=='MovieSongs')
       arguments.IsValid = true;
  else if(arguments.Value=='ArchestraSongs')
       arguments.IsValid = true;
  else if(arguments.Value=='SoloSongs')
       arguments.IsValid = true;
  else if(arguments.Value=='MovieClips')
       arguments.IsValid = true;
  else if(arguments.Value=='CricketVideos')
       arguments.IsValid = true;
  else
       arguments.IsValid = false;
}
function valMp3MovieName(source, arguments)//Do not Allow These Charactor
{
  var myRegExp = /\'/;
  var matchPos1 = arguments.Value.search(myRegExp);
  if(matchPos1 != -1)
	arguments.IsValid = false; 
  else
	arguments.IsValid = true;
}
function valMatchType(source, arguments)//Checking MatchType in GridView Edit Mode
{
  if(arguments.Value=='Test')
       arguments.IsValid = true;
  else if(arguments.Value=='ODI')
       arguments.IsValid = true;
  else if(arguments.Value=='T20')
       arguments.IsValid = true;
  else
       arguments.IsValid = false;
}
function valAnswerType(source, arguments)//Checking Answer Tyoe in QuizEdit Mode
{
  if(arguments.Value=='A')
       arguments.IsValid = true;
  else if(arguments.Value=='B')
       arguments.IsValid = true;
  else if(arguments.Value=='C')
       arguments.IsValid = true;
  else if(arguments.Value=='D')
       arguments.IsValid = true;
  else
       arguments.IsValid = false;
}
function Srikanth(source, arguments)//Date Calculation
{
   var v1 = arguments.Value
   var regEx=/^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;//Date Validation
   var regEx2 = /^\b\d{1,2}[\/]\d{1,2}[\/]\d{4}\b$/;  
  
   if(!v1.match(regEx))
      arguments.IsValid = false;
   else if(!v1.match(regEx2))
      arguments.IsValid = false;
   else
      arguments.IsValid = true;
}
function GetImgSizeAndType(source, arguments)//Image Validation
		{
			//var str1=document.getElementById(objFileName).value;
			var str1=arguments.Value;
			var str2=str1.split(".")
			var str3=str2.length;
			var Extension=str2[str3-1];//Extension Type
		
			var pic1      =  new Image();
			pic1.src	  =  str1;
			var imgHeight =  pic1.height;//Height of Image
			var imgWidth  =  pic1.width;//Width of Image
			
			if(str1="")
			{
				alert("No Image has given...")
				arguments.IsValid = false;
				return false;
			}
			else if((imgWidth > "190")||(imgHeight > "447"))
			{
				alert("Image Height should < 447 and Width should < 190");
				arguments.IsValid = false;
				return false;
			}
			else if ((Extension != "gif")&&(Extension != "jpg")&&(Extension != "JPG")&&(Extension != "GIF")&&(Extension != "jpeg")&&(Extension != "JPEG"))
			{
				alert('Image should be in .gif /.jpg /.jpeg format');
				arguments.IsValid = false;
				return false;
			}
			return true;
		}

function TdTextFormating(ObjTblName,objSplitStr,objColNum)
{//Makeing Bold Of First Item In the Td
    var table = document.getElementById(ObjTblName);
    var Trs = table.getElementsByTagName('tr');
    for (var i=0; i<Trs.length; i++)
    {
        if((Trs[i].className=="GridItemCls")||(Trs[i].className=="GridAltItemCls"))
        {
            var Temp=Trs[i].getElementsByTagName('td')[objColNum].innerHTML;
            var Temp1=Temp.split(objSplitStr);
            var FirText=Temp1[0];
            var LastText=Temp1[Temp1.length-1];
            var FirstSplitText=Temp.substring(0,3);
            var LastSplitText=LastText.substring(0,3);
                                  
            
            if (((LastSplitText != '<b>')&&(LastSplitText != '<B>'))&&((FirstSplitText != '<b>')&&(FirstSplitText != '<B>')))
            {
                 if ((FirstSplitText != '<b>')&&(FirstSplitText != '<B>'))
                 {
                     var NewFirstText="<b>" +FirText + "</b>";
                     Trs[i].getElementsByTagName('td')[objColNum].innerHTML=Temp.replace(FirText, NewFirstText);
                 }
            }
            else if ((LastSplitText != '<b>')&&(LastSplitText != '<B>'))
            {
                 var NewLastText="<b>" +LastText + "</b>";
                 Trs[i].getElementsByTagName('td')[objColNum].innerHTML=Temp.replace(LastText, NewLastText);
            }
            else
            {
                 if(navigator.appName == "Microsoft Internet Explorer")
                 {     
                    Trs[i].getElementsByTagName('td')[objColNum].innerHTML=Temp.replace("<B>", "");
                 }
                 else
                 { 
                    Trs[i].getElementsByTagName('td')[objColNum].innerHTML=Temp.replace("<b>", "");
                 }
            }
            
         }
     }
 }
 
 
 
       

