//for trim.. Aug 2006
String.prototype.trim = function() {

 // skip leading and trailing whitespace
 // and return everything in between
  var x=this;
  x=x.replace(/^\s*(.*)/, "$1");
  x=x.replace(/(.*?)\s*$/, "$1");
  return x;
}

//Functions used on admin panel. - Start
function login()
{
	var msg="";

  if(document.loginfrm.username.value.length==0)
	msg+="Enter Username!\n";
  if(document.loginfrm.password.value.length==0)
	msg+="Enter Password!\n";

	if(msg.length>0)
	{
		alert(msg);
		return false;
	}
	else
	{			
	//	document.loginfrm.submit();
		return true;
	}

}

/***************************************************************************/
function registration_a()
{
var msg="";
if(document.registerfrm.username.value.length==0)
	msg+="Enter Username\n";
if(document.registerfrm.password.value.length==0)
{
	msg+="Enter Password\n";
}
else
{
	if(document.registerfrm.password.value != document.registerfrm.cpassword.value)
	msg+="Passwords does not match\n";
}
if(document.registerfrm.firstname.value.length==0)
	msg+="Enter First Name\n";
if(document.registerfrm.lastname.value.length==0)
	msg+="Enter Last Name\n";
if(document.registerfrm.email.value.length==0)
	msg+="Enter Email\n";
if(msg.length>0)
	alert(msg)
else
	document.registerfrm.submit();		
}




//	TO SELECT FROM SELECTION BOX
function selectmenu(obj,val)
{
  var len=obj.options.length

  for(var i=0;i<len;i++)
  {
    if(obj.options[i].value==val)
     {
       obj.selectedIndex=i;
     }
  } 
}

/***************************************************************************/

function forgotpassword()
{
  if(document.forgotpass_frm.username.value=="" || document.forgotpass_frm.temailaddress.value=="")
  {
    alert("Enter both Username and Email address");
	return false;
  }
	else
	{
		return true;	
	}
}

 /**************************EMAIL CHECKING***************************/
 
 function checkmail(fldname,dothis)
  {  

	//for all email fields in any forms - BOTH FOR ADMIN/USERS
	
	var msg = "";  	
	email = fldname.value;

	var len = email.length;              

	if(len<5)
		{
			msg += "Invalid Email - id!\n";
		}
	else
		{
          
	var index1 = email.indexOf('@');
	var subind = email.substring(0,index1);
	var indlen = subind.length;
	var index2 = email.indexOf('.');
	var subind1=email.substring(indlen+1,index2);
	var indlen1 = subind1.length;
	var index3 = email.indexOf(' ');
	var subind3=email.substring(index2+1,len)
	var indlen2 = subind3.length;
	if((index1!= -1)&&(index2!= -1)&&(index3==-1))
	{	
		if((indlen!=0)&&(indlen1!=0)&&(indlen2!=0))
		{
//   			alert("valid Email -id");		  	 	
		} 
        else
		{
			msg += "Invalid Email - id!\n";
		}
	}
	else
	{
   		msg += "Invalid Email - id!\n";
	}		
	} // end of else if len<5

	if(dothis == "string")
	{
		return msg;
	}

	if(msg.length > 0)
	{
			fldname.value="";
			
			alert(msg);
	}

  }	

/***************************************************************************/
function numcheck(obj,val)
  {
    var msg = "";
    if(isNaN(obj.value)|| (obj.value.indexOf(' ')!=-1))
	{
	  msg = "Enter numeric values!\n";
          obj.value = "";          
    }
	
	if(val == "string") //changed on 240805
	return msg;

    if (obj.value <= 0)
	{
	  obj.value = "";
	}
        
	
    if(msg.length > 0)
		alert(msg);

  }


function popupwindow(obj)
{
	window.open(obj, '', "scrollbar=no, menu=no, status=no, resizable=no, width=350, height=250");
}



function confirm_on_del(val)
{

	if(val.length==0)
	val = "Are you sure?";
	
		if(confirm(val))
			return true;
		else
			return false;
}

