/* Function for login  Starts*/

function LoginCheck(Email,Pwd)
{
	var PostData = "";
	PostData = "EmailID="+Email+"&Password="+Pwd+"&Action=LoginCheck";
	//alert(PostData);
	//WaitDisplay();
	document.getElementById('Wait').style.display='block';
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
				//alert( "Data Saved: " + msg );
				if(parseInt(msg)==1)
				{
					window.location.href='index.php?TabIndex=1';
				}
				else if(parseInt(msg)==5)
				{
					window.location.href='ProfileSetting.php?TabIndex=3';
				}
				else if(parseInt(msg)==2)
				{
					//alert("Activation Pending. Please Activate Your Account");
					document.getElementById('Wait').style.display='none';
					document.getElementById('FunctionalPopupRed').style.display='block';
					document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Activation Pending. Please Activate Your Account.';
					AlignMessageDiv('FunctionalPopupRed');						
				}
				else if(parseInt(msg)==3)
				{
					document.getElementById('Wait').style.display='none';
					document.getElementById('ValError').innerHTML = "Account Suspended";
					document.getElementById('ValError').style.display = "block";
					//window.location.href='SignUp.php';
				}
				else if(parseInt(msg)==4)
				{
					document.getElementById('Wait').style.display='none';
					document.getElementById('ValError').innerHTML = "Invalid Login Details";
					document.getElementById('ValError').style.display = "block";
					//window.location.href='SignUp.php';
				}				
	   }
	 });

}
	
/* Function for login  Ends*/

/* Function for PostLink  Starts*/
function PostLink(Type,Link,Description)
{
	var PostData = "";
	PostData = "Type="+Type+"&Link="+Link+"&Action=PostLink";
	//alert(PostData);
	//WaitDisplay();
	document.getElementById('Wait').style.display='block';
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
				//alert( "Data Saved: " + msg );
				if(msg==1)
				{
					window.location.href='index.php';
				}
	   }
	 });

}
	
/* Function for PostLink  Ends*/

/* Function for Invoking Freinds Select Window for selection Starts*/

