function IsValidNumber(frm_field, err_msg, minimum, maximum)
{
	var minimum = (minimum == null) ? "1" : minimum;
	var maximum = (maximum == null) ? "" : maximum;
	//alert(minimum);
	//alert(maximum);
	if(trim(frm_field.value)=="")
	{
		alert('Please enter ' + err_msg);
		frm_field.focus();
		return false
	}
	sort_val = trim(frm_field.value)
	if(isNaN(sort_val) || sort_val.indexOf(".") != -1 || parseInt(sort_val)<minimum)
	{
		alert('Please enter valid ' + err_msg);
		frm_field.focus();
		return false;
	}
	if(maximum && (parseInt(sort_val)>maximum))
	{
		alert(err_msg + ' can be ' + maximum + ' only');
		frm_field.focus();
		return false;
	}
	return true;
}

function IsValidFloat(frm_field, err_msg, minimum, maximum)
{
	var minimum = (minimum == null) ? "1" : minimum;
	var maximum = (maximum == null) ? "" : maximum;
	//alert(minimum);
	//alert(maximum);	
	if(frm_field.value=="")
	{
		alert('Please enter ' + err_msg);
		frm_field.focus();
		return false
	}	
	frm_field = document.getElementById(frm_field);
	sort_val = trim(frm_field.value);	
	if(isNaN(sort_val) || parseFloat(sort_val)<minimum)
	{
		alert('Please enter valid ' + err_msg);
		frm_field.focus();
		return false;
	}	
	if(maximum && (parseFloat(sort_val)>maximum))
	{
		alert(err_msg + ' can be ' + maximum + ' only');
		frm_field.focus();
		return false;
	}	
	return true;
}

function checkEnter(e)//e is event object passed from function invocation
{ 
	var characterCode //literal character code will be stored in this variable
	
	if(e && e.which)//if which property of event object is supported (NN4)
	{ 
		e = e;
		characterCode = e.which ;//character code is contained in NN4's which property
	}
	else
	{
		e = event
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13)//if generated character code is equal to ascii 13 (if enter key)
	{ 
		return true;
	}
	else
	{
		return false;
	}
}
function isEmpty(ele,error_message){
	if(ele.value==""){
		alert(error_message);
		ele.focus();
		return false;
	}
	return true;
}

function checkURL(val)
{
	//var patt =  /(ftp|http|https):\/\/[wW]{3}\.[A-Za-z0-9\-]{3,}\.[A-Za-z]{2,3}/;
	var patt =  /[A-Za-z0-9\-]{3,}\.[A-Za-z]{2,3}/;
	var result;
	
	result = patt.test(val);
	return result;
}

function checkFormFields(type){
	switch(type){
		case "signup":
			return checkSignUpForm();
			break;		
		case "signin":
			return checkLoginForm();
			break;
		case "signin2":
			return checkLoginForm2();
			break;
		case "forgotpassword":
			return checkforgotpassword();
			break;
		case "addlists":
			return checkAddListsForm();
			break;
		case "additem":
			return checkAdditemForm();
			break;
		case "addfundrisers":
			return checkAddFundRaiseForm();
			break;
		case "editlist":
			return checkeditlistForm();
			break;
		case "sendtofriend":
			return checksendtofriendForm();
			break;
		case "sendtofriend_grp":
			return checksendtofriend_grpForm();
			break;
		case "invitationadd":
			return checkinvitationaddForm();
			break;
		case "search":
			return checksearchForm();
			break;
		case "search2":
			return checksearchForm2();
			break;
		case "editaccount":
			return checkeditaccountForm();
			break;
		case "edititem":
			return checkeditemForm();
			break;
		case "senditemtofriend":
			return checkedsenditemtofriendForm();
			break;
		case "sendlists":
			return checkedsendlistsForm();
			break;
		case "addcomment":
			return checkedaddcommentForm();
			break;
		case "addgroup":
			return checkedaddgroupForm();
			break;
		case "changepassword":
			return checkedchangepasswordForm();
			break;
		case "guest":
			return checkedsubmitForm();
			break;
			
	}	
}

function checkLoginForm(){
	if(isEmpty(document.getElementById('UserUserName'),"E-mail address should not be empty.") && isEmpty(document.getElementById('UserPassword'),"Password field should not be empty."))
		return true;
	else
		return false;
}
function checkLoginForm2(){
	if(isEmpty(document.getElementById('UserUserName2'),"E-mail address should not be empty.") && isEmpty(document.getElementById('UserPassword2'),"Password field should not be empty."))
		return true;
	else
		return false;
}
function checkforgotpassword(){
	var username = document.getElementById('UserUserName');
	if(username.value==""){
		alert("Email field should not be empty.");
		username.focus();
		return false;
	}else if(!checkEmail(username.value)){
		alert("Please enter valid E-mail address.");
		username.focus();
		return false;
	}
}