function alert_delete(val1,val2,val3)
{

if(confirm_on_del(''))
{
str=val2+"&id="+val1+"&type="+val3;
//alert(str);
window.location.href=str;

}

}

function paging_purpose(val)
{

	document.records.row.value=val;
	document.records.submit();

}

function manager_reg(val)
{
var dc;
var msg="";

dc = document.barnmanager_regfrm;

var re1 = /[a-zA-Z0-9 ]/g;

var specialString_username = dc.barn_username.value.replace(re1, "");


	if(dc.barn_username.value.length==0)
		msg+="Please enter username!\n";

	if(dc.barn_password.value.length==0)
		msg+="Please enter password!\n";

	var specialString_password = dc.barn_password.value.replace(re1, "");


//	if(dc.password.value.length==0)
	if(dc.barn_password.value != dc.cpassword.value)
		msg+="Passwords do not match!\n";


	if(dc.barn_name.value.length<3)
		msg+="Please enter Barn Name at least 3 characters long!\n";

	var specialString_barn_name= dc.barn_name.value.replace(re1, "");

if(val > 0)
{ //if member logged in the following fields should be validated

	if(dc.description.value.length==0)
		msg+="Please enter description!\n";

	if(dc.address.value.length==0)
		msg+="Please enter address!\n";
	
	if(dc.zip.value.length==0)
		msg+="Please enter zipcode!\n";
	
	if(dc.state.value.length==0)
		msg+="Please choose state!\n";
	
	if(dc.country.value.length==0)
		msg+="Please choose country!\n";
/* Script error noticed on 200405. Form field removed by them.
	if(dc.phone.value.length==0)
		msg+="Please enter phone!\n";
*/
/* commented on 21032005
	if(dc.photo.value.length==0 && dc.hid_barn_photo.value.length==0)
		msg+="Please upload a photograph of the barn!\n";
*/

} //end if val > 0

	if(dc.email.value.length==0)
		msg+="Please enter email!\n";

	if(dc.email.value.length > 0)
		msg += checkmail(dc.email,"string");

	if (specialString_username.length > 0 || specialString_password.length > 0 || specialString_barn_name.length > 0) 
	{
		msg+="Special Characters are not allowed(e.g:@, %, &, $)\n";
	}

	if(msg.length > 0)
	{
	
		alert(msg);
		return false;
	
	}
	else
	{
	
		return true;
	
	}



}

function horse()
{

var dc,msg="";
dc = document.horse_regfrm;

	if(dc.name.value.length==0)
		msg+="Please enter horse name!\n";
	

	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

}


function validate_bid()
{

var msg,dc;

msg = "";
dc = document.bid_frm;

if(Math.abs(dc.current_bid_amount.value) <= Math.abs(dc.last_bid_amount.value))
	msg += "Please enter bid amount greater than the last bid!\n";
	
if(dc.current_bid_amount.value.length > 0)
	msg += chk_isdecimal(dc.current_bid_amount,"string");

if(dc.hid_buy_now.value == "1")
{

	return confirm('Are you sure you want to purchse this horse for ' +  dc.current_bid_amount.value +'.');

}

if(msg.length > 0)
{
	alert(msg);
	return false;
}
else
{
	return true;
}

}

//specific paging functions - 050705
function paging_user_horses(val)
{

	document.records_userhorses.row.value=val;
	document.records_userhorses.submit();

}

function add_remove_listing(obj,uname,frm_name)
{

var page_all_user,temp_page_all_user="";
var all_user_search,final_str;
var page_user_array = new Array();
//alert(uname);
//alert(document.records.add_del_cust.value);

//page_all_user=document.records.add_del_cust.value;
var str1;
str1 = "document." + frm_name + ".selected_checkbox_values.value";
page_all_user_selected=eval(str1);

all_user_search=eval(str1);

temp_page_all_user=eval(str1);


		if(obj.checked==true)
		{
			temp_page_all_user+=uname+"|";
		}
		else
		{		
				temp_page_all_user="";
				page_all_user_selected_arr=page_all_user_selected.split("|");
				for(j=0;j<(page_all_user_selected_arr.length);j++)
				{
					//alert(page_all_user_selected_arr[j]+" uncheck");
					
					if(page_all_user_selected_arr[j]!=uname)
					{
						if(page_all_user_selected_arr[j].length > 0)
						temp_page_all_user+=page_all_user_selected_arr[j]+"|";
					}
					
				}

		}



		final_str = "document." + frm_name + ".selected_checkbox_values.value=\"" + temp_page_all_user + "\"";

		eval(final_str);

}