function OpenSelectFriend(Link,Dscr,UserID) {
	
	var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z\.]{2,3}/;
	var myRegxp = /^([ \.\,'a-zA-Z0-9_-]+)$/;

	if(Link == "" || Link=="http://")
	{
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Enter Link!';
		AlignMessageDiv('FunctionalPopupRed');
		return false;
	}
	else if(!tomatch.test(Link))
	{
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Invalid Link!';
		AlignMessageDiv('FunctionalPopupRed');
		return false;
	}	
	else if(Dscr!="")
	{
		if(myRegxp.test(Dscr)==false)
		{
			document.getElementById('FunctionalPopupRed').style.display='block';
			document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Please enter only alphanumeric text!';
			AlignMessageDiv('FunctionalPopupRed');
			return false;
		}
		else
		{
			tb_show('Select Friends to ping personally', 'SelectFriends.php?KeepThis=true&height=500&width=800&Link='+Link+'&Dscr='+Dscr+'&UserID='+UserID+'&TB_iframe=false', true);
		}
	}
	else
	{
		tb_show('Select Friends to ping personally', 'SelectFriends.php?KeepThis=true&height=500&width=800&Link='+Link+'&Dscr='+Dscr+'&UserID='+UserID+'&TB_iframe=false', true);
		//window.location.href="index.php?ActiveTitle=Links posted by me&TabIndex=1";
	}
};

/* Function for Invoking Freinds Select Window for selection Ends*/

/* Function for posting link through ajax starts*/

function PostPing(Link,Dscr) {
	//alert(Link+":"+Dscr);
	var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z\.]{2,3}/;
	var myRegxp = /^([ \.\,'a-zA-Z0-9_-]+)$/; 

	if(Link == "" || Link=="http://")
	{
		//alert('Hello World');
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Enter Link!';
		AlignMessageDiv('FunctionalPopupRed');
		return false;
	}
	else if(!tomatch.test(Link))
	{
		//alert('Hello World1');
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Invalid Link!';
		AlignMessageDiv('FunctionalPopupRed');
		return false;
	}	
	else if(Dscr!="")
	{
		//alert('Hello World2');
		if(myRegxp.test(Dscr)==false)
		{
			//alert(Dscr);
			document.getElementById('FunctionalPopupRed').style.display='block';
			document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Please enter only alphanumeric text!';
			AlignMessageDiv('FunctionalPopupRed');
			return false;
		}
		else
		{
			var PostData = "";
			PostData = "Link="+Link+"&Description="+Dscr+"&Type=Normal";
			//alert(PostData);
			tb_show();
					 $.ajax({
					   type: "POST",
					   url: "PostPing.php",
					   data: PostData,
					   success: function(msg){
						   //alert(msg);
						tb_remove();
						window.location.href="index.php?ActiveTitle=Links posted by me&TabIndex=1";
			   }
			 });
		}		
	}
	else
	{
		var PostData = "";
		PostData = "Link="+Link+"&Description="+Dscr+"&Type=Normal";
		//alert(PostData);
		tb_show();
				 $.ajax({
				   type: "POST",
				   url: "PostPing.php",
				   data: PostData,
				   success: function(msg){
					   //alert(msg);
					tb_remove();
					window.location.href="index.php?ActiveTitle=Links posted by me&TabIndex=1";
		   }
		 });
	}
}

/* Function for posting link through ajax ends*/



/* Function for Registration starts*/
var Indicator;
function ajaxSignIN(PostURL,CText) {

	var PostData;
	var PostData = PostURL;
	CapVal = ValidateCaptcha(CText);
	//alert(Indicator);
	if(Indicator==1)
	{
		tb_show(null,null,false);
				 $.ajax({
				   type: "POST",
				   url: "CommonMethods.php?Action=Registration",
				   data: PostData,
				   success: function(msg){
					 //alert(msg);
					   window.location.href='RegistrationSuccess.php';
					   /*alert("Registration Successful\n"+msg);
					   tb_remove();
					   tb_show("Registration Succesful","RegistrationSuccess.php?return=Login.php&height=150&width=300",null);
					setTimeout('window.location.href=\'Login.php\'', 20000);*/
			   }
		 });
	}
}

/* Function for Registration ends*/

/* Function for Saving Profile starts*/

function UpdateProfile(PostURL) {

	var PostData;
	PostData = PostURL;
	tb_show(null,null,false);
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php?Action=UpdateProfile",
			   data: PostData,
			   success: function(msg){
				   //alert(msg);
				   if(msg != "")
				   {
					   	document.getElementById('LoginName').innerHTML = msg;
				   }
				   tb_remove();
				   document.getElementById('SuccessMessage').style.display = "block";
				   document.getElementById('SuccessMessage1').innerHTML = "<br/><br/>Your profile has been updated";
				   //window.location.href='RegistrationSuccess.php';
				   /*alert("Registration Successful\n"+msg);
				   tb_remove();
				   tb_show("Registration Succesful","RegistrationSuccess.php?return=Login.php&height=150&width=300",null);
				setTimeout('window.location.href=\'Login.php\'', 20000);*/
		   }
	 });
}

/* Function for Saving Profile ends*/

/* Function for Old Password Check starts*/

function CheckOldPwd(Pwd) {

	var PostData;
	PostData = "OldPassword="+Pwd;
	//alert(PostData);
	tb_show(null,null,false);
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php?Action=CheckOldPwd",
			   data: PostData,
			   success: function(msg){
				   //alert(msg);
				   if(parseInt(msg)=="0")
				   {
					   	document.getElementById('SuccessMessage').style.display = "none";
					   	document.getElementById('ErrorMsg').style.display = "block";
						//document.getElementById('Password').focus();
						//document.getElementById('ErrorMsg').innerHTML = "<br/><br/>Oops Password doesn't Match";
						//document.getElementById('OldPassword').focus();
						tb_remove();
						return false;
				   }
				   else
				   {
					   	document.getElementById('ErrorMsg').style.display = "none";
					   	tb_remove();
						return true;
				   }
		   }
	 });
}

/* Function for Old Password Check ends*/

/* Function for Save Password starts*/

