// JavaScript Document
//function for validate change password
function changepassword()
{
	if(document.getElementById('oldpass').value=="")
	{
		alert("Enter Old Password!");
		return false;
	}
	if(document.getElementById('newpass').value=="")
	{
		alert("Enter New Password!");
		return false;
	}
	
	if(document.getElementById('newpass').value!="")
	{
		
		if(document.getElementById('newpass').value.length < 6 )	
		{
			alert("Password must be minimium 6 charcter");
			return false;
		}
	}
	
	if(document.getElementById('confirmpass').value=="")
	{
		alert("Confirm new Password!");
		return false;
	}
	if(document.getElementById('confirmpass').value!=document.getElementById('newpass').value)
	{
		alert("Confirm Password not match!");
		return false;
	
	}
}
//*******************************fucniton for new page*****************//
function insertnewpage()
{
		if(document.getElementById('pagetitle').value=="")
		{
				alert("Enter Page Name!")
				return false;
		}
}
/**************confirm delete page*******************/
function confirmpagedelete(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='newpagelist.php?deletepage='+id;
		return true ;
	}
	else
		return false ;
}

/**************confirm Did You Know Text*******************/
function confirmdeletedidyouknow(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='didyouknow.php?deletedidyouknow='+id;
		return true ;
	}
	else
		return false ;
}

/**************confirm delete country *******************/
function confirmdeletecountry(id)
{	alert(id);
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='countrieslist.php?countrydelete='+id;
		return true ;
	}
	else
		return false ;
}

/**************confirm delete category *******************/
function confirmdeletecategory(id)
{

	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='addcategory.php?categorydelete='+id;
		return true ;
	}
	else
		return false ;
}