function submit_paypal(id, amt){
	document.getElementById('frm_paypal').submit();
	
	var t=setTimeout("wLocateFund("+id+","+amt+")",200);
	
	return true;
}

function wLocateFund(id, amt) {
	window.location='/items/finalfund/'+id+'/'+amt;
}

function submit_grp_paypal(id, amt, gid) {
	document.getElementById('frm_paypal').submit();
	var t=setTimeout("wLocatePayment("+id+","+amt+","+gid+")",200);	
	return true;
}

function wLocatePayment(id, amt, gid) {
	window.location='/items/finalpayment/'+id+'/'+amt+'/'+gid;
}


function checkSignUpForm(){	

	var username = document.getElementById('UserUserName');
	var firstname = document.getElementById('UserFirstName');
	var lastname = document.getElementById('UserLastName');
	var month = document.getElementById('UserDateOfBirthMonth');
	var day = document.getElementById('UserDateOfBirthDay');
	var year = document.getElementById('UserDateOfBirthYear');
	var password = document.getElementById('UserPassword');
	var password_confirm = document.getElementById('UserConfirmPassword');
	var UserTerms = document.getElementById('UserTerms');
	
	
/*	return isEmpty(document.getElementById('UserUserName'),"User name should not be empty.");
	return isEmpty(document.getElementById('UserFirstName'),"First name should not be empty.");
	return isEmpty(document.getElementById('UserLastName'),"Last name should not be empty.");
	return isEmpty(document.getElementById('UserDateOfBirthMonth'),"Month field should not be empty.");
	return isEmpty(document.getElementById('UserDateOfBirthDay'),"Day field should not be empty.");
	return isEmpty(document.getElementById('UserDateOfBirthYear'),"Year field should not be empty.");	
	return isEmpty(document.getElementById('UserPassword'),"Password field should not be empty.");
	return isEmpty(document.getElementById('UserConfirmPassword'),"Confirtm Password should not be empty.");*/
	
	
	if(username.value==""){
		alert("Email field should not be empty.");
		username.focus();
		return false;
	}else if(!checkEmail(username.value)){
		alert("Please enter valid E-mail address.");
		username.focus();
		return false;
	}
	if(firstname.value==""){
		alert("First name field should not be empty.");
		firstname.focus();
		return false;
	}
	if(lastname.value==""){
		alert("Last name field should not be empty.");
		lastname.focus();
		return false;
	}
/*	if(month.value==""){
		alert("Month field should not be empty.");
		month.focus();
		return false;
	}
	if(day.value==""){
		alert("Day field should not be empty.");
		day.focus();
		return false;
	}
	if(year.value==""){
		alert("Year field should not be empty.");
		year.focus();
		return false;
	}*/
	if(password.value==""){
		alert("Password field should not be empty.");
		password.focus();
		return false;
	}
	if(password_confirm.value==""){
		password_confirm.focus();
		alert("Confirtm Password should not be empty.");
		return false;
	}
	if(document.getElementById('UserPassword').value!=document.getElementById('UserConfirmPassword').value){
		alert("Pass words mismatch.");
		return false;
	}
		if(UserTerms.checked==false){
		UserTerms.focus();
		alert("Please check terms & condtions.");
		return false;
	}
	return true;
}

function trim(str)
{
	if(str)
		return str.replace(/^\s*|\s*$/g,"");
	else
		return "";
}

function checkEmail_old(myForm)
{ 
	flag=false;
	if (/^\w+([+\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim(myForm))) 
	{
			flag=true;
			flag=validate_tldextension(myForm);
	}
		
	if(flag==true){
		return true;	
	} else {
		return false;
	}
}
function validate_tldextension(email){
	
	fullemail=email
	validtldlist="com,net,org,us,in,biz,info,tv,cc,ws,uk,au,name,de,jp,be,at,uk,nz,cn,tw,jobs,am,fm,gs,ms,nu,tc,tk,vg,eu,me"
	validtldlistarr=validtldlist.split(",")
	svalidtldlist="co.uk,me.uk,org.uk,co.nz,co.in,net.nz,org.nz,com.cn,org.cn,net.cn,com.tw,org.tw,idv.tw,templetechnologies.com"
	svalidtldlistarr=svalidtldlist.split(",")
	fullemailarr=fullemail.split("@")
	dotcount=0
	for(i=0;i<fullemailarr[1].length;i++){
		if(fullemailarr[1].charAt(i)=="."){
			dotcount++;	
		}
	}
	if(dotcount==2){
		tldextention=fullemailarr[1].split(".")
		reqstring=tldextention[1]+"."+tldextention[2]
		flag1=false
		for(i=0;i<svalidtldlistarr.length;i++){
			if(reqstring==svalidtldlistarr[i]){
				flag1=true
			}
		}
	}else if (dotcount==1){
		tldextention=fullemailarr[1].split(".")
		reqstring=tldextention[1]
		flag1=false
		for(i=0;i<validtldlistarr.length;i++){
			if(reqstring==validtldlistarr[i]){
				flag1=true
			}
		}
	}else{
		flag1=false
	}
	if(flag1==true){
		return true
	} else {
		return false
	}	
}
function checkEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID");
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID");
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID");
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID");
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID");
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID");
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID");
		    return false
		 }
		
		var email_name = str.split("@");
		if(checkforspecialchars_email_name(email_name[0]))
		{
			return false;
		}
		
		if(checkforspecialchars_email_domain(email_name[1]))
		{
			return false;
		}
		
 		 return true					
	}
	
	