function SavePassword(PostURL) {

	var PostData;
	PostData = PostURL;
	//alert(PostData);
	tb_show(null,null,false);
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php?Action=SavePwd",
			   data: PostData,
			   success: function(msg){
				   //alert(msg);
				   tb_remove();
				   setTimeout("RemoveMessage('SuccessMessage','ProfileSetting.php?ActiveTitle=Edit Profile&TabIndex=3')",2000);
				   document.getElementById('SuccessMessage').style.display = "block";
				   document.getElementById('SuccessMessage1').innerHTML = "<br/><br/>Password Changed Successfully";
		   }
	 });
}

/* Function for Save Password ends*/

/* function for removing message and redirecting  starts*/
function RemoveMessage(id,url)
{
	document.getElementById(id).style.display = 'none';
	if(url!="")
	{
		window.location.href=url;
	}
}
/* function for removing message and redirecting  starts*/


/* Function for Duplication User Name starts*/

function CheckDuplicate(EmailID) {
	var PostData;
	PostData = "EmailID="+EmailID;
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php?Action=DuplicateUser",
			   data: PostData,
			   success: function(msg){
			   tb_remove();
			   if(msg=="Duplicate")
			   {
				   	document.getElementById('EmailID').focus();
					document.getElementById('ErrorMsg').style.display='block';
					return false;
			   }
			   else
			   {
				   	document.getElementById('ErrorMsg').style.display='none';
				   	return true;
			   }
     		   
	   }
	 });
}

/* Function for Duplication User Name ends*/


/* Function for Captcha Validation starts*/

function ValidateCaptcha(CText) {
	var PostData;
	PostData = "CText="+CText;
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php?Action=ValidateCaptcha",
			   data: PostData,
			   success: function(msg){
			   if(msg==0)
			   {
				   	//alert(msg);
				   	document.getElementById('CaptchaText').focus();
					document.getElementById('CapErrorMsg').style.display='block';
					return false;
			   }
			   else
			   {
				    //alert("Hello World:"+msg);
				   	document.getElementById('CapErrorMsg').style.display='none';
					Indicator = 1;
				   	return 1;
			   }
     		   
	   }
	 });
}

/* Function for Captcha Validation ends*/


/* Function for Captcha Image Change starts*/
function ChangeCap()
{
	var PostData;
	PostData = "";
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "captcha.php",
			   data: PostData,
			   success: function(msg){
			   document.getElementById().src='';
			   tb_remove();
     		   
	   }
	 });		
}
/* Function for Captcha Image Change ends*/


function IsValidEmail(strValue)
{
	//var objRegExp  =/(^[a-z0-9]([a-z0-9_\.]*)@([a-z0-9_\-\.]*)([.][a-z]{3})$)|(^[a-z0-9]([a-z0-9_\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3})(\.[a-z]{2})*$)/i;
	var objRegExp  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return objRegExp.test(strValue);
}



/* Function for Accepting Friends Request starts*/
function AcceptFriend(FId,eleDet)
{
	var PostData;
	PostData = "Action=AcceptRequest&Id="+FId;
	tb_show();
			 $.ajax({
			   type: "GET",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
				   //alert(msg);
				   document.getElementById('MySpaceF').innerHTML = parseInt(document.getElementById('MySpaceF').innerHTML)+1;
				   document.getElementById('MySpaceNFR').innerHTML = parseInt(document.getElementById('MySpaceNFR').innerHTML)-1;
				   $(eleDet).parent().parent().parent().parent().remove();
				   tb_remove();
	   }
	 });		
}
/* Function for Accepting Friends Request ends*/

/* Function for Denying Friends Request starts*/
function DenyFriend(FId,eleDet)
{
	var PostData;
	PostData = "Action=DenyRequest&Id="+FId;
	//alert($(eleDet).parent().parent().parent().parent().html());
	//return false;
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
				   //alert(msg);
				   document.getElementById('MySpaceNFR').innerHTML = parseInt(document.getElementById('MySpaceNFR').innerHTML)-1;
				    $(eleDet).parent().parent().parent().parent().remove();
					if(msg==0)
					{
						document.getElementById('FunctionalPopupOrange').style.display='block';
						document.getElementById('FunctionalMessageOrange').innerHTML='<br/>You have no friend request at the moment.<br/>Did you invite your friends?';
						AlignMessageDiv('FunctionalPopupOrange');
					}
			   tb_remove();
			   //window.location.href='ViewFriends.php?ActiveTitle=New Friend Request';
     		   
	   }
	 });		
}
/* Function for Denying Friends Request ends*/

