function getBaseURL() {
    var url = location.href;  // entire url including querystring - also: window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 14));

    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);

        return baseLocalUrl + "/";
    }
    else {
        // Root Url for domain name
        //return baseURL + "/exteamz/";
		return baseURL+ "/";
    }
}

function resultstaticquestion()
{
	if(document.getElementById('answer_0').checked == false && document.getElementById('answer_1').checked == false && document.getElementById('answer1_0').checked == false && document.getElementById('answer1_1').checked == false && document.getElementById('answer2_0').checked == false &&  document.getElementById('answer2_1').checked == false && document.getElementById('answer3_0').checked == false && document.getElementById('answer3_1').checked == false && document.getElementById('answer4_0').checked == false && document.getElementById('answer4_1').checked == false)
	{
		alert("Please answer at least one question");
	}
	else
	{
		var ans=0;
		var ans1=0;
		var ans2=0;
		var ans3=0;
		var ans4=0;
		if(document.getElementById('answer_0').checked == true)
		{
			ans = 1;
		}
		if(document.getElementById('answer1_0').checked == true)
		{
			ans1 = 1;
		}
		if(document.getElementById('answer2_0').checked == true)
		{
			ans2 = 1;
		}
		if(document.getElementById('answer3_0').checked == true)
		{
			ans3 = 1;
		}
		if(document.getElementById('answer4_0').checked == true)
		{
			ans4 = 1;
		}
		if(ans == 1 || ans1 == 1 || ans2 == 1 || ans3 == 1 || ans4 == 1)
		{
			document.getElementById('result5').innerHTML="exTeamz.com helps to fulfill your needs perfectly whether you are a seeker or solver.We invite you to register now.";
		}
		else
		{
			document.getElementById('result5').innerHTML="exTeamz.com has great features to help with your future needs whether you are a seeker or solver. We invite you to register now.";
		}
	}
}

function checkclear(what){
	if(!what.value){
		what.value= 0
	};
}

function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

