function regisValidation()
{
	if(document.getElementById("firstName").value == "")
	{
		alert("Please enter First Name.");
		document.getElementById("firstName").focus();
		return false;
	}
	if(document.getElementById("lastName").value == "")
	{
		alert("Please enter Last Name.");
		document.getElementById("lastName").focus();
		return false;
	}
	if(document.getElementById("companyName").value == "")
	{
		alert("Please enter Organization.");
		document.getElementById("companyName").focus();
		return false;
	}	
	if(document.getElementById("country").value == 'US')
	{
		if(document.getElementById("phone1").value == ""){
			alert("Please enter first phone field");
			document.getElementById("phone1").focus();
			return false;
		}
		if(isNaN(document.getElementById("phone1").value))
		{
			alert("Phone number must be numeric");
			document.getElementById("phone1").focus();
			return false;
		}
		if(document.getElementById("phone2").value == ""){
			alert("Please enter second phone field");
			document.getElementById("phone2").focus();
			return false;
		}
		if(isNaN(document.getElementById("phone2").value))
		{
			alert("Phone number must be numeric");
			document.getElementById("phone2").focus();
			return false;
		}
		if(document.getElementById("phone3").value == ""){
			alert("Please enter third phone field");
			document.getElementById("phone3").focus();
			return false;
		}
		if(isNaN(document.getElementById("phone3").value))
		{
			alert("Phone number must be numeric");
			document.getElementById("phone3").focus();
			return false;
		}
	}
	else
	{
		if(document.getElementById("phone").value == ""){
			alert("Please enter phone number");
			document.getElementById("phone").focus();
			return false;
		}
	}
	if(document.getElementById("email").value == "")
	{
		alert("Please enter Email address.");
		document.getElementById("email").focus();
		return false;
	}
	var emailFilter=/^.+@.+\..{2,6}$/;
	if (!(emailFilter.test(document.getElementById('email').value)))
	{
		alert(document.getElementById('email').value + ' is not a valid Email ID.');
		document.getElementById('email').value='';
		document.getElementById('email').focus();
		return false;
	}
	if(document.getElementById("password").value == "")
	{
		alert("Please enter Password.");
		document.getElementById("password").focus();
		return false;
	}
	if(document.getElementById("conpassword").value == "")
	{
		alert("Please enter Confirm Password.");
		document.getElementById("conpassword").focus();
		return false;
	}
	if(document.getElementById("password").value != document.getElementById("conpassword").value)
	{
		alert("Password and Confirm Password does not match");
		document.getElementById('conpassword').value='';
		document.getElementById("conpassword").focus();
		return false;
	}
	if(document.getElementById("captcha").value == "")
	{
		alert("Please enter Captcha Code.");
		document.getElementById("captcha").focus();
		return false;
	}
	return true;
}

function goPhone2()
{
	if(document.getElementById("phone1").value.length==3)
	{
		document.getElementById("phone2").focus();
	}
}
function goPhone3()
{
	if(document.getElementById("phone2").value.length==3)
	{
		document.getElementById("phone3").focus();
	}
}
function goToEmail()
{
	if(document.getElementById("phone3").value.length==4)
	{
		document.getElementById("email").focus();
	}
}

function loginValidation()
{
	if(document.getElementById("userName").value == "")
	{
		alert("Please enter E-mail.");
		document.getElementById("userName").focus();
		return false;
	}
	var emailFilter=/^.+@.+\..{2,6}$/;
	if (!(emailFilter.test(document.getElementById('userName').value)))
	{
		alert(document.getElementById('userName').value + ' is not a valid Email ID.');
		document.getElementById('userName').value='';
		document.getElementById('userName').focus();
		return false;
	}
	if(document.getElementById("passWord").value == "")
	{
		alert("Please enter your Password.");
		document.getElementById("passWord").focus();
		return false;
	}
	return true;
}

function forgotValidation()
{
	if(document.getElementById("email").value == "")
	{
		alert("Please enter E-mail.");
		document.getElementById("email").focus();
		return false;
	}
	var emailFilter=/^.+@.+\..{2,6}$/;
	if (!(emailFilter.test(document.getElementById('email').value)))
	{
		alert(document.getElementById('email').value + ' is not a valid Email ID.');
		document.getElementById('email').value='';
		document.getElementById('email').focus();
		return false;
	}
	return true;
}

function openTable(tdId)
{
	document.getElementById(tdId).style.display = '';
}

function hideTable(tdId)
{
	document.getElementById(tdId).style.display = 'none';
}

