var typeDate;
function viewcalendar(dType) {
	typeDate = dType;
	  if (typeDate == "from"){
  kalendarik = window.open("php_calendar/calFrom.php", "kalendarik" , "location=0, menubar=0, scrollbars=0, status=0, titlebar=0, toolbar=0, directories=0, resizable=1, width=200, height=240, top=200, left=350");
  }
  else if(typeDate == "to"){
	 kalendarik = window.open("php_calendar/calTo.php", "kalendarik" , "location=0, menubar=0, scrollbars=0, status=0, titlebar=0, toolbar=0, directories=0, resizable=1, width=200, height=240, top=200, left=350");
  }
  
  else if (typeDate == "jFrom"){
  kalendarik = window.open("../php_calendar/calFrom.php", "kalendarik" , "location=0, menubar=0, scrollbars=0, status=0, titlebar=0, toolbar=0, directories=0, resizable=1, width=200, height=240, top=200, left=350");
  }
  else if(typeDate == "jTo"){
	 kalendarik = window.open("../php_calendar/calTo.php", "kalendarik" , "location=0, menubar=0, scrollbars=0, status=0, titlebar=0, toolbar=0, directories=0, resizable=1, width=200, height=240, top=200, left=350");
  }
 
  kalendarik.resizeTo(200, 240);
  kalendarik.moveTo(250, 50);
}

function dateFrom(d){
	dateMe = d;
	  window.close();
  window.opener.document.getElementById('valid_from_date').value = dateMe + " 00:00:00";

}

function dateTo(d){
	dateMe = d;
	  window.close();
	window.opener.document.getElementById('valid_to_date').value = dateMe + " 23:59:59";  

}

function insertdate(d) {
	dateMe = d;
  if (typeDate == "from"){
 dateFrom(dateMe);
  }
  else if(typeDate == "to"){
	dateTo(dateMe);
  }
}