$().ready(function() {

	$('#container1').hide();
	$('#container1').ajaxStart(function()	{
		$(this).show();
	}).ajaxStop(function(){
		$(this).hide();
	});

	/*---- Loading SubCategory values to dropdown on Category change starts----*/
	$('#category_id').change(function() {
		if($('#category_id').val())
		{
			$.post(getBaseURL() + 'index/get-subcategory-dropdown/', {category: $('#category_id').val()}, function(data) {
				$("#sub_category_id").html(data);
			});
		}
		else
		{
			$("#sub_category_id").html('<option value="">-- Select Sub-Category --</option>');
		}
	});
	/*---- Loading SubCategory values to dropdown on Category change ends----*/


	/*---- Loading State values to dropdown on Country change starts----*/
	$('#country_id').change(function() {
		if($('#country_id').val())
		{
			$.post(getBaseURL() + 'index/get-state-dropdown/', {country: $('#country_id').val()}, function(data) {
				$("#state_id").html(data);
			});
		}
		else
		{
			$("#state_id").html('<option value="">-- Select State --</option>');
		}
	});

	// Loading "state" for previous employment one form
	$('#previousemploymentone-country_id').change(function() {
		if($('#previousemploymentone-country_id').val())
		{
			$.post(getBaseURL() + 'index/get-state-dropdown/', {country: $('#previousemploymentone-country_id').val()}, function(data) {
				$("#previousemploymentone-state_id").html(data);
			});
		}
		else
		{
			$("#previousemploymentone-state_id").html('<option value="">-- Select State --</option>');
		}
	});
	// Loading "state" for previous employment two form
	$('#previousemploymenttwo-country_id').change(function() {
		if($('#previousemploymenttwo-country_id').val())
		{
			$.post(getBaseURL() + 'index/get-state-dropdown/', {country: $('#previousemploymenttwo-country_id').val()}, function(data) {
				$("#previousemploymenttwo-state_id").html(data);
			});
		}
		else
		{
			$("#previousemploymenttwo-state_id").html('<option value="">-- Select State --</option>');
		}
	});
	// Loading "state" for previous school one form
	$('#previouseducationone-country_id').change(function() {
		if($('#previouseducationone-country_id').val())
		{
			$.post(getBaseURL() + 'index/get-state-dropdown/', {country: $('#previouseducationone-country_id').val()}, function(data) {
				$("#previouseducationone-state_id").html(data);
			});
		}
		else
		{
			$("#previouseducationone-state_id").html('<option value="">-- Select State --</option>');
		}
	});
	// Loading "state" for previous school two form
	$('#previouseducationtwo-country_id').change(function() {
		if($('#previouseducationtwo-country_id').val())
		{
			$.post(getBaseURL() + 'index/get-state-dropdown/', {country: $('#previouseducationtwo-country_id').val()}, function(data) {
				$("#previouseducationtwo-state_id").html(data);
			});
		}
		else
		{
			$("#previouseducationtwo-state_id").html('<option value="">-- Select State --</option>');
		}
	});
	/*---- Loading State values to dropdown on Country change ends----*/

	/*---- Hide/Show Change Picture link in Profile edit section-----*/
	$("#profile_picture_div").hover(function(){
		$("#change_picture").show();
	},function(){
		$("#change_picture").hide();
	});

	$("#change_picture").click(function(){
		$("#dialog").dialog({
				height: 150,
				modal: true
		});
		return false;
	});
	$("#dialog_cancel").click(function(){
		$("#dialog").dialog("close");
		return false;
	});
	
	/*-------- news letter form -----------*/
	$('#subscribe_newsletter_button').click(function() {
        var hasError = false;
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
 
        var emailaddressVal = $("#newsletteremail").val();
        if(emailaddressVal == '') {
            $("#newlettermessage").html('<span class="profile-inactive">Please enter your email address.</span>');
            hasError = true;
        }
 
        else if(!emailReg.test(emailaddressVal)) {
            $("#newlettermessage").html('<span class="profile-inactive">Enter a valid email address.</span>');
            hasError = true;
        }
 
        if(hasError == true) { return false; }

		$.post(getBaseURL() + 'index/news-letter/', {email: $('#newsletteremail').val()}, function(data) {
			$("#newsletteremail").val('');
			$("#newlettermessage").html('<span class="profile-active">' + data + '<span>');
		});
		return false;
	});
	

	/*---- Changing the privacy settings for Consultants----*/
	$("input[name='privacy']").click(function(){
		//$("#current_setting").html('<img src="' + getBaseURL() + 'public/images/default/ajax-loader.gif" alt="Loading...">');
		$.post(getBaseURL() + 'dashboard/change-privacy/', {privacy: $("input[name='privacy']:checked").val()}, function(data) {
			$("#current_setting").html(data);
		});
	});
	
	/*------------ Code By Satheesh.N OCS256 ..............*/
	$('#manage_clients_button').click(function() {
	var multipleValues = $("#clientlist").val() || [];
	//var member_id = $("#m_id").val();
	$.post(getBaseURL() + 'resume/managereference/', {referenceList: multipleValues, rtype:1}, function(data) {
			location.reload();
			
		});
	});
	
	$('#manage_friends_button').click(function() {
	var multipleValues = $("#friendlist").val() || [];
	//var member_id = $("#m_id").val();
	$.post(getBaseURL() + 'resume/managereference/', {referenceList: multipleValues, rtype:2}, function(data) {
			location.reload();
			
		});
	});
	
	
	$("#edit_friendList").click(function(){
		$("#get-friendList").dialog({
				height: 275,
				width: 500,
				modal: true
		});
	});
	
	$("#edit_clientList").click(function(){
		$("#get-clientList").dialog({
				height: 275,
				width: 500,
				modal: true
		});
	});
	
	/*------------ Code By Satheesh.N OCS256 ..............*/

	$("#subscribe_newsletters").click(function(){
		$("#subscribe-confirm").dialog({
				height: 175,
				width: 400,
				modal: true
		});
	});
	
	/*---- Unsubscribe My Account for Consultants----*/
	$("#unsubscribe").click(function(){
		$("#unsubscribe-confirm").dialog({
				height: 175,
				width: 400,
				modal: true,
				buttons: {
					"Unsubscribe": function() {
						//$("#unsubscribe-confirm-alert").html('<img src="' + getBaseURL() + 'public/images/default/ajax-loader.gif" alt="Loading...">');
						$.post(getBaseURL() + 'dashboard/unsubscribe/', {unsub: 1}, function(data) {
							$(".ui-dialog-buttonpane").hide();
							$("#unsubscribe-confirm-alert").html(data + ". You will be logged out in <b id='show-time'>15</b> seconds");
							
							var settimmer = 0;
							$(function(){
								window.setInterval(function() {
									var timeCounter = $("b[id=show-time]").html();
									var updateTime = eval(timeCounter)- eval(1);
									$("b[id=show-time]").html(updateTime);

									if(updateTime == 0){
										$(location).attr('href', getBaseURL() + "auth");
									}
								}, 1000);
							});


						});
					},
					Cancel: function() {
						$( this ).dialog( "close" );
					}
				}
		});
	});
	
	$("#buy_package").click(function(){
		if (undefined === $("input[name='subscription_package']:checked").val()) {
			alert("Please select any one subscription package to continue");
			return false;
		}
	});
	/*---- profile viwe and edit page----*/
	$("#showpersonalinformation").click(function(){
		$("#personalinformationview").hide();
		$("#personalinformationedit").show();
	});
	$("#hidepersonalinformation").click(function(){
		$("#personalinformationedit").hide();
		$("#personalinformationview").show();
		return false;
	});
	
	$("#showcompanyinformation").click(function(){
		$("#companyinformationview").hide();
		$("#companyinformationedit").show();
	});
	$("#hidecompanyinformation").click(function(){
		$("#companyinformationedit").hide();
		$("#companyinformationview").show();
		return false;
	});
	
	$("#showcontactinformation").click(function(){
		$("#contactinformationview").hide();
		$("#contactinformationedit").show();
	});
	$("#hidecontactinformation").click(function(){
		$("#contactinformationedit").hide();
		$("#contactinformationview").show();
		return false;
	});
	
	$("#personalinformationform").click(function(){
		var hasError = false;
		
		if($("#first_name").val() == '') {
            $("#first_name_error").html('<ul class="errors"><li>First Name can\'t be empty</li></ul>');
            hasError = true;
        }
		else
		{
			$("#first_name_error").html('');
		}
		var valtest=/^[a-zA-Z]+$/;
		if(!$("#first_name").val().match(valtest))
		{
			 $("#first_name_error").html('<ul class="errors"><li>First Name is not valid</li></ul>');
            hasError = true;
		}
		else
		{
			$("#first_name_error").html('');
		}
		if($("#last_name").val() == '') {
            $("#last_name_error").html('<ul class="errors"><li>Last Name can\'t be empty</li></ul>');
            hasError = true;
        }
		else
		{
			 $("#last_name_error").html('');
		}
		var valtest=/^[a-zA-Z]+$/;
		if(!$("#last_name").val().match(valtest))
		{
			 $("#last_name_error").html('<ul class="errors"><li>Last Name is not valid</li></ul>');
            hasError = true;
		}
		else
		{
			$("#last_name_error").html('');
		}
		if($("#category_id").val() == '') {
            $("#category_id_error").html('<ul class="errors"><li>Category can\'t be empty</li></ul>');
            hasError = true;
        }
		else
		{
			$("#category_id_error").html('');
		}
		if ($("#role").val() != 'Consultants') {
			if($("#company").val() == '') {
				$("#company_error").html('<ul class="errors"><li>Company can\'t be empty</li></ul>');
				hasError = true;
			}
		}
		else
		{
			$("#company_error").html('');
		}
        
        if(hasError == true) { return false; }
		
		$.post(getBaseURL() + 'profile/personal/', {first_name: $('#first_name').val(), 
													last_name: $('#last_name').val(),
													category_id: $('#category_id').val(),
													sub_category_id: $('#sub_category_id').val(),
													company: $('#company').val()
													}, function(data) {
			$("#personalinformationedit").hide();
			$("#personalinformationview").html(data);
			$("#personalinformationview").show();
		});
		return false;
	});
	
	$("#companyinformationform").click(function(){
		$.post(getBaseURL() + 'profile/company/', {company: $('#company').val(), 
													about_company: $('#about_company').val(),
													company_url: $('#company_url').val()
													}, function(data) {
			$("#companyinformationedit").hide();
			$("#companyinformationview").html(data);
			$("#companyinformationview").show();
		});
		return false;
	});
	
	$("#contactinformationform").click(function(){
		var hasError = false;
		
		if($("#address").val() == '') {
            $("#address_error").html('<ul class="errors"><li>Address can\'t be empty</li></ul>');
            hasError = true;
        }
		else
		{
			 $("#address_error").html('');
		}
		if($("#country_id").val() == '') {
            $("#country_id_error").html('<ul class="errors"><li>Country can\'t be empty</li></ul>');
            hasError = true;
        }
		else
		{
			$("#country_id_error").html('');
		}
		if($("#state_id").val() == '') {
            $("#state_id_error").html('<ul class="errors"><li>State can\'t be empty</li></ul>');
            hasError = true;
        }
		else
		{
			$("#state_id_error").html('');
		}
		if($("#state_id").val() == 'other') {
			$("#other_state_hint").show();
            if($("#other_state").val() == '') {
				$("#other_state_error").html('<ul class="errors"><li>State can\'t be empty</li></ul>');
				hasError = true;
			}
        } 
		else {
			$("#other_state_hint").hide();
			$("#other_state_error").html('');
		}
		
		if($("#city").val() == '') {
            $("#city_error").html('<ul class="errors"><li>City can\'t be empty</li></ul>');
            hasError = true;
        }
		else
		{
			$("#city_error").html('');
		}
        if($("#zipcode").val() == '') {
            $("#zipcode_error").html('<ul class="errors"><li>Zipcode can\'t be empty</li></ul>');
            hasError = true;
        }
		else
		{
			$("#zipcode_error").html('');
		}
		var valtest=/^[0-9a-zA-Z]+$/;
		if(!$("#zipcode").val().match(valtest))
		{
			 $("#zipcode_error").html('<ul class="errors"><li>Zipcode is not valid</li></ul>');
            hasError = true;
		}
		else
		{
			$("#zipcode_error").html('');
		}
		var valtest=/^[0-9]+$/;
		if(!$("#phone").val().match(valtest) || $("#phone").val().length != 10) {
            $("#phone_error").html('<ul class="errors"><li>Phone is not valid</li></ul>');
            hasError = true;
        }
		else
		{
			$("#phone_error").html('');
		}
        if(hasError == true) { return false; }
		
		$.post(getBaseURL() + 'profile/contact/', {address: $('#address').val(), 
													country_id: $('#country_id').val(),
													state_id: $('#state_id').val(),
													other_state: $('#other_state').val(),
													city: $('#city').val(),
													zipcode: $('#zipcode').val(),
													phone: $('#phone').val(),
													fax: $('#fax').val()
													}, function(data) {
			$("#contactinformationedit").hide();
			$("#contactinformationview").html(data);
			$("#contactinformationview").show();
		});
		return false;
	});
	
	$(".send_message_to_user").click(function(){
		var user_email = $(this).attr('id');
		$("#send_message_to_user_popup").dialog({
				height: 300,
				width: 600,
				modal: true,
				open: function() {
					jQuery("#send_message_to_user_popup").load(getBaseURL() + "profile/sent-message/id/" + $("#profile_user_id").val() + "/em/" + $("#profile_user_email").val(), function() {});
				}
		});
		return false;
	});
	/*---- End profile viwe and edit page----*/
	
	/* -- Start Collab Invite friends  -- */
	
	$(".invite_collab_member").click(function(){
		$("#invite_friends_popup").dialog({
				height: 400,
				width: 555,
				modal: true,
				open: function() {
					jQuery("#invite_friends_popup").load(getBaseURL() + "index/static-question/", function() {});
				}
		});
		return false;
	});
	
	$("#invite_friends_popup_cancel").live('click', function(){
		$("#invite_friends_popup").dialog("close");
		return false;
	});
	
	
	$('#invite_collab_member').live('click',function(){
		
	var selectedValues = $('#consultant_id').val();
 alert(selectedValues);
		return false;
	
	});
	/* Close invite friends  */
	
	
	/*---- Start Group status ----*/
	$(".invite_group_member").click(function(){
		$("#invite_friends_popup").dialog({
				height: 500,
				width: 555,
				modal: true,
				open: function() {
					jQuery("#invite_friends_popup").load(getBaseURL() + "index/static-question", function() {});
				}
		});
		return false;
	});
	$("#invite_friends_popup_cancel").click(function(){
		$("#invite_friends_popup").dialog("close");
		return false;
	});
	
	$(".send_message_to_group_owner").click(function(){
		var group_id = $(this).attr('id');
		$("#send_message_to_group_owner_popup").dialog({
				height: 300,
				width: 600,
				modal: true,
				open: function() {
					jQuery("#send_message_to_group_owner_popup").load(getBaseURL() + "group/sent-message-to-owner/id/"+ group_id, function() {});
				}
		});
		return false;
	});
	
	$(".review_and_rating").click(function(){
	
		var group_id = $(this).attr('id');
		$("#review_and_rating_popup").dialog({
				height: 300,
				width: 555,
				modal: true,
				open: function() {
					jQuery("#review_and_rating_popup").load(getBaseURL() + "group/review-and-rating/id/"+ group_id, function() {});
				}
		});
		return false;
	});
	
	$(".task_review_and_rating").click(function(){
	
		var group_id = $(this).attr('id');
		$("#task_review_and_rating_popup").dialog({
				height: 300,
				width: 555,
				modal: true,
				open: function() {
					jQuery("#task_review_and_rating_popup").load(getBaseURL() + "job/review-and-rating/id/"+ group_id, function() {});
				}
		});
		return false;
	});
	
	$(".remove_group_member").click(function(){
		var member_id = $(this).attr('id');
		if(confirm("Are you Sure, Do you want to Remove?")==true)
		{
		$.post(getBaseURL() + 'group/remove-member/', {group_id: $('#remove_group_id').val(), member_id:member_id}, function(data) {
			$("#member_div_"+member_id).remove();
		});
		}
		return false;
	});
	
	$(".remove_collab_member").click(function(){
		var member_id = $(this).attr('id');
		if(confirm("Are you Sure, Do you want to Remove?")==true)
		{
		$.post(getBaseURL() + 'collab/remove-member/', {collab_id: $('#remove_collab_id').val(), member_id:member_id}, function(data) {
			$("#member_div_"+member_id).remove();
		});
		}
		return false;
	});
	
	$("#join_this_group").click(function(){
		$("#join_this_group_dialog").dialog({
				height: 150,
				width: 400,
				modal: true
		});
		return false;
	});
	$("#join_this_group_dialog_cancel").click(function(){
		$("#join_this_group_dialog").dialog("close");
		return false;
	});
	$("#join_this_group_button").click(function(){
		$.post(getBaseURL() + 'group/join-this-group/', {group_id: $('#join_this_group_id').val()
													}, function(data) {
			$("#join_this_group").hide();
			$("#awaiting_group_request").show();
			$("#join_this_group_dialog").dialog("close");
		});
		return false;
	});
	$("#awaiting_group_request").click(function(){
		$("#awaiting_group_request_dialog").dialog({
				height: 150,
				width: 450,
				modal: true
		});
		return false;
	});
	$("#awaiting_group_request_dialog_cancel").click(function(){
		$("#awaiting_group_request_dialog").dialog("close");
		return false;
	});
	$("#awaiting_group_request_button").click(function(){
		$.post(getBaseURL() + 'group/remove-member/', {group_id: $('#awaiting_group_id').val(), member_id: $('#awaiting_group_member_id').val()
													}, function(data) {
			$("#join_this_group").show();
			$("#awaiting_group_request").hide();
			$("#awaiting_group_request_dialog").dialog("close");
		});
		return false;
	});
	
	$("#remove_group_member").click(function(){
		$("#remove_group_member_dialog").dialog({
				height: 150,
				width: 450,
				modal: true
		});
		return false;
	});
	$("#remove_group_member_dialog_cancel").click(function(){
		$("#remove_group_member_dialog").dialog("close");
		return false;
	});
	$("#remove_group_member_button").click(function(){
		$.post(getBaseURL() + 'group/remove-member/', {group_id: $('#remove_group_id').val(), member_id: $('#remove_group_member__id').val()
													}, function(data) {
			
			$("#member_div_"+$('#remove_group_member__id').val()).remove();
			$("#join_this_group").show();
			$("#group_member_status").hide();
			$("#remove_group_member").hide();
			$("#review_and_rating").hide();
			$("#remove_group_member_dialog").dialog("close");
		});
		return false;
	});
	
	$('.message_reply_form').submit(function() {
		var message_id = $(this).attr('id');
		if($('#message_reply_'+message_id).val() == '') {
			$('#error_message_reply_'+message_id).show();
			return false;
		}
		return true;
	});
	$(".message_reply_cancel_button").click(function(){
		var message_id = $(this).attr('id');
		$('#group_message_div_'+message_id).hide();
		return false;
	});

	/*---- End Group status ----*/
	/*---- Start Friend status ----*/
	$(".remove_friend_list").live('click', function(){
		var members = $(this).attr('id');
		members = members.split('|');
		if(confirm("Are you Sure, Do you want to Remove?")==true)
		{
			$.post(getBaseURL() + 'profile/cancel-friend/', {member_id: members[0], friend_id: members[1]
													}, function(data) {
			$("#friend_div_"+members[0]).remove();
			});
		}
		return false;
	});
	$("#add_friend").click(function(){
		$("#add_friend_dialog").dialog({
				height: 150,
				width: 400,
				modal: true
		});
		return false;
	});
	$("#add_friend_dialog_cancel").click(function(){
		$("#add_friend_dialog").dialog("close");
		return false;
	});
	$("#add_friend_button").click(function(){
		$.post(getBaseURL() + 'profile/add-friend/', {friend_id: $('#friend_id').val()
													}, function(data) {
			$("#add_friend").hide();
			$("#awaiting_request").show();
			$("#add_friend_dialog").dialog("close");
		});
		return false;
	});
		
	$("#awaiting_request").click(function(){
		$("#awaiting_request_dialog").dialog({
				height: 150,
				width: 450,
				modal: true
		});
		return false;
	});
	$("#awaiting_request_dialog_cancel").click(function(){
		$("#awaiting_request_dialog").dialog("close");
		return false;
	});
	$("#awaiting_request_button").click(function(){
		$.post(getBaseURL() + 'profile/cancel-friend/', {member_id: $('#awaiting_member_id').val(), friend_id: $('#awaiting_friend_id').val()
													}, function(data) {
			$("#add_friend").show();
			$("#awaiting_request").hide();
			$("#awaiting_request_dialog").dialog("close");
		});
		return false;
	});
	
	$("#respond_request").click(function(){
		$("#respond_request_dialog").dialog({
				height: 150,
				width: 450,
				modal: true
		});
		return false;
	});
	
	$("#respond_request_accept").click(function(){
		$.post(getBaseURL() + 'profile/accept-friend/', {member_id: $('#respond_member_id').val(), friend_id: $('#respond_friend_id').val()
													}, function(data) {
			$("#remove_friend").show();
			$("#respond_request").hide();
			$("#respond_request_dialog").dialog("close");
		});
		return false;
	});
	
	$("#respond_request_reject").click(function(){
		$.post(getBaseURL() + 'profile/cancel-friend/', {member_id: $('#respond_member_id').val(), friend_id: $('#respond_friend_id').val()
													}, function(data) {
			$("#add_friend").show();
			$("#respond_request").hide();
			$("#respond_request_dialog").dialog("close");
		});
		return false;
	});

	$("#respond_request_block").click(function(){
		$.post(getBaseURL() + 'profile/block-friend/', {member_id: $('#respond_member_id').val(), friend_id: $('#respond_friend_id').val()
													}, function(data) {
			$("#friend_status").hide();
			$("#respond_request_dialog").dialog("close");
		});
		return false;
	});
	
	$("#remove_friend").click(function(){
		$("#remove_friend_dialog").dialog({
				height: 150,
				width: 450,
				modal: true
		});
		return false;
	});
	$("#remove_friend_dialog_cancel").click(function(){
		$("#remove_friend_dialog").dialog("close");
		return false;
	});
	$("#remove_friend_button").click(function(){
		$.post(getBaseURL() + 'profile/cancel-friend/', {member_id: $('#awaiting_member_id').val(), friend_id: $('#awaiting_friend_id').val()
													}, function(data) {
			$("#add_friend").show();
			$("#remove_friend").hide();
			$("#remove_friend_dialog").dialog("close");
		});
		return false;
	});
	/*---- End Friend status ----*/
	
	/*---- Start Search Friend status ----*/
	
	$(".add_search_friend").click(function(){
		var friend_id = $(this).attr('rel');
		$("#add_friend_dialog").dialog({
				height: 150,
				width: 400,
				modal: true,
				open: function() {
					jQuery("#add_friend_dialog").load(getBaseURL() + "profile/add-search-friend-popup/friend_id/"+ friend_id, function() {});
				}
		});
		return false;
	});
	$(".awaiting_search_request").click(function(){
		var friend_id = $(this).attr('rel');
		$("#awaiting_request_dialog").dialog({
				height: 150,
				width: 450,
				modal: true,
				open: function() {
					jQuery("#awaiting_request_dialog").load(getBaseURL() + "profile/cancel-search-friend-popup/friend_id/"+ friend_id, function() {});
				}
		});
		return false;
	});
	
	/*---- End Search Friend status ----*/
	
	/*---- Start Notification Friend status ----*/
	$(".notification_friend_accept").live('click', function(){
		var friends = $(this).attr('id').split('|');
		var notification_friend_count = parseInt($("#notification_friend_count").html());
		$.post(getBaseURL() + 'profile/accept-friend/', {member_id: friends[0], friend_id: friends[1]
													}, function(data) {
			$("#notification_friend_"+friends[0]).remove();
			$("#notification_friend_count").html(notification_friend_count - 1);
		});
		return false;
	});
	
	$(".notification_friend_reject").live('click', function(){
		var friends = $(this).attr('id').split('|');
		var notification_friend_count = parseInt($("#notification_friend_count").html());
		$.post(getBaseURL() + 'profile/cancel-friend/', {member_id: friends[0], friend_id: friends[1]
													}, function(data) {
			$("#notification_friend_"+friends[0]).remove();
			$("#notification_friend_count").html(notification_friend_count - 1);
		});
		return false;
	});

	$(".notification_friend_block").live('click', function(){
		var friends = $(this).attr('id').split('|');
		var notification_friend_count = parseInt($("#notification_friend_count").html());
		$.post(getBaseURL() + 'profile/block-friend/', {member_id: friends[0], friend_id: friends[1]
													}, function(data) {
			$("#notification_friend_"+friends[0]).remove();
			$("#notification_friend_count").html(notification_friend_count - 1);
		});
		return false;
	});
	
	$(".notification_group_accept").live('click', function(){
		var groupMembers = $(this).attr('id').split('|');
		var notification_group_count = parseInt($("#notification_group_count").html());
		$.post(getBaseURL() + 'group/accept-member/', {group_id: groupMembers[0], member_id: groupMembers[1]
													}, function(data) {
			$("#notification_group_"+groupMembers[1]).remove();
			$("#notification_group_count").html(notification_group_count - 1);
		});
		return false;
	});
	
	$(".notification_group_reject").live('click', function(){
		var groupMembers = $(this).attr('id').split('|');
		var notification_group_count = parseInt($("#notification_group_count").html());
		$.post(getBaseURL() + 'group/remove-member/', {group_id: groupMembers[0], member_id: groupMembers[1]
													}, function(data) {
			$("#notification_group_"+groupMembers[1]).remove();
			$("#notification_group_count").html(notification_group_count - 1);
		});
		return false;
	});
	
	$(".group-message-reply").click(function(){ 
		var parent_id = $(this).attr('id');
		$("#group_message_div_"+parent_id).show();
		return false;
	});
	
	/*---- End Notification Friend status ----*/
	$('#state_id').change(function() {
		if($('#state_id').val() == '449') {
			$('#other_state').after('<span id="state_id_hint" class="hint"><img alt="required" src="/effinova//public/images/default/star.png"></span>');
		} else {
			if($('#state_id_hint')) {
				$('#state_id_hint').remove();
				$('#other_state').val('');
			}
		}
	});
	
	$('#previousemploymentone-state_id').change(function() {
		if($('#previousemploymentone-state_id').val() == '449') {
			$('#previousemploymentone-other_state').after('<span id="previousemploymentone-state_id_hint" class="hint"><img alt="required" src="/effinova//public/images/default/star.png"></span>');
		} else {
			if($('#previousemploymentone-state_id_hint')) {
				$('#previousemploymentone-state_id_hint').remove();
				$('#previousemploymentone-other_state').val('');
			}
		}
	});
	
	$('#previousemploymenttwo-state_id').change(function() {
		if($('#previousemploymenttwo-state_id').val() == '449') {
			$('#previousemploymenttwo-other_state').after('<span id="previousemploymenttwo-state_id_hint" class="hint"><img alt="required" src="/effinova//public/images/default/star.png"></span>');
		} else {
			if($('#previousemploymenttwo-state_id_hint')) {
				$('#previousemploymenttwo-state_id_hint').remove();
				$('#previousemploymenttwo-other_state').val('');
			}
		}
	});
	
	$('#previouseducationone-state_id').change(function() {
		if($('#previouseducationone-state_id').val() == '449') {
			$('#previouseducationone-other_state').after('<span id="previouseducationone-state_id_hint" class="hint"><img alt="required" src="/effinova//public/images/default/star.png"></span>');
		} else {
			if($('#previouseducationone-state_id_hint')) {
				$('#previouseducationone-state_id_hint').remove();
				$('#previouseducationone-other_state').val('');
			}
		}
	});
	
	$('#previouseducationtwo-state_id').change(function() {
		if($('#previouseducationtwo-state_id').val() == '449') {
			$('#previouseducationtwo-other_state').after('<span id="previouseducationtwo-state_id_hint" class="hint"><img alt="required" src="/effinova//public/images/default/star.png"></span>');
		} else {
			if($('#previouseducationtwo-state_id_hint')) {
				$('#previouseducationtwo-state_id_hint').remove();
				$('#previouseducationtwo-other_state').val('');
			}
		}
	});
	
/*
	$("#friends_list").autocomplete(getBaseURL() + 'index/get-users-dropdown/', {
		multiple: true,
		mustMatch: true,
		autoFill: true
	});

	$("#friends_list").result(function(event, data, formatted) {
		if ($('#friends_id_list').val() == '')
			$('#friends_id_list').val(data[1]);
		else
			$('#friends_id_list').val($('#friends_id_list').val() +','+ data[1]);
	});
	
	*/
	
	$('#check_all').toggle(function(){
        $('input:checkbox').attr('checked','checked');
    },function(){
        $('input:checkbox').removeAttr('checked');
    });
	
	$("#apply_jobs").click(function(){
		$("#jobs_status_message").html('');
		var fields = $("input[name='jobs[]']").serializeArray(); 
		if (fields.length == 0) { 
			alert('Please select atleast one job');
			return false;
		}
		$.post(getBaseURL() + 'job/apply/', {jobs_id: fields}, function(data) {
			$("#jobs_status_message").html('Jobs applyed successfully.');
		});
		return false;
	});	
	
	$("#jobs_saved").click(function(){
		$("#jobs_status_message").html('');
		var fields = $("input[name='jobs[]']").serializeArray(); 
		if (fields.length == 0) { 
			alert('Please select atleast one job');
			return false;
		}
		$.post(getBaseURL() + 'job/saved/', {jobs_id: fields}, function(data) {
			$("#jobs_status_message").html('Jobs saved successfully.');
		});
		return false;
	});
	
	$("#remove_seaved_jobs").click(function(){
		var fields = $("input[name='jobs[]']").serializeArray(); 
		if (fields.length == 0) 
			alert('Please select atleast one job'); 
		else 
		{
			if(confirm("Are you sure want to Removed selected saved job(s)?"))
			{
				//$("#hidden_action").val('remove_consultants');
				$('#search_result').submit();
			}
		}
	});

	$("#sendmail").click(function(){
		$("#consultants_status_message").html('');
		var fields = $("input[name='consultant[]']").serializeArray(); 
		if (fields.length == 0) { 
			alert('Please select atleast one consultants');
			return false;
		}
	
		var hidden_consultants = '';
		jQuery.each(fields, function(i, field){
			var comma = ',';
			if(!hidden_consultants)
				comma = '';
			hidden_consultants	+=	comma + $.makeArray(field.value);
		});

		$("#dialog").dialog({
			height: 400,
			width: 500,
			modal: true,
			open: function(event, ui) {
				$("#hidden_pop_action").val($("#sendmail_action").val());
				$("#hiddenConsultants").val(hidden_consultants);
			}
		});
		return false;

	});
	
	$("#save_consultants").click(function(){
		$("#consultants_status_message").html('');
		var fields = $("input[name='consultant[]']").serializeArray(); 
		if (fields.length == 0) { 
			alert('Please select atleast one consultants');
			return false;
		}
		$.post(getBaseURL() + 'resume/saved/', {consultants_id: fields}, function(data) {
			$("#consultants_status_message").html('Consultants saved successfully.');
		});
		return false;
	});
	/*
	$("#shortlist").click(function(){
		$("#consultants_status_message").html('');
		var fields = $("input[name='consultant[]']").serializeArray(); 
		if (fields.length == 0) { 
			alert('Please select atleast one consultants');
			return false;
		}
		$.post(getBaseURL() + 'resume/shortlisted/', {consultants_id: fields}, function(data) {
			$("#consultants_status_message").html('Consultants short listed successfully.');
		});
		return false;
	});
	*/
	$("#resumeview_sendmail").click(function(){
		$("#dialog").dialog({
			height: 400,
			width: 500,
			modal: true,
			open: function(event, ui) {
				$("#hidden_pop_action").val($("#sendmail_action").val());
				$("#hiddenConsultants").val($("#consultant").val());
				$("#consultant_reffer").val($("#view_consultant_reffer").val());
				
			}
		});
		return false;
	});
	
	$("#remove_consultant").click(function(){
		var fields = $("input[name='consultant[]']").serializeArray(); 
		if (fields.length == 0) 
			alert('Please select atleast one Consultant'); 
		else 
		{
			if(confirm("Are you sure want to Removed selected Consultant(s)?"))
			{
				$("#hidden_action").val('remove_consultants');
				$('#search_result').submit();
			}
		}
	});
	
	$("#reject_consultant").click(function(){
		var fields = $("input[name='consultant[]']").serializeArray(); 
		if (fields.length == 0) {
			alert('Please select atleast one Consultant'); 
		} else {
			if(confirm("Are you sure want to Reject selected Consultant(s)?"))
			{
				$("#hidden_action").val('Reject');
				$('#search_result').submit();
			}
		}
	});
	
	$("#accept_consultants").click(function(){
		var fields = $("input[name='consultant[]']").serializeArray(); 
		if (fields.length == 0) {
			alert('Please select atleast one Consultant');
		} else 	{
			$("#hidden_action").val('Accept');
			$('#search_result').submit();
		}
	});
	
	$("#invite_consultants").click(function(){
		var fields = $("input[name='consultant[]']").serializeArray(); 
		if (fields.length == 0) {
			alert('Please select atleast one Consultant');
		} else 	{
			$("#hidden_action").val('Invite');
			$('#search_result').submit();
		}
	});
	
	$("#apply_invite_jobs").click(function(){
		var fields = $("input[name='jobs[]']").serializeArray(); 
		if (fields.length == 0) {
			alert('Please select atleast one Job');
		} else 	{
			$("#hidden_action").val('Apply');
			$('#search_result').submit();
		}
	});
	
	$("#omitted_invite_jobs").click(function(){
		var fields = $("input[name='jobs[]']").serializeArray(); 
		if (fields.length == 0) {
			alert('Please select atleast one Job');
		} else 	{
			$("#hidden_action").val('Omitted');
			$('#search_result').submit();
		}
	});
	
	$("#commit_consultants").click(function(){
		var fields = $("input[name='consultant[]']").serializeArray(); 
		if (fields.length == 0) {
			alert('Please select atleast one Consultant');
		} else 	{
			$("#hidden_action").val('Commit');
			$('#search_result').submit();
		}
	}); 
	
	$("#assign_project_manager").click(function(){
		var fields = $("input[name='consultant[]']").serializeArray(); 
		if (fields.length == 0) {
			alert('Please select atleast one Consultant');
		} else if (fields.length > 1) {
			alert('Please select any one Consultant to assign as a project manager.');
		} else	{
			$('#search_result').submit();
		}
	});
	
	if ($("#start_date").length > 0) { 
		$("#start_date").datepicker({
			showOn: "button",
			buttonImage: getBaseURL() + "public/images/default/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'yy-mm-dd'
		});
	}
	if ($("#end_date").length > 0) {
		$("#end_date").datepicker({
			showOn: "button",
			buttonImage: getBaseURL() + "public/images/default/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'yy-mm-dd'
		});
	}
/*	$(".").click(function(){
		var friend_id = $(this).attr('rel');
		$("#awaiting_request_dialog").dialog({
				height: 150,
				width: 450,
				modal: true,
				open: function() {
					jQuery("#awaiting_request_dialog").load(getBaseURL() + "profile/cancel-search-friend-popup/friend_id/"+ friend_id, function() {});
				}
		});
		return false;
	}); */
	
	$(".choose_consultant_task").click(function(){
		var assign_task_id = $(this).attr('id');
		$("#choose_consultant_task_popup").dialog({
				height: 400,
				width: 400,
				modal: true,
				open: function() {
					jQuery("#choose_consultant_task_popup").load(getBaseURL() + "job/assign-task/assign_task_id/"+ assign_task_id, function() {});
				}
		});
		return false;
	});
	
	
	
	/*
	$(".applied-members").click(function(){
		var job_id = $(this).attr('id');
		$("#applied_members_popup").dialog({
				height: 400,
				width: 555,
				modal: true,
				open: function() {
					jQuery("#applied_members_popup").load(getBaseURL() + "job/applied-member-list/job_id/"+ job_id, function() {});
				}
		});
		return false;
	});
	
	$(".current-members").click(function(){
		var job_id = $(this).attr('id');
		$("#current_members_popup").dialog({
				height: 400,
				width: 555,
				modal: true,
				open: function() {
					jQuery("#current_members_popup").load(getBaseURL() + "job/current-members-list/job_id/"+ job_id, function() {});
				}
		});
		return false;
	});
	*/

	$(".review-task-button").live('click', function(){
		var task_user_detail_id = $(this).attr('id');
		$("#review_consultant_task_popup").dialog({
			height: 175,
			width: 400,
			modal: true,
			buttons: {
				"Confirm": function() {
					$.post(getBaseURL() + 'job/review-task/', {task: task_user_detail_id}, function(data) {
						window.parent.location.reload();
					});
				},
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			}
		});
		return false;
	});
	


	$("#calculate_withdraw_fee").click(function(){
		if($("#req_amount").val() == '')
		{
			$("#amount_after_fee").html("<span class='profile-inactive'>Withdraw amount not mentioned</span>");
		}
		else
		{
			var numericExpression = /^[0-9]+$/;
			if($("#req_amount").val().match(numericExpression)){
				$.post(getBaseURL() + 'job/calculate-fee/', {req: $("#req_amount").val()}, function(data) {
					$("#amount_after_fee").html(data);
				});
			}else{
				$("#amount_after_fee").html("<span class='profile-inactive'>Withdraw amount must be numeric</span>");
			}
		}
	});

	$(".reject-collab").live('click', function(){
		var collab_invite_id	= $(this).attr('id')
		$.post(getBaseURL() + 'job/calculate-fee/', {collab_request: collab_invite_id}, function(data) {
			$("#collab_" + collab_invite_id).html('');
		});
	});
});
