//maximum length
function maxLength(obj,len,msg){
	if(obj.value.length > len){	
		alert(msg);	
		obj.focus();
		var new_value = obj.value;
		
		obj.value = new_value.substring(0,len);//cut string

		return false;
	}
 return true;	
}






// check NUMBER only
function isNumber(obj,msg){
  var strTmp = obj.value;
  var ValidChars = '0123.456789';

  //Check Validity
  for (i=0; i<=strTmp.length-1; i++) 
    if (ValidChars.indexOf(strTmp.charAt(i)) == -1   ) 
    {
	  alert(msg);
	  obj.value = '';
      obj.focus();
      return false;
	}
  return true;
}	

function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function delete_file(company_id, category, filename){
	var answer = confirm ("Are you sure you want to delete this file?");
	if (answer){
		window.open("index.php?action=company_profile_edit&delete_file=1&my_company_id="+company_id+"&category="+category+"&filename="+filename, "_self");
	}
	
}

function reject_startup(company_id){
	var answer = confirm ("Are you sure you want to reject and permanently delete this entry?");
	if (answer){
		window.open("index.php?action=approve_startups&what=reject&my_company_id="+company_id, "_self");
	}
	
}

function reject_investor(investor_id){
	var answer = confirm ("Are you sure you want to reject this entry?");
	if (answer){
		window.open("index.php?action=approve_investors&what=reject&investor_id="+investor_id, "_self");
	}
	
}



function delete_investor(investor_id){
	var answer = confirm ("Are you sure you want to permanently delete this entry?");
	if (answer){
		window.open("index.php?action=approve_investors_dev&what=delete&investor_id="+investor_id, "_self");
	}
	
}


function reject_investor_dev(investor_id){
	var answer = confirm ("Are you sure you want to reject this entry?");
	if (answer){
		window.open("index.php?action=approve_investors_dev&what=reject&investor_id="+investor_id, "_self");
	}
	
}



function delete_investment_file(company_id, category, filename){
	var answer = confirm ("Are you sure you want to delete this file?");
	if (answer){
		window.open("index.php?action=investment_documents&delete_file=1&company_id="+company_id+"&category="+category+"&filename="+filename, "_self");
	}
	
}


function popup_video(video_file){
	w = 500;
	h = 400;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	var p = 'height=' + h + ',width=' + w + ',top=' + t + ',left=' + l + ',scrollbars=0,resizable=0, menubar=0,toolbar=0, statusbar=0, fullscreen=0';
		
	var mine = window.open("dsp_popup_video.php?video_file="+video_file, "newwin", p);
	
		
}

function saveAsMe (filename)
{
	alert(filename);
	document.execCommand('saveas',null,'http://localhost/can/userfiles/product_descriptions_100023_CCTEC%202007%20AR.pdf');
}
