var loadingMsg_Investor = '<br /><center><img src="images/v2/loader/blue.gif" alt="..."/><br />'+lang_txt_loading+'</center><br />';


function validateFormInvestorProfile(zap) {
	if ($('#investorAboutForm').validate().form()) {
		validateInvestorAboutOnSubmit(zap);
	} else {
		window.scrollBy(0,-300);
		$('.success_message').hide();
		$('.fail_message').fadeIn();
	}
}

function validateInvestorAboutOnSubmit(zap){
	if(!zap){
		if (parseInt($('#link_label2').val()) < 5) {
			$('#person_input_label2').attr('value', '');
		}
		if (parseInt($('#link_label1').val()) < 5) {
			$('#person_label1_input').attr('value', '');
		}
	}
	if(zap){
		$('#investorAboutForm').ajaxSubmit({
		success:    function() { 
			//	tb_remove();
				$('#profile').html(loadingMsg_Investor);
				$('#processInvestor').submit();
			} 
		});
	} else{
		$('#investorAboutForm').ajaxSubmit({
			target: '#TabbedPanels1-TabbedPanels1',
			success:    function(text,status,zap) { 
				document.getElementById('success_message').scrollIntoView(false);
			} 
		});
	}
}

function getInvestorInvestmentInfo(company_id, invested) {
	window.location = non_secure_url + '/company-details.php?invested='+invested+'&id=' + company_id;
}

function getInvestorInvestmentInfoEnd(company_id, invested) {
	$("#TabbedPanels1").hide();
	$("#company-investment-info").hide();
	$("#loader").show();
	$.ajax({
		type: "POST",
		url: "investor-investment.php",
		data: 'action=getInvestmentInfo&company_id='+company_id+'&invested='+invested,
		success: function(msg){
			$("#company-investment-info").html(msg);
			$("#loader").hide();
			$("#company-investment-info").show();
		}
	});
}
function getInvestorInvestmentFailed(company_id) {
	$("#TabbedPanels1").hide();
	$("#company-investment-info").hide();
	$("#loader").show();
	$.ajax({
		type: "POST",
		url: "investor-investment.php",
		data: 'action=getInvestmentInfo&company_id='+company_id+'&invested='+invested,
		success: function(msg){
			$("#company-investment-info").html(msg);
			$("#loader").hide();
			$("#company-investment-info").show();
		}
	});
}


function cancelInvestorInvestment(){
	$("#company-investment-info").html('');
	$("#TabbedPanels1").show();
}



function processInvestorBuyShares() {
	$("#company-investment-info").hide();
	$("#loader").show();
	$('#processInvestor').ajaxSubmit({
		target: '#company-investment-info',
		success:    function(text,status) { 
			$("#loader").hide();
			$("#company-investment-info").show();
		} 
	});
}


function showJobEditFieldInv(val){
	/*
	if(val == "other"){
		$("#other1").show();
	}	else{
		$("#other1").hide();
	}
	*/
}