/* Function for sending  Friends Request starts
function SendRequest(FId)
{
	var PostData;
	PostData = "Action=SendRequest&Id="+FId;
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
			   tb_remove();
			   document.getElementById('Add').style.display='none';
 	   }
	 });		
}
/* Function for sending Friends Request ends*/


/* Function for Remove Contact starts*/
function RemoveContact(FId,eleDet)
{
	var PostData;
	PostData = "Action=Remove&Id="+FId;
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
				   //alert(msg);
				   document.getElementById('MySpaceF').innerHTML = msg;
				   $(eleDet).parent().parent().parent().parent().remove();
			   tb_remove();
			   //window.location.href='ViewFriends.php?ActiveTitle=My Friends';
     		   
	   }
	 });		
}
/* Function for Remove Contact ends*/


/* Function  for friend request starts here */
function SendFriendRequest(UserID,eleDet)
{
	//alert(UserID);
	var PostData;
	PostData = "Action=SendFriendRequest&ToAddUserID="+UserID;
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
				  //alert(msg);
				  $(eleDet).parent().parent().remove();
				document.getElementById('FunctionalPopupGreen').style.display='block';
				document.getElementById('FunctionalMessageGreen').innerHTML='<br/><br/>Invitation has been sent successfully';
				tb_remove();
				AlignMessageDiv('FunctionalPopupGreen');
	   }
	 });		
}
/* Function  for friend request ends here */


/* Function  for comment submission starts here */
function SubmitComment(Comment,LinkID)
{
	//alert(Comment);
	var PostData;
	//alert(Comment.length);
	//$('#CommentButton').parent().before(msg);
	if(Comment != "")
	{
		PostData = "Action=CommentSubmit&LinkID="+LinkID+"&Comment="+Comment;
		tb_show();
				 $.ajax({
				   type: "POST",
				   url: "CommonMethods.php",
				   data: PostData,
				   success: function(msg){
					   //alert("1"+msg);
					   $('#CommentButton').parent().before(msg);
					   document.getElementById('Comment').value = "";
					   tb_remove();
		   }
		 });
	}
	else
	{
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Comment should not be blank.';
		AlignMessageDiv('FunctionalPopupRed');
		return false;
	}
}
/* Function  for comment submission ends here */

/* Function  for comment submission starts here */
function SubmitComment1(Comment,LinkID,CommentCounterCont,CommentCount)
{
	//alert(Comment+":"+LinkID+":"+CommentCounterCont+":"+CommentCount);
	//Container = document.getElementbyId('DivCommentCont'+LinkID);
	if(Comment != "")
	{	
		var PostData;
		PostData = "Action=CommentSubmit&LinkID="+LinkID+"&Comment="+Comment;
		tb_show();
				 $.ajax({
				   type: "POST",
				   url: "CommonMethods.php",
				   data: PostData,
				   success: function(msg){
					   //alert(msg);
					   document.getElementById('CommentCount').value = parseInt(document.getElementById('CommentCount').value)+1;
					   document.getElementById(CommentCounterCont).innerHTML = parseInt(document.getElementById('CommentCount').value)+' Comments';
					   $('#CommentButton').parent().before(msg);
					   tb_remove();
					   slideup('DivCommentCont'+LinkID);
		   }
		 });
	}
	else
	{
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Comment should not be blank.';
		AlignMessageDiv('FunctionalPopupRed');
		return false;
	}
	
}
/* Function  for comment submission ends here */

/* Function  for updating image url starts here */
function UpdateImageURL(ImagePath)
{
	var PostData;
	PostData = "Action=UpdateImageURL&ImagePath="+ImagePath;
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
				   var dateTimeStamp = new Date();
				   dateTimeStamp = dateTimeStamp.toString();
				   document.getElementById('uploaded_image').src=ImagePath+"?"+dateTimeStamp;
			   tb_remove();
	   }
	 });		
}
/* Function  for updating image url ends here */