function status_dropdown_event(dropdown_value,horse_id,frm_name)
{

	var dc;
	if(horse_id > 0)
	{
		dc = eval("document." + frm_name);
		//index of the config variable "horse_status_aray" refers here...
			
			if(dropdown_value == 1)
			{ //forsale has been selected
			
				dc.set_price_horse.value = horse_id;
				dc.action = "set_bid_price.php";
				dc.submit();
			
			} //end if(dropdown_value == 1)
			
			else if(dropdown_value == 2)
			
			{
			
				dc.selected_horse_id.value = horse_id;
				dc.action = "pay_bill_action.php";
				dc.submit();
			
			} //end else if(dropdown_value == 2)
			else if(dropdown_value == 4)
			{//upon confirmation set horse to retired. - 280206
			
				var confirm_retirement = false;
				
				confirm_retirement = confirm("Are you sure you want to retire this horse? \n \n The horse will be removed from your account if you retire it!");
				
				if(confirm_retirement)
				{
					dc.selected_horse_id.value = horse_id;
					dc.action = "retire_horse.php";
					dc.submit();
				}								
			}
			else if(dropdown_value == 5)
			{//if show is selected display the horses show schedule. - 010306
				window.location.href = "show_schedule_list.php?hid=" + horse_id;
			}
			else if(dropdown_value == 6)
			{//if show is selected display the horses show schedule. - 010306
				window.location.href = "shows_list.php?hid=";
			}
			else if(dropdown_value == 7)
			
			{
			
				window.location.href = "sterilize_horse.php?hid=" + horse_id;
			
			} //end else if(dropdown_value == 7)
			
	} //end if(horse_id > 0)
	
} //end function status_dropdown_event


function validate_msg()
{
var msg="";

	if(document.messages.subject.value.trim().length==0)
		msg+="Please enter subject!\n";

	if(document.messages.message.value.trim().length==0)
		msg+="Please enter your message!\n";

	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

}

//to delete multiple messages at a time
function del_messages()
{

if(confirm_on_del(''))
{

document.records_barnmessages.action = "delete_message.php";
document.records_barnmessages.submit();

}

}