/**************confirm delete category *******************/
function confirmdeletesubcategory(id)
{

	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='add_subcategory.php?subcategorydelete='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm delete Goals *******************/
function confirmdeletegoals(id)
{

	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='add_subcategory.php?goalsdelete='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm delete Request *******************/
function confirmdeletemyreq(id)
{

	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='my_friend_requests.php?my_request='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm delete Request *******************/
function confirmdelete_monitor(id)
{

	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='monitor_my_friend_requests.php?my_request_momitor='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm Accept Request *******************/
function confirm_accetmyreq(id)
{

	if (id){
		window.location='friend_requests.php?accept_my_request='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm Reject Request *******************/
function confirm_rejectmyreq(id)
{

	if (id){
		window.location='friend_requests.php?reject_my_request='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm Accept Request *******************/
function confirm_accetreq_monitor(id)
{

	if (id){
		window.location='friend_requests.php?accept_myreq_monitor='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm Accept Request *******************/
function confirm_rejectreq_monitor(id)
{

	if (id){
		window.location='friend_requests.php?reject_myreq_monitor='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm delete Task *******************/
function confirmdelete_task(id,mid,title)
{

	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='goals_plans.php?tasks_delete='+id+'&mid='+mid+'&title='+title;
		return true ;
	}
	else
		return false ;
}

/**************confirm delete Goals *******************/
function confirmdelete_goal(id)
{

	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='my_goals.php?goal_delete='+id;
		return true ;
	}
	else
		return false ;
}

/**************confirm Share Goals *******************/
function confirmshare_goal(id)
{

	if (id){
		window.location='monitor_sharing_list.php?catid='+id+'&pa=share';
		return true ;
	}
	else
		return false ;
}
/**************confirm delete Goals *******************/
function confirmdeletetasks(id)
{

	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='add_subcategory.php?tasksdelete='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm delete industry *******************/
function confirmdeletejob(id)
{
	var agree=confirm("Are you sure to delete this Job?");
	if (agree){
		window.location='joblist.php?jobdelete='+id;
		return true ;
	}
	else
		return false ;
}

/**************confirm delete industry *******************/
function confirm_deluser(id)
{
	var agree=confirm("Are you sure to delete this Friend?");
	if (agree){
		window.location='friends_list.php?my_deluser='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm delete industry *******************/
function confirm_deluser_monitor(id)
{
	var agree=confirm("Are you sure to delete this Friend?");
	if (agree){
		window.location='friends_list.php?my_deluser_monitor='+id;
		return true ;
	}
	else
		return false ;
}
/**************confirm delete JOB *************************/
function confirmdeleteindustry(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='industries.php?industrydelete='+id;
		return true ;
	}
	else
		return false ;
}


/**************confirm delete FAQ Group*********************/
function confirmdeletefaqgroup(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='faqgrouplist.php?faqgroupdelete='+id;
		return true ;
	}
	else
		return false ;
}


/**************confirm delete job functions*******************/
function confirmjobfunction(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='jobfunctions.php?jobfunctiondelete='+id;
		return true ;
	}
	else
		return false ;
}


/**************confirm delete EVENT *******************/
function confirmdeleteevent(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='events.php?eventdelete='+id;
		return true ;
	}
	else
		return false ;
}

/*--------------------window pop up-------------*/
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=1000,height=700,left=150,top =50');");
}


/*---------------email validation function-----------------------*/
function echeck(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 Email ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid Email ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid Email ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid Email ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid Email ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid Email ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid Email ID")
		    return false
		 }

 		// return true					
	}
	
	

/*-------------------------CHK Event DATA------------------*/
function chkevent()
{	
	if(document.getElementById('eventname').value=="")
	{
		alert("Please Enter Event Name Properly.");
		return false
	}	
	
	if(document.getElementById('eventstartdate').value=="")
	{
		alert("Please Enter Event Opening Date Properly.");
		return false
	}
	
	if(document.getElementById('eventenddate').value=="")
	{
		alert("Please Enter Event Closing Date Properly.");
		return false
	}
	
	if(document.getElementById('eventvenue').value=="")
	{
		alert("Please Enter Event Venue Properly.");
		return false
	}
	
	return true;
}



	
/*----------------------------*/
function emailalerts()
{
	if(document.getElementById('emailadmin').value!="")
	{
		if (echeck(document.getElementById('emailadmin').value)==false)
			{
				document.getElementById('emailadmin').value=""
				return false
		   }
	}
	if(document.getElementById('emailuser').value!="")
	{
		if (echeck(document.getElementById('emailuser').value)==false)
			{
				document.getElementById('emailuser').value=""
				return false
		   }
	}
	
}
function submitfun()
{

	if(document.getElementById('txtemail').value=="")
	{
		alert('Email address field is empty. Please enter valid email address to process order.');
		return false;
	}
	else if (echeck(document.getElementById('txtemail').value)==false)
	{
		document.getElementById('txtemail').value="";
		return false;				

	}
	else
	{
		return true;
	}
	
}
function submitebookform(){
	alert('eeeeeeeeee');
	window.document.form.submit();
}
/***************validation for home page product page************/
function inserthomepage()
{

	if( document.getElementById('productno').value=="")
	{
		alert("Select Product Number!");
		return false;
	}
	
}
/***************validation for page category page************/
function insertcategorypage()
{

	if( document.getElementById('categoryname').value=="")
	{
		alert("Select Category Name!");
		return false;
	}
	
}

/***************validation for Industry************/
function chkindustry()
{

	if( document.getElementById('industryname').value=="")
	{
		alert("Add Industry Name Properly!");
		return false;
	}
	
	return true;
}


/***************validation for Industry************/
function chkdidyouknow()
{

	if( document.getElementById('didyouknow').value=="")
	{
		alert("Add Did You Know Details Properly!");
		return false;
	}
	
	return true;
}

/***************validation for FAQ Group************/
function chkfaqgroup()
{

	if( document.getElementById('faqgroupname').value=="")
	{
		alert("Give FAQ Group Name Properly!");
		return false;
	}
	
	return true;
}

/***************validation for FAQ's ***************/
function chkfaqs()
{

	if( document.getElementById('faqgroupid').value=="")
	{
		alert("Select FAQ Group Properly!");
		return false;
	}
	
	if( document.getElementById('faqquestion').value=="")
	{
		alert("Enter FAQ Question Properly!");
		return false;
	}
	
	if( document.getElementById('faqanswer').value=="")
	{
		alert("Enter FAQ Answer Properly!");
		return false;
	}
	
	return true;
}

/***************validation for Job Function************/
function chkjobfunction()
{

	if( document.getElementById('jobfunctionname').value=="")
	{
		alert("Add Job Function Name Properly!");
		return false;
	}
	
	return true;
}


//*************************************************************************************************************************
function insertnewuser()
	{
		var form=document.newadmin;
		var useremail=document.getElementById('txtHint').innerHTML;
		if(useremail.match('Not'))
		{
			alert("This E-mail is Already in use!")
			return false;
		}
		//alert(form.uemail.value);
		if (form.userlogin.value=="")
	    {
			alert("Enter User Name!")
			form.userlogin.focus();
			return false;
	     }
	   if (echeck(form.useremail.value)==false)
	    {
			form.useremail.value="";
			form.useremail.focus();
			return false;
	   }
		if(form.password.value=="")
		{
			alert("Enter password!");
			return false;
		}
		if(form.password.value!="")
		{
			if(form.password.value.length <6 )	
			{
				alert("Password must be minimium 6 charcter");
				return false;
			}
		}
		if(form.confirmpass.value=="")
		{
			alert("Enter Confirm password!");
			return false;
		}
		if(form.confirmpass.value!=form.password.value)
		{
			alert("Password is not match!")
			return false;
		}
}

/**************confirm delete Country*******************/
function confirmdeletecountry(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='countries.php?countrydelete='+id;
		return true ;
	}
	else
		return false ;
}

/**************confirm delete FAQ's*******************/
function confirmdeletefaqs(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='faqslist.php?faqsdelete='+id;
		return true ;
	}
	else
		return false ;
}


/**************confirm delete Admin user *******************/
function confirmdeleteuser(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='administrators_list.php?deleteuser='+id;
		return true ;
	}
	else
		return false ;
}

/**************confirm delete user *******************/
function confirmdeluser(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='user_list.php?deluser='+id;
		return true ;
	}
	else
		return false ;
}
//***********************delete product**********************/
function confirmdeleteproduct(id)
{
	var agree=confirm("Are you sure to delete this?");
	if (agree){
		window.location='productslist.php?deleteproduct='+id;
		return true ;
	}
	else
		return false
}
//******************************* for new *****************//
function insertnewattcat()
{
		if(document.getElementById('attcatname').value=="")
		{
				alert("Enter Category Name!")
				return false;
		}
}
//******************************* for new *****************//
function insertproductattribute()
{
		if(document.getElementById('attname').value=="")
		{
				alert("Enter Attribute Name!")
				return false;
		}
		if(document.getElementById('attriburecategory').value=="")
		{
				alert("Select  Attribute Category!")
				return false;
		}
}
//***********************selectall**********************/
function selectall(countnum)
	{
		if(document.getElementById('selall').checked==true)
		{
			for(i=1;i<=countnum;i++)
			{
				var sleall='ch';
				document.getElementById(sleall).checked=true;
			}
		}
		else
		{
			for(i=1;i<=countnum;i++)
			{
				var sleall='ch';
				document.getElementById(sleall).checked=false;
			}
		}
	}
//***********************selectall**********************/

	var checked=false;
	 function checkedAll(myform) 
	 {
		
		var aa= document.getElementById(myform);
		
		if (checked == false)
		{
			checked = true
		}
		else
		{
			checked = false
		}
		
		for (var i =0; i < aa.elements.length; i++) 
		{
			aa.elements[i].checked = checked;
		}
	}

//***********************Delete inbox**********************/

	function delMulticontacts(myform)
	{
		
		var DelId;
		var cd;
		cd=confirm("Are You Sure To Delete?");
		if(cd)
		{
					var tmp='';
					var aa= document.getElementById(myform);
					for (var i =0; i < aa.elements.length; i++) 
					{
						if(aa.elements[i].checked == true)
						{
							if (tmp == '' )
							{
								tmp= aa.elements[i].value;
							}
							else
							{
								tmp=tmp + ',' + aa.elements[i].value;
							}	
						}
					}
					
					
					
					if (tmp!='') 
					{
						
						//var arg = "action=Multidelcustomercontacts&MultiDelId="+tmp+"&sendap=25";
						window.location = "message.php?delall="+tmp;
					}
					else
					{
						alert("select atleast one contact Mail list.");
					}
				
				
		}


	}

//***********************Delete Send**********************/

	function delMulticontactssend(myform)
	{
		
		var DelId;
		var cd;
		cd=confirm("Are You Sure To Delete?");
		if(cd)
		{
					var tmp='';
					var aa= document.getElementById(myform);
					for (var i =0; i < aa.elements.length; i++) 
					{
						if(aa.elements[i].checked == true)
						{
							if (tmp == '' )
							{
								tmp= aa.elements[i].value;
							}
							else
							{
								tmp=tmp + ',' + aa.elements[i].value;
							}	
						}
					}
					
					
					
					if (tmp!='') 
					{
						
						//var arg = "action=Multidelcustomercontacts&MultiDelId="+tmp+"&sendap=25";
						alert(tmp);
						window.location = "message_send.php?senddelall="+tmp;
					}
					else
					{
						alert("Select Atleast one Mail from list.");
					}
				
				
		}


	}
//***********************Delete Send**********************/

	function delMulticontactstrash(myform)
	{
		
		var DelId;
		var cd;
		cd=confirm("Are You Sure To Delete?");
		if(cd)
		{
					var tmp='';
					var aa= document.getElementById(myform);
					for (var i =0; i < aa.elements.length; i++) 
					{
						if(aa.elements[i].checked == true)
						{
							if (tmp == '' )
							{
								tmp= aa.elements[i].value;
							}
							else
							{
								tmp=tmp + ',' + aa.elements[i].value;
							}	
						}
					}
					
					
					
					if (tmp!='') 
					{
						
						//var arg = "action=Multidelcustomercontacts&MultiDelId="+tmp+"&sendap=25";
						alert(tmp);
						window.location = "message_trash.php?trashdelall="+tmp;
					}
					else
					{
						alert("Select Atleast one Mail from list.");
					}
				
				
		}


	}
function chkcontactusfrm()
	  {
		  
			if(document.getElementById('name').value=='')
			{
				alert("Enter Name Properly.");
				return false;
			}
			
			if(document.getElementById('from').value=='')
			{
				alert("Enter Email Address Properly.");
				return false;
			}
			else
			{
				emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/	
				
				var recipiantemails = document.getElementById("from").value;
				
				var myemails = recipiantemails.split(",");
				
				for (var i=0;i<myemails.length;i++)
				{
					if(!emailRe.test(myemails[i]))
					{
						alert('Please enter a valid email address')
						return false;
					}
				}	
			}

		}
		