/* Function for sending invitation to friend starts*/
function SendInvitation(Email)
{
	var PostData;
	var UserName = document.getElementById('UserName').value;
	if(Email=="")
	{
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Enter email address of your friend to invite!';
		AlignMessageDiv('FunctionalPopupRed');		
		document.getElementById('FriendMail').focus();
		return false;
	}
	else if(!IsValidEmail(Email))
	{
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Please enter valid email address!';
		AlignMessageDiv('FunctionalPopupRed');			
		document.getElementById('FriendMail').focus();
		return false;
	}
	else if(Email == UserName)
	{
		//alert(UserName);
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Opps!!! You have entered your own email id!';
		AlignMessageDiv('FunctionalPopupRed');			
		document.getElementById('FriendMail').focus();
		return false;
	}	
	else
	{
		PostData = "Action=SendInvitation&EmailID="+Email;
		tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
			   //alert(msg);
			   tb_remove();
			   if(parseInt(msg)==1)
			   {
				   	//alert("Hello World");
					document.getElementById('FunctionalPopupGreen').style.display='block';
					document.getElementById('FunctionalMessageGreen').innerHTML='<br/><br/>Invitation has been sent successfully';
					AlignMessageDiv('FunctionalPopupGreen');
					document.getElementById('FriendMail').value='';
			   }
			   else
			   {
					document.getElementById('FunctionalPopupRed').style.display='block';
					document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Invitation failed';
					AlignMessageDiv('FunctionalPopupRed');
					document.getElementById('FriendMail').focus();
			   }
			   
	   	}
	 	});
	}
	return false;
}
/* Function for sending invitation to friend ends*/

/* Function for adding favourites link starts*/
function FavLink(LinkID,eleDet)
{
	var PostData;
	PostData = "Action=FavLink&LinkID="+LinkID;
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
			   //alert($(eleDet).parent().html());
			   $(eleDet).replaceWith('<img src="images/star_dim.jpg" border="0" title="Added to your favorites" style="margin:5px;" />');
			    //alert($(eleDet).parent().html());
			   document.getElementById('MySpaceLinks').innerHTML = parseInt(document.getElementById('MySpaceLinks').innerHTML)+1;
			   tb_remove();
			   //document.getElementById('FunctionalPopup').style.display='block';
			   //document.getElementById('FunctionalMessage').innerHTML='<br/><br/>This ping is added to your link box for future reference.';
	   }
	 });
}
/* Function for adding favourites link ends*/

/* Function for adding favourites link starts*/
function RemoveFavLink(LinkID,eleDet)
{
	var PostData;
	PostData = "Action=RemoveFavLink&LinkID="+LinkID;
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
			   if(parseInt(msg)==0)
			   {
					document.getElementById('SuccessMessage').style.display='block';
			   }
			   $(eleDet).parent().parent().parent().remove();
			   document.getElementById('MySpaceLinks').innerHTML = parseInt(document.getElementById('MySpaceLinks').innerHTML)-1;
			   tb_remove();
	   }
	 });
}
/* Function for adding favourites link ends*/


/* Function for deleteting user's own link comment starts */
function DeleteComment(CommentID,LinkID,eleDet)
{
	var PostData;
	//alert(eleDet);
	//alert($(eleDet).parent().html());
	//return false;
	PostData = "Action=DelComment&CommentID="+CommentID;
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
				  $(eleDet).parent().parent().remove();
			   tb_remove();
			   //window.location.href='index.php?TabIndex=1&ActiveTitle=Comment on selected ping&LinkID='+LinkID;
	   }
	 });		
}
/* Function for deleteting user's own link comment ends */

