	function populate(inForm,sday,smonth,syear,dayfld, monthfld, yearfld, startyr,endyr){
	//alert('pop');
var temp=0;

if (sday == 0){
var today= new Date();
var sday= today.getDate();
var smonth= today.getMonth()+1;
var syear= today.getFullYear();
}

var startyear= startyr;
var endyear = endyr;
t2= 3;
for (var i=0; i <31 ; i++){
var x= String(i+1);
document[inForm][dayfld].options[i] = new Option(x,x);
}

for (var i=-1; i <31 ; i++){
if(i=sday){
document[inForm][dayfld].options[i-1].selected=true;
break;
}
}

for (var i=0, j=startyear; j<=endyear; i++, j++) {
var y= String(j);
document[inForm][yearfld].options[i] = new Option(y,y);
}
for (var i=0, j=startyear; j<=endyear; i++, j++) {
if (j==syear){
document[inForm][yearfld].options[i].selected=true;
break;
}
}
		
for(var i=0;i<=12;i++){
if(i=smonth){
document[inForm][monthfld].options[i-1].selected=true;
break;
}
}
}


function updateProds(obj){

	var access = '';
	//loop through checkboxes
	var i=-1;
	
	while(++i < obj.length){
		if(obj[i].checked == true){
			access += obj[i].value + ',';
		}
	}
	access = access.substring(0,access.length-1);

			document.getElementById('user_country_interest').value = access;
			//alert(document.getElementById('user_country_interest').value);

}
			
	function updateAlerts(obj){

	var access = '';
	//loop through checkboxes
	var i=-1;
	
	while(++i < obj.length){
		if(obj[i].checked == true){
			access += obj[i].value + ',';
		}
	}
	access = access.substring(0,access.length-1);

			document.getElementById('alert_developments').value = access;
			//alert(document.getElementById('alert_developments').value);

}

		function jump(url,id){
			
			var callurl = url;
			if(id>0) callurl = callurl + "?id="+id;
		window.open(callurl,'_self');
			
		}
		
		
	function formatDate(day, month, year,field){
	var date = year+"-"+month+"-"+day;
	//alert(date);
	document.getElementById(field).value = date;
	//alert (document.getElementById('news_date').value);
}	
			
			
			
			function updateDelete(obj){
		
	var delid = '';
	//loop through checkboxes
	var i=-1;
	
	while(++i < obj.length){
		if(obj[i].checked == true){
			delid += obj[i].value + ',';
	
			
		}
	}
	
	delid = delid.substring(0,delid.length-1);
			//alert(delid);
			document.getElementById('deleteids').value = delid;

}
	
	function toggleCheck(is_checked,field){
		//alert (is_checked);
		if(is_checked){
	 document.getElementById(field).value = 1;
		} else {
			//alert ('zero');
	 document.getElementById(field).value = 0;	
		}
	}
	
	
	function setSearchPage(){
var country = $("country_id").options[$("country_id").selectedIndex].text;
var deal_id = $("deal_id").options[$("deal_id").selectedIndex].value
var country_id= $("country_id").options[$("country_id").selectedIndex].value;
var country = country.replace(/ /g, "-");
var country = country.replace("&", "and");
var url="http://www.iqpropertyinvest.co.uk/";
if(deal_id==1){
	url += "current-investments/"
} else {
	url += "forthcoming-investments/"
}
url += country.toLowerCase();
url += "/"+country_id+"/";

$("searchform").action = url;


}
	

function popwhizz(element){ //Pop up a whizzywig form for the element id
window.open('whizzy.htm?'+element,'popwhizzhizz',
'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=100')
}
function whizzed(){
//EXAMPLE ONLY: Join the divs together and put them into the hidden 'edited' - 
 document.getElementById('investment_intro').value= document.getElementById('investment_intro_prev').innerHTML;
 document.getElementById('investment_body').value= document.getElementById('investment_body_prev').innerHTML;
  document.getElementById('investment_notes').value= document.getElementById('investment_notes_prev').innerHTML;

}

function whizzed2(){
  document.getElementById('country_intro').value= document.getElementById('country_intro_prev').innerHTML;	
}
function whizzed3(){
	
  document.getElementById('research_html').value= document.getElementById('research_html_prev').innerHTML;	
}