function ticketValidation()
{
	if(document.getElementById("subject").value == "")
	{
		alert("Please create an appropriate title for your support ticket.");
		document.getElementById("subject").focus();
		return false;
	}
	if(document.getElementById("details").value == "")
	{
		alert("Please describe your issue to the best of your ability.");
		document.getElementById("details").focus();
		return false;
	}
	
	var radiosDomain = document["create_ticket"].elements["conPref"];
	for (var i=0; i <radiosDomain.length; i++) {
	  if (radiosDomain[i].checked) {	   	
		var radioDomainValue=radiosDomain[i].value;
	  }
	}
	if(radioDomainValue != "1" && radioDomainValue != "0")
	{
		alert("Please select a preferred means for response.");
		return false;
	}
	/*if(document.getElementById("cont_email").checked == false && document.getElementById("cont_phone").checked == false)
	{
		alert("Please select a preferred means for response.");
		return false;
	}*/
	return true;
}

function ConfirmReopen(ticketId)
{
	var tmp = confirm("Are you sure you want to re-open the ticket #"+ticketId);
	if(tmp==true)
	{
		window.location.href="ticketDetails.php?ticketId="+ticketId+"&mode=reopen&&reopenTicket=Reopen Ticket";
	}
}

function ConfirmCloseTicket(ticketId)
{
	var tmp = confirm("Are you sure you want to close the ticket #"+ticketId);
	if(tmp==true)
	{
		window.location.href="ticketDetails.php?ticketId="+ticketId+"&task=close";
	}
}

function ConfirmReopenTicket(ticketId)
{
	var tmp = confirm("Are you sure you want to re-open the ticket #"+ticketId);
	if(tmp==true)
	{
		window.location.href="ticketDetails.php?ticketId="+ticketId+"&task=reopen";
	}
}

function editValidation()
{
	if(document.getElementById("firstName").value == "")
	{
		alert("Please enter First Name.");
		document.getElementById("firstName").focus();
		return false;
	}
	if(document.getElementById("lastName").value == "")
	{
		alert("Please enter Last Name.");
		document.getElementById("lastName").focus();
		return false;
	}
	if(document.getElementById("companyName").value == "")
	{
		alert("Please enter Organization.");
		document.getElementById("companyName").focus();
		return false;
	}			
	return true;
}

function fnBlankCheck()
{
	if(document.getElementById("headline").value == "")
	{
		alert("Please enter Article Title.");
		document.getElementById("headline").focus();
		return false;
	}	
	if(document.getElementById("articleDate").value == "")
	{
		alert("Please select Article Date.");
		document.getElementById("articleDate").focus();
		return false;
	}
	if(document.getElementById("generalArticle").checked == false && document.getElementById("realEstateArticle").checked == false)
	{
		alert("Please select atleast one Article Type.");
		document.getElementById("generalArticle").focus();
		return false;
	}			
	return true;
}
/*--------------------------record delete from admin article page--------------------------*/
function delConfirmArticle(articleId)
{
	var articleId=articleId;
	var tmp = confirm("Are You Sure You Want To Remove It?");
	if(tmp==true)
	{
		window.location.href="industryArticle.php?articleId="+articleId+"&mode=delete";
	}
}

/*--------------------------record delete from admin address biik page--------------------------*/
function deleteConfirmSubscriberEmail(subscriberId,registration)
{
	if(confirm("Are You Sure You Want To Remove It?"))
	{
		window.location.href="addressbook.php?subid="+subscriberId+"&mode=delete&type="+registration;
		
	}
}

function addNewEmail(registration)
{
	window.location.href="addressbook.php?mode=add&type="+registration;
}

function importContacts(registration)
{
	window.location.href="addressbook.php?mode=upload&type="+registration;

}


/*--------------------------record delete from admin flyer delete--------------------------*/
function deleteConfirmFlyer(flyerId)
{
	if(confirm("Are You Sure You Want To Remove It?"))
	{
		window.location.href="flyerlist.php?fid="+flyerId+"&mode=delete";
		
	}
}

/*******************  Preview Flyer *******************/
function previewFlyer()
{
	var fid = document.getElementById('flid').value;
	if(fid == "")
	{
		alert('Please select a flyer');		
		document.getElementById('flid').focus();
	}
	else
	{
		window.open("../../viewFlyer.php?flid=" + fid);	
	}

/*--------------------------record delete from admin article comment page--------------------------*/
function delConfirmComment(commentId, articleId)
{
	var commentId=commentId;
	var tmp = confirm("Are You Sure You Want To Remove It?");
	if(tmp==true)
	{
		window.location.href="commentDetails.php?commentId="+commentId+"&mode=delete&articleId="+articleId;
	}
}

}

