// Greengate 
function add_comment(){
  document.cform.submit();
}

function search1(){
  document.sform1.submit();
}


function showpic(pic,width,height){
 win=window.open('showpic.php?id='+pic, 'userpicwin', 'height='+height+',width='+width);
}
function showpic2(pic,width,height){
 win=window.open('showpic.php?id='+pic+'&type=2', 'userpicwin', 'height='+height+',width='+width);
}

function print_win(url){
 win=window.open(url,'printwin','');
}

// common functions
 function getSelectedId(el){
   return parseInt(el.options[el.selectedIndex].value);
 }

 var numDays = [31,29,31,30,31,30,31,31,30,31,30,31];

 function makeDays(obj,min,max) {
   var cur_length=obj.options.length;
   for (i=0; i<=max-min; i++)  {    
    obj.options[i] = new Option(i+min,i+min);
   }
   for (i=(max-min)+1; i<=cur_length; i++) {
    obj.options[max-min+1]=null;
   }
 }


 function is_leap_year(year){
   if (((year % 4==0) && (year % 100!=0)) || (year % 400==0)) {
      return true;
   }
   return false;
 }  


 function refresh(d,m,y) {
   var tmp=d.selectedIndex;
   var year=getSelectedId(y);
   if (is_leap_year(year)){
     numDays[1]=29;
   } else {
     numDays[1]=28;
   }
   var days=numDays[m.options[m.selectedIndex].value-1];
   makeDays(d,1,days);
   var len=d.options.length;
   d.selectedIndex=(len<tmp+1)?len-1:tmp;
 }

 function CheckCurrentDate(){
 }

 function ch_month(form,num){
   refresh (eval('document.'+form+'.day'+num),
   	    eval('document.'+form+'.mon'+num),
	    eval('document.'+form+'.year'+num));
//   d = new Date();
//   alert (d.getTimezoneOffset());
 }


 function ch_year(form,num){
   ch_month(form,num);
 }
 
 function days_from_now(num){
  d = new Date();
  var e = 'document.forms[0].';
  var d1 = cd(d.getDate(), d.getMonth()+1, d.getFullYear());
  var d2 = cd(getSelectedId(eval(e+'day'+num)),
     getSelectedId(eval(e+'mon'+num)), 
     getSelectedId(eval(e+'year'+num))+2000);
  return d2-d1;
 }