/* Function for Updating Session starts */
function UpdateSession()
{
	var PostData;
	PostData = "";
	//tb_show();
			 $.ajax({
			   type: "POST",
			   url: "UpdateSession.php",
			   data: PostData,
			   success: function(msg){
				   //alert(msg);
				   var arry = msg.split(','); 
				   //alert(arry.length);
				   document.getElementById('MySpaceNFR').innerHTML = arry[0];
				   document.getElementById('MySpaceLinks').innerHTML = arry[2];
				   document.getElementById('MySpaceF').innerHTML = arry[1];
				   if(msg!="")
				   {
				   		//alert(msg);
						//location.reload(true);
				   }
				   //setTimeout("UpdateSession()",5000);
			  //tb_remove();
	   }
	 });		
}
/* Function for Updating Sessions ends */

/* Alphanuric check */
function CheckAlphaNumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
 return true;
}

/* Alphanuric check */

/* RHS find validation */
function ValidateFind(Fval)
{
	var myRegxp = /^([ a-zA-Z0-9_-]+)$/; 
	if(Fval=="")
	{
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Search value should not be blank';
		AlignMessageDiv('FunctionalPopupRed');			
		document.getElementById('SearchString1').focus();
		return false;
	}
	else if(myRegxp.test(Fval)==false)
	{
		document.getElementById('FunctionalPopupRed').style.display='block';
		document.getElementById('FunctionalMessageRed').innerHTML='<br/><br/>Illegal string found in your search string';
		AlignMessageDiv('FunctionalPopupRed');			
		document.getElementById('SearchString1').focus();
		return false;
	}	
}

/* RHS find validation */

function AlignMessageDiv(id)
{
	  var pos=parseInt($(window).scrollTop())+parseInt($(window).height());
	  pos_sub = parseInt($(window).height())/2;
	  $('#'+id).css("top",pos-pos_sub+"px");
	  $('#'+id).show(); //display the message box
	  $(window).scroll(function()
	  {
		 var pos=parseInt($(window).scrollTop())+parseInt($(window).height());
		 pos_sub = parseInt($(window).height())/2;
		$('#'+id).animate({top:pos-pos_sub+"px" },{queue: false, duration: 500});
	  });
}


function getISDCode(id)
{
	var PostData;
	PostData = "Action=GetISD&CountryID="+id;
	tb_show();
			 $.ajax({
			   type: "POST",
			   url: "CommonMethods.php",
			   data: PostData,
			   success: function(msg){
				   //alert("GetoISDStatus:"+msg);
				   tb_remove();
				  jQuery(function($){$("#Mobile").mask("+"+msg+"nnnnnnnnnn");});
			   //window.location.href='index.php?TabIndex=1&ActiveTitle=Comment on selected ping&LinkID='+LinkID;
	   }
	 });	
}

function DisplayEditButton()
{
	el=document.getElementById('uploaded_image');
	ButtonCont=document.getElementById('EditImageCont');
	var pos = $(el).offset();
	var eWidth = $(el).outerWidth();
	var eHeight = $(el).height();
	var mWidth = $(ButtonCont).outerWidth();
	var left = (pos.left) + "px";
	var top = (pos.top) + "px";
	//alert(left);
	//alert(checkeditimage);
	$(ButtonCont).css( {
		position: 'absolute',
		zIndex: 5000,
		left: left,
		display: 'block',
		top: top
	} );
	$(ButtonCont).hide().fadeIn();
}

function HideEditButton()
{
	el=document.getElementById('EditImageCont');
	$(el).fadeOut();
}

function CheckChecked(st)
{
	//alert(st);
	var cnt = document.getElementById('CountNFr').value;
	cnt1=0;
	for(i=0;i<cnt;i++)
	{	
		if(document.getElementById('Ch'+i).checked==true)
		{
			cnt1++;
		}
	}
	if(cnt1==cnt)
	{
		document.getElementById('SelectAll').checked=true;
	}
	else
	{
		document.getElementById('SelectAll').checked=false;
	}
}

function CheckAll(st1)
{
	//alert(st1)
	var cnt = document.getElementById('CountNFr').value;
	//alert(cnt);
	if(st1==true)
	{
		for(i=0;i<cnt;i++)
		{	
			document.getElementById('Ch'+i).checked=true;
		}
	}
	else
	{
		for(i=0;i<cnt;i++)
		{	
			document.getElementById('Ch'+i).checked=false;
		}		
	}	
}