function checkFileType(imagePath)
{
	var pathLength = imagePath.length;
	var lastDot = imagePath.lastIndexOf(".");
	var fileType = imagePath.substring(lastDot,pathLength);
	
	if((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG")) {
		return true;
	} else {
		return false;
	}
}


function checkforspecialchars_email_name(text)
{
	var iChars = "`~!@#$%^&*()=[]\\\';,/{}|\":<>?";
	for (var i = 0; i < text.length; i++) 
		if (iChars.indexOf(text.charAt(i)) != -1) 
			return true;
	return false;
}


function checkforspecialchars_email_domain(text)
{
	var iChars = "`~!@#$%^&*()+=-_[]\\\';,/{}|\":<>?";
	for (var i = 0; i < text.length; i++) 
		if (iChars.indexOf(text.charAt(i)) != -1) 
			return true;
	return false;
}

function showHideCommentForm(){
	var comment = document.getElementById("comment");
	//comment.focus();
	//alert(document.getElementById('comment').focus());
	var commentDiv = document.getElementById("comment");
	//document.getElementById('addComment').focus()
	//alert(commentDiv.focus());
	
	if(commentDiv.style.display=='none'){
		commentDiv.style.display = 'block';
		//alert(document.getElementById("addComment").value="Post Your Comment Here");
		//alert(document.forms['frm_comments'].childNodes[1].childNodes[1]);
		
		//alert(document.frm_comments.elements['data[ItemsComment][comment]'].focus); 	
		location.href = '#comment';	
		document.getElementById("addComment").focus();
		//alert(document.getElementById("addComment").focus);
	}else{
		commentDiv.style.display = 'none';
	}
	
}
function checkAddListsForm(){
	
					var MylistTitle = document.getElementById('MylistTitle');
					//var MylistDescription = document.getElementById('MylistDescription');
					var MylistAccessType = document.getElementById('MylistAccessType');
					if(MylistTitle.value==""){
						alert("MylistTitle should not be empty.");
						MylistTitle.focus();
						return false;
					}
				/*	if(MylistDescription.value==""){
						alert("Description should not be empty.");
						MylistDescription.focus();
						return false;
					}*/
					if(MylistAccessType.value==""){
						alert("Access type should not be empty.");
						MylistAccessType.focus();
						return false;
					}
	
			return true;
	}


function checkAdditemForm(){
		var	OrgItemPrice;
		var	CurItemPrice;
		var ItemTitle = document.getElementById('ItemTitle');
		var ItemListId = document.getElementById('ItemListId');
		var ItemDescription = document.getElementById('ItemDescription');
		var ItemQuantity = document.getElementById('ItemQuantity');
		var ItemPriority = document.getElementById('ItemPriority');
		var ItemPrice = document.getElementById('ItemPrice');
		var ItemTags = document.getElementById('ItemTags');
		var location = document.getElementsByName('data[Item][location][]');
		var ItemWeb = document.getElementById('ItemWeb');
		var computer_0 = document.getElementById('computer_0');
		var computer_1 = document.getElementById('computer_1');
		var ItemImageUrl = document.getElementById('ItemImageUrl');
		
	if(ItemListId && ItemListId.value==""){
		alert("Please select list.");
		ItemListId.focus();
		return false;
	}
	if(ItemTitle.value==""){
		alert("Please enter a title for your item.");
		ItemTitle.focus();
		return false;
	}
/*	if(ItemTitle.value.length>60){
		alert("Item Title should be with in 60 charcters.");
		ItemTitle.focus();
		return false;
	}*/
/*	if(ItemDescription.value==""){
		alert("Item Description should not be empty");
		ItemDescription.focus();
		return false;
	}*/
	if(ItemQuantity.value==""){
		alert("Please enter the quantity desired");
		ItemQuantity.focus();
		return false;
	}
	
	if(isNaN(ItemQuantity.value) || parseInt(ItemQuantity.value)<=0)
	{
		alert('Please enter valid Quantity in numericals');
		ItemQuantity.focus();
		return false;
	}
	/*	
	if(ItemPriority.value==""){
		alert("Priority should not be empty");
		ItemPriority.focus();
		return false;
	}
	if(isNaN(ItemPriority.value)){
		alert("Please enter Priority in numericals");
		ItemPriority.focus();
		return false;
	}
	*/
	/*
	if(ItemPrice.value==""){
		alert("Please enter Item Price");
		ItemPrice.focus();
		return false;
	}
	*/
	OrgItemPrice = ItemPrice.value;
	CurItemPrice = ItemPrice.value;
	CurItemPrice = CurItemPrice.replace(/\$/g,"");
	CurItemPrice = CurItemPrice.replace(/,/g,"");
	
	/*	
	if(isNaN(CurItemPrice) || parseFloat(CurItemPrice)<=0)
	{
		//alert(CurItemPrice);
		alert('Please enter valid Price in numericals');
		ItemPrice.focus();
		return false;
	}
	*/
	/*
	if(ItemWeb.value && computer_1.checked==true){
		if(!checkFileType(ItemWeb.value)){
			alert('Please enter valid web URL for your image');
			ItemWeb.focus();
			return false;
		}
	}
	*/
	if(ItemImageUrl.value && computer_0.checked==true){
		if(!checkFileType(ItemImageUrl.value)){
			alert('Please select images of type gif, jpg, jpeg, png only.');
			ItemImageUrl.focus();
			return false;
		}
	}

/*	if(ItemTags.value==""){
		alert("Tags should not be empty");
		ItemTags.focus();
		return false;
	}*/
	
	for(loc=0;loc<location.length;loc++){
		if(location[loc].value!=""){
			if(!checkURL(location[loc].value)){					 
				alert("Please enter a valid URL");
				location[loc].focus();
				return false;
			}
		}
	}
	ItemPrice.value = CurItemPrice;
	return true;		
}


function checkAddFundRaiseForm(){
	var	OrgItemPrice;
	var	CurItemPrice;
	var ItemTitle = document.getElementById('ItemTitle');
	var ItemDescription = document.getElementById('ItemDescription');
	var ItemPrice = document.getElementById('ItemPrice');
	var donations = document.getElementById('pay_type_0');
	var noonlinedonations = document.getElementById('pay_type_1');
	var ItemsPaymentPayToPaypal = document.getElementById('ItemsPaymentPayToPaypal');
	var ItemsPaymentCheck = document.getElementById('ItemsPaymentCheck');
	var ItemsPaymentPayToCheque=document.getElementById('ItemsPaymentPayToCheque');
	var ItemsPaymentPayAddress=document.getElementById('ItemsPaymentPayAddress');
	var location = document.getElementsByName('data[Item][location][]');
	var ItemWeb = document.getElementById('ItemWeb');
	var ItemImageUrl = document.getElementById('ItemImageUrl');
	var computer_0 = document.getElementById('computer_0');
	var computer_1 = document.getElementById('computer_1');

	if(ItemTitle.value==""){
		alert("Please enter a title for your item.");
		ItemTitle.focus();
		return false;
	}
/*	if(ItemTitle.value.length>60){
		alert("Item Title should be with in 60 charcters.");
		ItemTitle.focus();
		return false;
	}*/
	if(ItemDescription.value==""){
		alert("Item Description should not be empty");
		ItemDescription.focus();
		return false;
	}
	if(ItemPrice.value==""){
		alert("Please enter a financial goal amount");
		ItemPrice.focus();
		return false;
	}
	OrgItemPrice = ItemPrice.value;
	CurItemPrice = ItemPrice.value;
	CurItemPrice = CurItemPrice.replace(/\$/g,"");
	CurItemPrice = CurItemPrice.replace(/,/g,"");
		
	if(isNaN(CurItemPrice) || parseFloat(CurItemPrice)<0)
	{
		//alert(CurItemPrice);
		alert('Please enter valid Price in numericals');
		ItemPrice.focus();
		return false;
	}
	
	if(ItemImageUrl.value!=""){
		if(document.getElementById('different_image'))
			document.getElementById('different_image').checked = true;
	}	
	if(ItemWeb.value && computer_1.checked==true){
		if(!checkFileType(ItemWeb.value)){
			alert('Please enter valid web URL for your image');
			ItemWeb.focus();
			return false;
		}
	}
	if(ItemImageUrl.value && computer_0.checked==true){
		if(!checkFileType(ItemImageUrl.value)){
			alert('Please select images of type gif, jpg, jpeg, png only.');
			ItemImageUrl.focus();
			return false;
		}
	}
	for(loc=0;loc<location.length;loc++){
		if(location[loc].value!=""){
			if(!checkURL(location[loc].value)){					 
				alert("Please enter a valid URL");
				location[loc].focus();
				return false;
			}
		}
	}
	if(donations.checked==true){
		if(ItemsPaymentPayToPaypal.value==""){
			alert("Please enter the PayPal Email Address.");
			ItemsPaymentPayToPaypal.focus();
			return false;
		}
		if(!checkEmail(ItemsPaymentPayToPaypal.value)){
			alert("Please enter valid E-mail address.");
			ItemsPaymentPayToPaypal.focus();
			return false;
		}
	}else if(ItemsPaymentCheck.checked==false){
		alert("Please select any one payment method.");
		return false;
	}
	if( ItemsPaymentCheck.checked==true){
		if(ItemsPaymentPayToCheque.value==""){
			alert("Please enter Make out Check To");
			ItemsPaymentPayToCheque.focus();
			return false;
		}
		if(ItemsPaymentPayAddress.value==""){
			alert("Please enter Mail Check To");
			ItemsPaymentPayAddress.focus();
			return false;
		}
	}
	ItemPrice.value = CurItemPrice;
	return true;
}

function checkeditlistForm(){
				var MylistTitle = document.getElementById('MylistTitle');
				//var MylistDescription = document.getElementById('MylistDescription');
				var MylistImageUrl = document.getElementById('MylistImageUrl');
		
		
				if(MylistTitle && MylistTitle.value==""){
					alert("MylistTitle should not be empty.");
					MylistTitle.focus();
					return false;
				}
			/*	if(MylistDescription.value==""){
					alert("Description should not be empty.");
					MylistDescription.focus();
					return false;
				}*/
			/*	if(MylistImageUrl.value==""){
					alert("image URL should not be empty.");
					MylistImageUrl.focus();
					return false;
				}*/
		
			return true;//alert('gfdgf');
		
	}
	
	function checksendtofriendForm() {
		
			if(document.getElementById('MylistId'))
				var MylistId= document.getElementById('MylistId');
			var MylistEmailThemeId = document.getElementById('MylistEmailThemeId');
			var MylistEmailAddresses = document.getElementById('MylistEmailAddresses');
			var MylistEmailSubject = document.getElementById('MylistEmailSubject');
			var MylistEmailMessage = document.getElementById('MylistEmailMessage');
			
			
			if(document.getElementById('MylistId')){
				if(MylistId.value==""){
					alert("Please select any list.");
					MylistId.focus();
					return false;
				}				
			}
			if(MylistEmailThemeId.value==""){
				alert("Please select email theme.");
				MylistEmailThemeId.focus();
				return false;
			}
			
			if(trim(MylistEmailAddresses.value)=="" || trim(MylistEmailAddresses.value)=="Enter multiple addresses separated by commas"){
				alert("Email addresse(s) should not be empty.");
				MylistEmailAddresses.focus();
				return false;
			}
			em_array = MylistEmailAddresses.value.split(",");
			for(em=0;em<em_array.length;em++){
				current_mail = trim(em_array[em]);
				if(!checkEmail(current_mail)){
					alert("Please enter valid E-mail address for "+current_mail+".");
					//MylistEmailAddresses.focus();
					return false;
				}
			}
			if(MylistEmailSubject.value==""){
				alert("Email subject should not be empty.");
				MylistEmailSubject.focus();
				return false;
			}
			if(MylistEmailMessage.value==""){
				alert("Email message should not be empty.");
				MylistEmailMessage.focus();
				return false;
			}
		
		return true;
	}
	
	
	
		function checksendtofriend_grpForm() {
			//alert("Please select any list.");
			var MylistEmailAddresses = document.getElementById('MylistEmailAddresses');
			var MylistEmailMessage = document.getElementById('MylistEmailMessage');
			
			if(trim(MylistEmailAddresses.value)=="" || trim(MylistEmailAddresses.value)=="Enter multiple addresses separated by commas"){
				alert("Email addresse(s) should not be empty.");
				MylistEmailAddresses.focus();
				return false;
			}
			em_array = MylistEmailAddresses.value.split(",");
			for(em=0;em<em_array.length;em++){
				current_mail = trim(em_array[em]);
				if(!checkEmail(current_mail)){
					alert("Please enter valid E-mail address for "+current_mail+".");
					//MylistEmailAddresses.focus();
					return false;
				}
			}
		
			if(MylistEmailMessage.value==""){
				alert("Email message should not be empty.");
				MylistEmailMessage.focus();
				return false;
			}
		
		return true;
	}
	

function checksearchForm(){
		var SearchSearch = document.getElementById('SearchSearch');
		
			if(SearchSearch.value==""){
					alert("Search should not be empty.");
					SearchSearch.focus();
					return false;
				}
		location.href=HTTP_BASE+'search/index/'+SearchSearch.value;
		return true;
	
	}
function checksearchForm2(){
		var SearchSearch = document.getElementById('SearchSearch2');
		
			if(SearchSearch.value==""){
					alert("Search should not be empty.");
					SearchSearch.focus();
					return false;
				}
		location.href=HTTP_BASE+'search/index/'+SearchSearch.value;
		return true;
	
	}
	
function checkeditaccountForm(){
			var UserUserName = document.getElementById('UserUserName');
			var UserFirstName = document.getElementById('UserFirstName');
			var UserLastName = document.getElementById('UserLastName');
			var UserDateOfBirthMonth = document.getElementById('UserDateOfBirthMonth');
			var UserDateOfBirthDay = document.getElementById('UserDateOfBirthDay');
			var UserDateOfBirthYear = document.getElementById('UserDateOfBirthYear');
			
			checkeditaccountForm
			if(UserUserName.value==""){
				alert("E-mail address should not be empty.");
				UserUserName.focus();
				return false;
			}
			
			if(UserFirstName.value==""){
				alert("First name should not be empty.");
				UserFirstName.focus();
				return false;
			}
			if(UserLastName.value==""){
				alert("Last name should not be empty.");
				UserLastName.focus();
				return false;
			}
		/*	if(UserDateOfBirthMonth.value==""){
				alert("Month should not be empty.");
				UserDateOfBirthMonth.focus();
				return false;
			}
			if(UserDateOfBirthDay.value==""){
				alert("Day should not be empty.");
				UserDateOfBirthDay.focus();
				return false;
			}
			if(UserDateOfBirthYear.value==""){
				alert("Year should not be empty.");
				UserDateOfBirthYear.focus();
				return false;
			}*/
		return true;
}


function checkeditemForm(){
	
//alert('fgdhgd');
	var	OrgItemPrice;
	var	CurItemPrice;
	var ItemTitle = document.getElementById('ItemTitle');
	var ItemListId = document.getElementById('ItemListId');
	var ItemDescription = document.getElementById('ItemDescription');
	var ItemQuantity = document.getElementById('ItemQuantity');
	var ItemPriority = document.getElementById('ItemPriority');
	var ItemPrice = document.getElementById('ItemPrice');
	var ItemTags = document.getElementById('ItemTags');
	var location = document.getElementsByName('data[Item][location][]');
	var ItemWeb = document.getElementById('ItemWeb');
	var computer_0 = document.getElementById('computer_0');
	var computer_1 = document.getElementById('computer_1');
	var ItemImageUrl = document.getElementById('ItemImageUrl');

	if(ItemListId && ItemListId.value==""){
		alert("Please select list.");
		ItemListId.focus();
		return false;
	}
	if(ItemTitle.value==""){
		alert("ItemTitle should not be empty.");
		ItemTitle.focus();
		return false;
	}
/*	if(ItemTitle.value.length>60){
		alert("Item Title should be with in 60 charcters.");
		ItemTitle.focus();
		return false;
	}*/
/*	if(ItemDescription.value==""){
		alert("ItemDescription should not be empty");
		ItemDescription.focus();
		return false;
	}*/
	if(ItemQuantity.value==""){
		alert("Please enter the quantity desired");
		ItemQuantity.focus();
		return false;
	}
	
	if(isNaN(ItemQuantity.value) || parseInt(ItemQuantity.value)<=0)
	{
		alert('Please enter valid Quantity in numericals');
		ItemQuantity.focus();
		return false;
	}
	/*	
	if(ItemPriority.value==""){
		alert("Priority should not be empty");
		ItemPriority.focus();
		return false;
	}
	if(isNaN(ItemPriority.value)){
		alert("Please enter Priority in numericals");
		ItemPriority.focus();
		return false;
	}
	*/
	/*
	if(ItemPrice.value==""){
		alert("Please enter Item Price");
		ItemPrice.focus();
		return false;
	}
	*/
	OrgItemPrice = ItemPrice.value;
	CurItemPrice = ItemPrice.value;
	CurItemPrice = CurItemPrice.replace(/\$/g,"");
	CurItemPrice = CurItemPrice.replace(/,/g,"");
		
	if(isNaN(CurItemPrice) || parseFloat(CurItemPrice)<0)
	{
		//alert(CurItemPrice);
		alert('Please enter valid Price in numericals');
		ItemPrice.focus();
		return false;
	}
	
	/*
	if(ItemWeb.value && computer_1.checked==true){
		if(!checkFileType(ItemWeb.value)){
			alert('Please enter valid web URL for your image');
			ItemWeb.focus();
			return false;
		}
	}
	*/
	if(ItemImageUrl.value && computer_0.checked==true){
		if(!checkFileType(ItemImageUrl.value)){
			alert('Please select images of type gif, jpg, jpeg, png only.');
			ItemImageUrl.focus();
			return false;
		}
	}
	
	/*if(ItemTags.value==""){
		alert("Tags should not be empty");
		ItemTags.focus();
		return false;
	}*/
	
	for(loc=0;loc<location.length;loc++){
		if(location[loc].value!=""){
			if(!checkURL(location[loc].value)){					 
				alert("Please enter a valid URL");
				location[loc].focus();
				return false;
			}
		}
	}
	
	ItemPrice.value = CurItemPrice;
	return true;
}


function checkedsenditemtofriendForm(){
	//alert('dfhgfdhg');
			var MylistEmailThemeId = document.getElementById('ItemEmailThemeId');
			var MylistEmailAddresses = document.getElementById('ItemEmailAddresses');
			var MylistEmailSubject = document.getElementById('ItemEmailSubject');
			var MylistEmailMessage = document.getElementById('ItemEmailMessage');
			
			
			if(MylistEmailThemeId.value==""){
				alert("Please select email theme.");
				MylistEmailThemeId.focus();
				return false;
			}
			
			if(trim(MylistEmailAddresses.value)=="" || trim(MylistEmailAddresses.value)=="Enter multiple addresses separated by commas"){
				alert("Email addresse(s) should not be empty.");
				MylistEmailAddresses.focus();
				return false;
			}
			em_array = MylistEmailAddresses.value.split(",");
			for(em=0;em<em_array.length;em++){
				current_mail = trim(em_array[em]);
				if(!checkEmail(current_mail)){
					alert("Please enter valid E-mail address for "+current_mail+".");
					//MylistEmailAddresses.focus();
					return false;
				}
			}
			if(MylistEmailSubject.value==""){
				alert("Email subject should not be empty.");
				MylistEmailSubject.focus();
				return false;
			}
			if(MylistEmailMessage.value==""){
				alert("Email message should not be empty.");
				MylistEmailMessage.focus();
				return false;
			}
		
		return true;
	
	}
	
function checkedsendlistsForm(){
		
		//alert('fhjgh');
			var MylistId = document.getElementById('MylistId');
			var MylistEmailThemeId = document.getElementById('MylistEmailThemeId');
			var MylistEmailAddresses = document.getElementById('MylistEmailAddresses');
			var MylistEmailSubject = document.getElementById('MylistEmailSubject');
			var MylistEmailMessage = document.getElementById('MylistEmailMessage');
			
			
			
			if(MylistId.value==""){
				alert("Please select lists.");
				MylistId.focus();
				return false;
			}
			if(MylistEmailThemeId.value==""){
				alert("Please select email theme.");
				MylistEmailThemeId.focus();
				return false;
			}
			
			if(trim(MylistEmailAddresses.value)=="" || trim(MylistEmailAddresses.value)=="Enter multiple addresses separated by commas"){
				alert("Email addresse(s) should not be empty.");
				MylistEmailAddresses.focus();
				return false;
			}
			em_array = MylistEmailAddresses.value.split(",");
			for(em=0;em<em_array.length;em++){
				current_mail = trim(em_array[em]);
				if(!checkEmail(current_mail)){
					alert("Please enter valid E-mail address for "+current_mail+".");
					//MylistEmailAddresses.focus();
					return false;
				}
			}
			if(MylistEmailSubject.value==""){
				alert("Email subject should not be empty.");
				MylistEmailSubject.focus();
				return false;
			}
			if(MylistEmailMessage.value==""){
				alert("Email message should not be empty.");
				MylistEmailMessage.focus();
				return false;
			}
		
		return true;
}


function checkedaddcommentForm(){
		
		var addComment = document.getElementById('addComment');
		
		if(addComment.value==""){
				alert("Comment should not be empty.");
				addComment.focus();
				return false;
		}
			
		return true;
}
function checkedaddgroupForm(){
	var GroupGroupTitle = document.getElementById('GroupGroupTitle');
	var GroupGroupDesc = document.getElementById('GroupGroupDesc');
	var donations = document.getElementById('pay_type_0');
	var noonlinedonations = document.getElementById('pay_type_1');
	var ItemsPaymentPayToPaypal = document.getElementById('ItemsPaymentPayToPaypal');
	var ItemsPaymentCheck = document.getElementById('ItemsPaymentCheck');
	var ItemsPaymentPayToCheque=document.getElementById('ItemsPaymentPayToCheque');
	var ItemsPaymentPayAddress=document.getElementById('ItemsPaymentPayAddress');

	if(GroupGroupTitle.value==""){
		alert("Group Title should not be empty.");
		GroupGroupTitle.focus();
		return false;
	}
	if(GroupGroupDesc.value==""){
		alert("Group Description should not be empty.");
		GroupGroupDesc.focus();
		return false;
	}
	if(donations.checked==true){
		if(ItemsPaymentPayToPaypal.value==""){
			alert("Please enter the PayPal Email Address.");
			ItemsPaymentPayToPaypal.focus();
			return false;
		}
		if(!checkEmail(ItemsPaymentPayToPaypal.value)){
			alert("Please enter valid E-mail address.");
			ItemsPaymentPayToPaypal.focus();
			return false;
		}
	}else if(ItemsPaymentCheck.checked==false){
		alert("Please select any one payment method.");
		return false;
	}
	if( ItemsPaymentCheck.checked==true){
		if(ItemsPaymentPayToCheque.value==""){
			alert("Please enter Make out Check To");
			ItemsPaymentPayToCheque.focus();
			return false;
		}
		if(ItemsPaymentPayAddress.value==""){
			alert("Please enter Mail Check To");
			ItemsPaymentPayAddress.focus();
			return false;
		}
	}
	return true;
}

function checkedchangepasswordForm(){
	
	var UserOldpassword = document.getElementById('UserOldpassword');
	var UserNewPassword = document.getElementById('UserNewPassword');
	var UserConfirmPassword = document.getElementById('UserConfirmPassword');
	//alert('fgdkhg');
	
		if(UserOldpassword.value==""){
			alert("Please enter your old password");
			UserOldpassword.focus();
			return false;
		}
		if(UserNewPassword.value==""){
			alert("Please enter your new password");
			UserNewPassword.focus();
			return false;
		}
		if(UserNewPassword.value.length<4){
			alert("Your password must be at least 4 characters");
			UserNewPassword.focus();
			return false;
		}
		if(UserConfirmPassword.value==""){
			alert("Please confirm your password");
			UserConfirmPassword.focus();
			return false;
		}
		if(UserNewPassword.value!=UserConfirmPassword.value){
			alert("The confirmed password does not match");
			UserConfirmPassword.focus();
			return false;
		}		
		return true;
}

function val_add_comments(frm)
{
	var addComment_field = document.getElementById('addComment');	
	if(trim(addComment_field.value)=="")
	{
		alert('Please enter your comments');
		addComment_field.focus();
		return false
	}
}

function checkedsubmitForm(){
	var ItemName = document.getElementById('ItemName');
	var ItemEmailid = document.getElementById('ItemEmailid');
		if(ItemName.value==""){
			alert("Please enter the your name");
			ItemName.focus();
			return false;
		}
			if(ItemEmailid.value==""){
			alert("Please enter the your E-mail address");
			ItemEmailid.focus();
			return false;
		}
		 if(!checkEmail(ItemEmailid.value)){
		alert("Please enter valid E-mail address.");
		ItemEmailid.focus();
		return false;
	}
	return true;
}

function onLoadedvars(){
	if(trim(document.getElementById('ItemWeb').value)==""){
		document.getElementById('my_img_privew_tag').innerHTML = '';
		document.getElementById('ItemWeb').value = '';
		num_calls=0;
	}else{
		var someInt_w = Number(document.getElementById("my_img_privew").width);
		var someInt_h = Number(document.getElementById("my_img_privew").height);
		//alert(someInt_w);
		if(someInt_w >=1){
			//mydiv_tag_resized
			
			var obj = sizer(someInt_w, someInt_h, 150, 100);
			document.getElementById("my_img_privew").width = Math.round(obj.new_W);
			document.getElementById("my_img_privew").height = Math.round(obj.new_H);
			document.getElementById("my_img_privew_tag").style.display = "block";
			
		} else {
			if(num_calls>10){
			    /*
				alert('Please enter valid web url.');
				document.getElementById('my_img_privew_tag').innerHTML = '';
				document.getElementById('ItemWeb').value = '';
				*/
				num_calls=0;
				
			}else{
				num_calls++;
				setTimeout ( "onLoadedvars()", 100 );
			}
		}
	}
}