//changes from 220805
function popupwindow_chat(obj)
{
	window.open(obj, '', "scrollbar=yes, menu=no, status=no, resizable=yes, width=540, height=550");
}
//function added on 240805
function validate_pasture()
{

	var dc = document.pasture_frm, msg = "";
	
	var tot_acre = (Math.abs(dc.used_acres.value) + Math.abs(dc.acres.value));
	
	if(dc.acres.value.length == 0)
		msg += "Please enter acres!\n";
	
	if(dc.acres.value.length > 0)
	msg += numcheck(dc.acres,"string");


/*	
	if(dc.acres.value > 100) //acres cant exceed 100 - as per document in the third phase - 310805
	msg += "Acres are limited to \"100\". You cannot set more than that!\n"; 
*/	
	if(dc.acres.value <= 0) //acres cant exceed 100 - as per document in the third phase - 310805
	msg += "Please enter a positive value!\n"; 

	//cummulative of acres in pasturea and crop shuld be the limit set in barnamanger table - 121105
	if(tot_acre > dc.alloted_acres.value)
	msg += "Acres are limited to \"" + dc.alloted_acres.value + "\". You cannot set more than that!\n"; 

	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function validate_pasture

//function added on 310805
function validate_studfee()
{

	var dc, msg = "";
	
	dc = document.studfee_frm;
	
	if(dc.stud_fee.value.length == 0)
		msg += "Please enter stud fee!\n";
	
	if(dc.stud_fee.value.length > 0)
	msg += numcheck(dc.stud_fee,"string");
	
	if(dc.stud_fee.value < 0)
	msg += "Please enter stud fee greater than or equal to \"0\"!\n"; 
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function validate_studfee


var validate_breedhorse = true; //specific for the horse selection for the breed purpose

function validate_breed_horse()
{

var msg = "", dc, validate;

dc = document.records_userhorses;

if(validate_breedhorse)
msg += "Please choose a horse to breed!";

if(msg.length > 0)
{
	alert(msg);
}
else
{

	dc.action = 'breed_tothis_horse_action.php';
	dc.submit();
	
}

} //end function validate_breed_horse

//functions added on 010905
function validate_hname()
{

	var dc, msg = "";
	
	dc = document.name_frm;
	
	if(dc.horse_name.value.length == 0)
		msg += "Please enter name!\n";
	
	var re1 = /[a-zA-Z0-9 ]/g;
	
	var specialString = dc.horse_name.value.replace(re1, "");

	if (specialString.length > 0) 
	{
		msg+="Special Characters are not allowed(e.g:@, %, &, $)\n";
	}
	

	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function validate_studfee

function validate_shows()
{

	var dc, msg = "";
	
	dc = document.shows_detail_frm;
	
	if(dc.show_name.value.length == 0)
		msg += "Please enter name!\n";
	
	if(dc.first_place.value.length > 0)
		msg += numcheck(dc.first_place,"string");
	
	if(dc.second_place.value.length > 0)
		msg += numcheck(dc.second_place,"string");
	
	if(dc.third_place.value.length > 0)
		msg += numcheck(dc.third_place,"string");
	
	if(dc.rest_places.value.length > 0)
		msg += numcheck(dc.rest_places,"string");
	
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function validate_shows

//200905 - functions added in the development of 4th phase

function validate_feedback()
{

var msg = "", dc = document.negative_feedback_frm;

if(dc.comments.value.length == 0)
	msg += "Please enter feedback!\n";

if(msg.length > 0)
{
	alert(msg);
	return false;
}	
else
{
	return true;
}

} //end function validate_feedback

function validate_settings()
{

var msg ="", dc = document.form1;

if(dc.payment_email.value.length > 0)
	msg += checkmail(dc.payment_email,"string");

if(msg.length > 0)
{
	alert(msg);
	return false;
}
else
{
	return true;
}

}

//210905 - Start

function validate_discipline()
{

	var dc, msg = "";
	
	dc = document.discipline_frm;
	
	if(dc.discipline_rate.value.length == 0)
		msg += "Please enter discipline fee!\n";
	
	if(dc.discipline_rate.value < 0 && dc.discipline_rate.value.length > 0)
	msg += "Please enter a positive value!\n"; 
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function validate_discipline

//function added during the development of fifth phase development. - 171005
function chk_salary()
{

var msg = "";
var dc = document.salary_frm;

if(dc.salary.value.length == 0)
	msg += "Please enter salary!\n";

if(dc.salary.value.length > 0)
	msg += numcheck(dc.salary,'string');

if(msg.length > 0)
{
	alert(msg);
	return false;
}	
else
{
	return true;
}

} //end function salary

//251005
function chk_crop()
{

var dc,msg="";
dc = document.crop_detail_frm;

	if(dc.crop_name.value.length==0)
		msg += "Please enter crop name!\n";

	if(dc.yield.value.length==0)
		msg += "Please enter yield!\n";
	
	if(dc.yield.value.length > 0)
		msg += numcheck(dc.yield,"string");
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

}

function validate_crop()
{

var dc = document.crop_frm;
var msg = "";
var tot_acre = (Math.abs(dc.used_acres.value) + Math.abs(dc.acres.value));

if(dc.acres.value.length == 0)
	msg += "Please enter acres!\n";

if(dc.acres.value.length > 0)
	msg += numcheck(dc.acres,"string");
//241205 - user can set the crop acre to "0"
if(dc.acres.value < 0) //acres cant exceed 100 - as per document in the third phase - 310805
	msg += "Please enter a number greater than or equal to '0'!\n"; 

//cummulative of acres in pasturea and crop shuld be the limit set in barnamanger table - 121105
if(tot_acre > dc.alloted_acres.value)
	msg += "Acres are limited to \"" + dc.alloted_acres.value + "\". You cannot set more than that!\n"; 


if(msg.length > 0)
{
	alert(msg);
	return false;
}
else
{
	return true;
}

} //end function validate_crop

function chk_isdecimal(obj,dothis)
{  

	var msg = "", num;  	
	num = obj.value;
	
	var index = num.indexOf('.');
	
	msg += numcheck(obj,"string");
	
	if(index != -1)
		msg += "Do not enter any float values!\n";

	if(dothis == "string")
	{
		return msg;
	}

	if(msg.length > 0)
	{
			fldname.value="";
			
			alert(msg);
	}

}

function chk_bid_amount()
{
var dc = document.initial_price_frm, msg = "";

if(dc.bid_start_amount.value.length > 0)
	msg+=chk_isdecimal(dc.bid_start_amount,"string");

if(msg.length > 0)
{
	alert(msg);
	return false;
}
else
{
	return true;
}

}


function validate_showbid()
{

var msg,dc;

msg = "";
dc = document.bid_frm;

if(Math.abs(dc.bid_amount.value) <= Math.abs(dc.last_bid_amount.value))
	msg += "Please enter bid amount greater than the last bid!\n";
	
if(dc.bid_amount.value.length > 0)
	msg += chk_isdecimal(dc.bid_amount,"string");

if(msg.length > 0)
{
	alert(msg);
	return false;
}
else
{
	return true;
}

}

function validate_show_name()
{
	if(document.show_frm.show_name.value.length == 0) 
	{ 
		alert('Please enter a show name!\n'); 
		return false; 
	} 
	else 
		return true;
}

//functions added from 130206

function chk_registry(frmname)
{

var msg = "", dc = eval("document." + frmname); 

	if(dc.registryname.value.length == 0)
		msg += "Please enter registry name!\n";

	if(dc.registrybreed.value.length == 0)
		msg += "Please select a breed type!\n";

	if(dc.id.value.length > 0)
	{
	
	if(parseInt(dc.registryfee.value) <= 0 || isNaN(dc.registryfee.value))
		msg += "Please enter fee greater than 0!\n";

	if(dc.description.value.length == 0)
		msg += "Please enter description!\n";
	}

if(msg.length > 0)
{
	alert(msg);
	return false;
}
else
{
	return true;
}

}

function validate_usershows(frmname)
{

 var dc = eval("document." + frmname), msg = "";
 
 if(dc.show_name.value.length == 0)
 	msg += "Please enter name!\n";
 
 if(dc.breed.value.length == 0)
 	msg += "Please select breed!\n";
 
 if(dc.entry_fee.value.length == 0)
 	msg += "Please enter entry fee!\n";
else
{
	if(isNaN(dc.entry_fee.value) || dc.entry_fee.value.indexOf(' ')!=-1 || dc.entry_fee.value.indexOf('.') != -1)
	msg += "Please enter numeric values for entry fee(decimal values not allowed)!\n";
	else if(Math.abs(dc.entry_fee.value) > 250)
		msg+="Maximum Entry fee is 250!\n";

}
 
 if(dc.first_prize.value.length == 0)
 	msg += "Please enter first place prize amount!\n";
else
{
	if(isNaN(dc.first_prize.value) || dc.first_prize.value.indexOf(' ')!=-1 || dc.first_prize.value.indexOf('.') != -1)
	msg += "Please enter numeric values for first place prize amount(decimal values not allowed)!\n";
}
 
 if(dc.second_prize.value.length == 0)
 	msg += "";//Please enter second place prize amount!\n
else
{
	if(isNaN(dc.second_prize.value) || dc.second_prize.value.indexOf(' ')!=-1 || dc.second_prize.value.indexOf('.') != -1)
	msg += "Please enter numeric values for second place prize amount(decimal values not allowed)!\n";
}

 if(dc.third_prize.value.length == 0)
 	msg += "";//Please enter third place prize amount!\n
else
{
	if(isNaN(dc.third_prize.value) || dc.third_prize.value.indexOf(' ')!=-1 || dc.third_prize.value.indexOf('.') != -1)
	msg += "Please enter numeric values for third place prize amount(decimal values not allowed)!\n";
}

 
 if(msg.length > 0)
 {
 	alert(msg);
	return false;
 }
 else
 {
 	return true;
 }

}

function injury(frmname)
{

var dc = eval("document." + frmname), msg = "";
	if(dc.injury_name.value.length == 0)
		msg += "Please enter a name!\n";
	
	if(dc.penalty.value.length == 0)
		msg += "Please enter penalty!\n";
	else if(!is_numeric(dc.penalty, false))
		msg += "Please enter numeric values for penalty(decimal values not allowed)!\n";

	if(dc.total_horses.value.length == 0)
		msg += "Please enter affected horses!\n";
	else if(!is_numeric(dc.total_horses, false))
		msg += "Please enter numeric values for affected horses(decimal values not allowed)!\n";

	if(dc.vet_cost.value.length == 0)
		msg += "Please enter vet cost!\n";
	else if(!is_numeric(dc.vet_cost, false))
		msg += "Please enter numeric values for vet cost(decimal values not allowed)!\n";


if(msg.length > 0)
{
	alert(msg);
	return false;
}
else
{
	return true;
}
}

function is_numeric(obj, deci_bool)
{
	if(isNaN(obj.value) || obj.value.indexOf(' ') != -1 || (obj.value.indexOf('.') != -1 && !deci_bool))
		return false;
	else
		return true;

}

function doselection(obj,frmname)
{
	
	var dc = eval("document." + frmname);
	
	if(obj.value.indexOf('|') == "-1")
		window.location.href = obj.value;
	else
	{
		
		dc.selected_checkbox_values.value = obj.value + "|";
		dc.submit_action.value = 'send';
		dc.submit();
		
	}

}

function chk_member_admin(frmname)
{
	
	var msg = "", dc = eval("document." + frmname);
	
	if(dc.barn_username.value.length==0)
		msg+="Please enter username!\n";

	if(dc.barn_password.value.length==0)
		msg+="Please enter password!\n";

	if(dc.barn_name.value.length==0)
		msg+="Please enter barn name!\n";

	if(dc.email.value.length==0)
		msg+="Please enter email!\n";

	if(dc.email.value.length > 0)
		msg += checkmail(dc.email,"string");

	if(!is_numeric(dc.ponybuck_amount, false))
		msg += "Please enter numeric values for ponybuck(decimal values not allowed)!\n";

	if(msg.length > 0)
	{
	
		alert(msg);
		return false;
	
	}
	else
	{
	
		return true;
	
	}

}



function chk_barn_news(frmname)
{

	var msg = "", dc = eval("document." + frmname);
	
	if(dc.news_subject.value.trim().length==0)
		msg+="Please enter Subject!\n";
		
	if(dc.news_detail.value.trim().length==0)
		msg+="Please enter News!\n";
	else if(dc.news_detail.value.length > 5000)	
		msg+="News should not exceed 5000 characters!\n";
				
	if(msg.length > 0)
	{
		alert(msg);
		return false;	
	}
	else
	{	
		return true;	
	}
	
}

function chk_mybarn(frmname)
{
	var msg = "", dc = eval("document." + frmname);

	if(dc.barn_description.value.length > 10000)	
		msg+="Barn Description should not exceed 10000 characters!\n";
		
	if(msg.length > 0)
	{
		alert(msg);
		return false;	
	}
	else
	{	
		return true;	
	}
		
}

function chk_aboutme(frmname)
{
	var msg = "", dc = eval("document." + frmname);

	if(dc.aboutme_description.value.length > 10000)	
		msg+="About Me description should not exceed 10000 characters!\n";
		
	if(msg.length > 0)
	{
		alert(msg);
		return false;	
	}
	else
	{	
		return true;	
	}
		
}

function chk_aboutme_photo(frmname)
{
	var msg = "", dc = eval("document." + frmname);

	if(dc.aboutme_photodescr.value.length > 10000)	
		msg+="Description should not exceed 10000 characters!\n";
		
	if(msg.length > 0)
	{
		alert(msg);
		return false;	
	}
	else
	{	
		return true;	
	}
		
}


function chk_horsedescription(frmname)
{
	var msg = "", dc = eval("document." + frmname);

	if(dc.horse_description.value.length > 5000)	
		msg+="Description should not exceed 5000 characters!\n";
		
	if(msg.length > 0)
	{
		alert(msg);
		return false;	
	}
	else
	{	
		return true;	
	}
		
}

//functions validate brand
function validate_brand()
{

	var dc, msg = "";
	
	dc = document.setbrand;
	
	if(dc.newbrand.value.length == 0)
		msg += "Please Enter Brand!\n";
		
	if(dc.newbrand.value.length > 5)
		msg += "Please Enter Brand!\n";
	
	var re1 = /[a-zA-Z0-9 ]/g;
	
	var specialString = dc.newbrand.value.replace(re1, "");

	if (specialString.length > 0) 
	{
		msg+="Special Characters are not allowed(e.g:@, %, &, $)\n";
	}
	

	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function validate brand

//functions validate forum report
function validate_forum_report()
{

	var dc, msg = "";
	
	dc = document.report_frm;
	
	if(dc.report_reason.value.length == 0)
		msg += "You must enter a reason!\n";
		
	if(dc.report_reason.value.length > 80)
		msg += "Your reason is too long!\n";
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function forum report

//functions validate forum report
function validate_forum_discussion()
{

	var dc, msg = "";
	
	dc = document.discussion_frm;
	
	if(dc.title.value.length == 0)
		msg += "You must enter a Title!\n";
		
	if(dc.title.value.length > 55)
		msg += "Your Title is too long!\n";
		
	if(dc.subject.value.length == 0)
		msg += "You must enter a Subject!\n";
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function forum report

//functions validate forum comment
function validate_forum_comment()
{

	var dc, msg = "";
	
	dc = document.comment_frm;
	
	if(dc.comment.value.length == 0)
		msg += "You must enter a Comment!\n";
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function forum comment

//functions validate blog report
function validate_blog_post()
{

	var dc, msg = "";
	
	dc = document.blog_frm;
	
	if(dc.title.value.length < 5)
		msg += "Your Blog Title is too short!\n";
		
	if(dc.title.value.length > 50)
		msg += "Your Title is too long!\n";
		
	if(dc.subject.value.length == 0)
		msg += "You must enter a Blog Subject!\n";
		
	if(dc.subject.value.length < 100)
		msg += "Your Blog Subject is too short!\n";
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function blog report

//functions validate aboutme_photo_comment
function validate_aboutme_photo_comment()
{

	var dc, msg = "";
	
	dc = document.aboutme_photo_comment_frm;
	
	if(dc.aboutme_comment.value.length < 10)
		msg += "Your Comment is too Short!\n";
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end aboutme_photo_comment

//functions validate_blog_comment
function validate_blog_comment()
{

	var dc, msg = "";
	
	dc = document.blog_comment_frm;
	
	if(dc.blog_comment.value.length < 10)
		msg += "Your Comment is too Short!\n";
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end validate_blog_comment

//functions validate say post
function validate_say_post()
{

	var dc, msg = "";
	
	dc = document.say_frm;
	
	if(dc.say_comment.value.length < 20)
		msg += "Your post is too short!\n";
		
	if(dc.say_comment.value.length > 255)
		msg += "Your post is too long!\n";
	
	if(msg.length > 0)
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}

} //end function say post