function checkFields(){
	if(edit.linkedin_firstname.value == ""){
		alert("First name is required.");
		edit.linkedin_firstname.focus();
		return false;
	}
	else if(edit.linkedin_lastname.value == ""){
		alert("Last name is required.");
		edit.linkedin_lastname.focus();
		return false;
	}
}


/*function uNameValidate(){
	
	var uName = document.register.username.value;
	var iChars = "_!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	
	for (var i = 0; i < uName.length; i++) {
		alert("hello");
		if (iChars.indexOf(uName.charAt(i)) != -1) {
			alert ("Your username has special characters. \nOnly alphabets and numbers are allowed.");
		  	return false;
		}
		
		if(i == 0){
			alert("Please provide username.");
			return false;
		}
		if(i > 12){
			alert("Please limit username to at most 12 characters");
			return false;
		}
	}
	
}*/

//on send_message.php
function DisplayAlert(id,left,top) {
	document.getElementById(id).style.left=left+'px';
	document.getElementById(id).style.top=top+'px';
	document.getElementById(id).style.display='block';
	}
	
function checkMessageContents(){
	if(document.msg.message_subject.value <= 0){
				DisplayAlert('AlertBox',100,250);
				document.msg.message_subject.focus();
				return false;
	}
	if(document.msg.message_body.value <= 0){
				DisplayAlert('AlertBox',100,250);
				document.msg.message_body.focus();
				return false;
	}
}
//-end of send_message.php

//on reply to message
function checkReplyContents(){
	if(document.msg.message_body.value <= 0){
				DisplayAlert('AlertBox',100,250);
				document.msg.message_body.focus();
				return false;
	}
	else{
		return true;
	}
}

function productComment(){
	var commentBox = document.getElementById("prodcommentBox");
	if(document.commentbox.product_comment.value <= 0){
			DisplayAlert('NoCommentContents',100,250);
			document.commentbox.product_comment.focus();
			return false;
	}
	else{ 
		$.ajax({ 
			type: "POST",
			url: "add_commentsProduct.php",
			data: "prodid=" + commentbox.productid.value + "&comment=" + commentbox.product_comment.value,
			dataType:"html",
			success: function(html){
				commentBox.innerHTML = html;
				document.getElementById("prodcommentArea").value="";
			}
		}); 
		return false;
	}
}

function jobComments(){
	var commentBox = document.getElementById("jobcommentBox");
	if(form_comment.comment.value == ""){
		document.getElementById("commentAlert").style.display="block";
		form_comment.comment.focus();
		return false;
	}
	else {
		$.ajax({ 
			type: "POST",
			url: "add_comments.php",
			data: "job_id=" + form_comment.jobid.value + "&comment=" + form_comment.comment.value,
			dataType:"html",
			success: function(html){
				commentBox.innerHTML = html;
				document.getElementById("commentArea").value="";	
				document.getElementById("commentAlert").style.display="none";
			}
		}); 
		return false;
	}    
}

//edit job
function checkPostJobFields(){
	alert('hello');

	if(document.post_job.job_title.value <= 0){
		alert('Please provide job title.');
		document.post_job.job_content.focus();
		return false;
	}

	if(document.post_job.job_content.value <= 0){
		alert('Job should not be empty.');
		document.post_job.job_content.focus();
		return false;
	}
	
	if(document.post_job.webpoints.value <= 0){
		alert('Webpoints should not be empty.');
		document.post_product_check.product_title.focus();
		return false;
	}
	
	if (isNaN(document.post_job.webpoints.value)==true){
		alert("Please enter digits for webpoints amount.");
		return false;
	}
	if (isNaN(document.post_job.limit.value)==true){
		alert("Please enter digits for Number of users.");
		return false;
	}
  
	var totalcost = (document.post_job.webpoints.value) * (document.post_job.limit.value);
	alert('total Cost: '+totalcost);
	if(document.post_job.userwebpoints.value < totalcost){
		alert('You do not have enough webpoints to post this job.');
		return false;
	}
}


/*function checkPostProductFields(){
	if(document.post_product_check.product_title.value <= 0){
		alert('Enter product name.');
		document.post_product_check.product_title.focus();
		return false;
	}
		
	if(document.post_product_check.product_webpoints.value <= 0){
		alert('Webpoints should not be empty.');
		document.post_product_check.product_webpoints.focus();
		return false;
	}
		
	if (isNaN(document.post_product_check.product_webpoints.value)==true){
		alert("Please enter digits for webpoints amount");
		document.post_product_check.product_webpoints.focus();
		return false;
	}
  
	if (isNaN(document.post_product_check.product_limit.value)==true){
		alert("Please enter digits for product count");
		document.post_product_check.product_limit.focus();
		return false;
	}
	
	if(document.post_product_check.image.value != ""){
	var filename = document.getElementById("image").value;
    var ext = getExt(filename);
    if(ext == "gif" || ext == "jpg" || ext == "jpeg" || ext == "png")
        return true;
    document.getElementById("noti5").innerHTML = "*";
    return false;
  }
}
*/
function limitAttach() {
    var filename = document.getElementById("image").value;
    var ext = getExt(filename);
    if(ext == "gif" || ext == "jpg" || ext == "jpeg" || ext == "png")
        return true;
    document.getElementById("noti5").innerHTML = "*";
    return false;
}

function getExt(filename) {
    var dot_pos = filename.lastIndexOf(".");
    if(dot_pos == -1)
        return "";
    return filename.substr(dot_pos+1).toLowerCase();
}
