/**
 * Registration Validiation
 */
function validateregform()
{
	var id1=document.getElementById("dispname");
	var id2=document.getElementById("username");
	var id3=document.getElementById("emailid");
	var id4=document.getElementById("password");
	var id5=document.getElementById("cpassword");
	var id6=document.getElementById("country");
	var id7=document.getElementById("city");
	var id8=document.getElementById("capthca");
	var id9=document.getElementById("accept");
	var lbl=document.getElementById("valid");
	if(checkTextEmpty(id1,"Display Name",lbl) && checkTextEmpty(id2,"Username",lbl) && ValidNumtext(id2,"Username should not allow spaces",lbl) && checkuserexist() && checkTextEmpty(id3,"Email Address",lbl) && validateEmail(id3,"The Email Address field must contain a valid email address",lbl) && checkemailexist() && checkTextEmpty(id4,"Password",lbl) && ifallspacespwd(id4,"Password should not allow spaces",lbl) && minimum_length(id4,"Password Strength is Weak, Enter min 8 characters",8,lbl) && checkTextEmpty(id5,"Confirm Password",lbl) &&  ifallspacespwd(id5,"Confirm Password should not allow spaces",lbl) && minimum_length(id5,"Confirm Password Strength is Weak, Enter min 8 characters",8,lbl) && comparepasswords(id4,id5,lbl)&& checkSelEmpty(id6,"Country",lbl)&& checkSelEmpty(id7,"City",lbl) && checkTextEmpty(id8,"Captcha",lbl) && checkcaptcha())
	{
	}
	else
	{
		return false;
	}
	if(id9.checked==false)
	{
		lbl.innerHTML = "Please accept the terms and conditions";	
		
		return false;
	}
}

/**
 * Forget Password Validiation
 */
function validateforgetform()
{
	var id1=document.getElementById("emailid");
	var lbl=document.getElementById("valid");
	if(checkTextEmpty(id1,"Email Address",lbl) && validateEmail(id1,"The Email Address field must contain a valid email address",lbl) && checkforgetemailexist())
	{
	}
	else
	{
		return false;
	}
}
/**
 * Lays Validiation
 */
function validatelaysform()
{
	var id1=document.getElementById("keyword");
	var id2=document.getElementById("country");
	var id3=document.getElementById("city");
	var id4=document.getElementById("message");
	var lbl=document.getElementById("valid");
	var variablename=(id1.value == 0)?(checkSelEmpty(id1,"Keyword",lbl)):(checkTextEmpty(id1,"Keyword",lbl) && countWords(id1,"Keyword must have a length of 4 words",lbl) && minimum_lengthz (id1,"Keyword whould not exceed 70 characters",lbl));
	if( variablename &&  checkTextEmpty(id4,"message",lbl))
	{
	}
	else
	{
		return false;
	}
}
function validategrpform()
{
	var id1=document.getElementById("keyword");
	var id2=document.getElementById("message");
	var lbl=document.getElementById("valid");
	if(checkTextEmpty(id1,"Keyword",lbl) && countWords(id1,"Keyword must have a length of 4 words",lbl) && minimum_lengthz (id1,"Keyword whould not exceed 70 characters",lbl) &&  checkTextEmpty(id2,"message",lbl))
	{
	}
	else
	{
		return false;
	}
}
function validatereplyform()
{
	var id1=document.getElementById("reply");
	var lbl=document.getElementById("valid");
	if(checkTextEmpty(id1,"Reply",lbl))
	{
	}
	else
	{
		return false;
	}
}
function replybox()
{
	document.getElementById('replybox').style.display='block';
}
/**
 * Filter Lays Validiation
 */
function validatefilterform()
{
	var id1=document.getElementById("keyword");
	var id2=document.getElementById("country");
	var id3=document.getElementById("city");
	var lbl=document.getElementById("valid");
	if(checkTextEmpty(id1,"Keyword",lbl) && countWords(id1,"Keyword must have a length of 4 words",lbl) && minimum_lengthz (id1,"Keyword whould not exceed 70 characters",lbl) && checkSelEmpty(id2,"Country",lbl) && checkSelEmpty(id3,"City",lbl))
	{
	}
	else
	{
		return false;
	}
}
/**
 * inbox validation
 */

function inboxvalidate()
{
	var frm = document.inboxform;
	var checkboxArr = document.getElementById('inboxform').getElementsByTagName("input");
	//alert(checkboxArr);
	var numChecked = 0;
	for (i=1; i<checkboxArr.length; i++)
	{
		if (checkboxArr[i].type == "checkbox" && checkboxArr[i].checked == true)
		numChecked++;
	}
	if(numChecked <= 0)
	{
		alert("Please Select Atleast One message to delete");
		return false;
	}	
	else 
	{
		var x=confirm("Are you sure to delete selected message(s)? ")	
		if(x)
		{
			return true;
		}
		else
		{
			return false;
		}
		
	}
	
}

/**
 * check all function
 */
var flag=false;
function select_deselectAll (chkVal, idVal)
{ 
	
	var frm = document.forms[0];
	
       //alert(frm.length);
    for (i=0; i<frm.length; i++)
    {  
        if (idVal.indexOf ('chkAll') != -1)
        {
			
            if(chkVal == true)
            {	
				
                frm.elements[i].checked = true;
            }
            else
            {	//alert(frm.length);
                frm.elements[i].checked = false;
				
            }
        }
        else if (idVal.indexOf ('checklist') != -1)
        {
			
            if(frm.elements[i].checked == false)
            {	//alert(frm.length);
				
                document.getElementById("chkAll").checked=false;
                frm.elements[0].checked = false; 
            }
			else
			{
				
			}
        }
    }
	var c=frm['checklist[]'];
	var t=0;
	for(var i=0;i<c.length;i++)
	{

		c[i].checked?t++:null;
		//alert("c[i].checked");
	}
	
	if(c.length==null)
	{
		if(flag==false)
		{
			flag=true;
			document.getElementById("chkAll").checked=true;
		}
		else
		{
			flag=false;
			document.getElementById("chkAll").checked=false;
		}
	}
	else if(t==c.length)
	{
		document.getElementById("chkAll").checked=true;
	}
	
}
function check_group_values()
{
	var lb1=document.getElementById("valid");
	var id1=document.getElementById('country');
	var id2=document.getElementById('city');
	if((checkSelEmpty(id1,"Country",lb1)) && (checkSelEmpty(id2,"city",lb1)) )
	{
		
	}
	else
	{		
			return false;
	}
	
}