// For Check form function



function checkCheckbox(IdClassName)
{
	other="";
	result="";
	$$('.'+IdClassName).each(function(checkbox,i){
										if(checkbox.checked && checkbox.value!='0' && checkbox.value!='')
											{	
												result="checked";
												
										////////////////
											if(checkbox.hasClass('check_other'))
												{
														if(!checkOther(checkbox.getProperty('id')))
														{   /// Cannot pass
															
															other+=checkbox.getProperty('id')+" ";
															result=checkbox.getProperty('id');
														}
														else
														{
															result="checked";
														}
												}
										////////////////
										}
										
									   });
	//alert(other+ "----"+result);
	if(other.length<=0 && result.length>0)
		return "checked";
	else
		return other;
}

function checkOther(id){
	
	var otherid=id+'Other';
	//alert($(otherid));
	if($(otherid).value=='')
	{
		return false;	
	}else{
		return true;
		
	}
}

function differentPassword(){
	var warning='';
	if($('Password').value!=$('Re-type Password').value)
	{
		warning='Different Password';
	}
	return warning;
}

function checkEmail(element)
{	var warning='';
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(element.value))
	{
		warning='';
	}else{ 
	warning='Invalid E-mail Address! Please re-enter.';
	}
	return warning;
}
function validate_num(val){
	var digits="0123456789-";
	var temp;

	for (var i=0;i<val.length;i++){
		temp=val.substring(i,i+1);
		if (digits.indexOf(temp)==-1){
			return (false);
	    }
	}
	return (true);
}
function validPassword(str) {
	var digits="0123456789";
	var alph="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var c_digit=false, c_alph=false;
	var temp;

	for (var i=0;i<str.length;i++)
	{
		temp=str.substring(i,i+1);
		if ((digits.indexOf(temp)==-1) && (alph.indexOf(temp)==-1)){
			return (false);
	    } else if (digits.indexOf(temp)!=-1) {
	    	c_digit = true;
	    } else if (alph.indexOf(temp)!=-1) {
	    	c_alph = true;
	    }	    
	}
	if ((!c_digit) || (!c_alph)) {
		return false;
	} else {
		return true;
	}
}


function compulsory(){
	missinginfo = "";

	/****************/
	if (missinginfo == "") {
		if (document.form1.txtFirstName.value == "") {
			missinginfo += "\n - Given Name";
		}
		if (document.form1.txtLastName.value == "") missinginfo += "\n - Surname";
		if (document.form1.txtEmail.value == "") missinginfo += "\n - Email";

		missinginfoa = "Please fill in your:" + missinginfo;
		if (missinginfo != "") {
			missinginfo = missinginfoa;
		}
	}

	if (missinginfo != "") {
		alert (missinginfo);
		return false;
	} else {
		return checkEmail2(document.form1.txtEmail.value);
	}
}

function checkEmail2(email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
	{
		return (true);
	}
	else {
		alert("Invalid E-mail Address! Please re-enter.");
		return (false);
	}
}

function check(ele)
{
	value=ele.value;
	if(value.indexOf('"')>=0)
	{
		value=value.substring(0,value.indexOf('"'));
		ele.value=value;
		return false;
	}
	return true;
}	
function addmore(){
	if(i<10){
		t1 = "friend" + (i);
	//	t2 = "friend" + (i*2+1);
		document.getElementById(t1).style.display = "block";
	//	document.getElementById(t2).style.display = "block";
		i++;
	}	
}
