function submitform(pressbutton){
  if(pressbutton)
    document.adminform.option.value=pressbutton;
  if(typeof document.adminform.onsubmit == "function")
    document.adminform.onsubmit();
  document.adminform.submit();
}
function submitform2(pressbutton){
  if(pressbutton)
    document.adminform2.option.value=pressbutton;
  if(typeof document.adminform2.onsubmit == "function")
    document.adminform2.onsubmit();
  document.adminform2.submit();
}

function submitform3(pressbutton){
  if(pressbutton)
    document.adminform3.option3.value=pressbutton;
  if(typeof document.adminform3.onsubmit == "function")
    document.adminform3.onsubmit();
  document.adminform3.submit();
}

function submitform4(pressbutton){
  if(pressbutton)
    document.adminform4.option4.value=pressbutton;
  if(typeof document.adminform4.onsubmit == "function")
    document.adminform4.onsubmit();
  document.adminform4.submit();
}

function submitform5(pressbutton){
  if(pressbutton)
    document.adminform5.option5.value=pressbutton;
  if(typeof document.adminform5.onsubmit == "function")
    document.adminform5.onsubmit();
  document.adminform5.submit();
}

function createselectedRowsPath(arr) {
  document.adminform.argus.value = arr.toString();
}

function setTotalPromoLength() {
  if(document.adminform.promo.length == null)
    document.adminform.total.value = 0;
  else
    document.adminform.total.value = document.adminform.promo.length;
}

function getCheckedElements() {
  //var form = document.getElementById("adminform");
  var path = "";
  if(document.adminform.promo != null) {
    if(document.adminform.promo.length == null) {
	   if(document.adminform.promo.checked == true)
	      path = document.adminform.promo.id.replace("v","")+",";
    }
    else {
      for(var i=0;i < document.adminform.promo.length;i++) {
	    if(document.adminform.promo[i].checked == true)
          path += document.adminform.promo[i].id.replace("v","")+",";
      }	
    }
    path = path.substring(0,path.length-1);
  }
  return path;
}

function checkAllElements() {
  if(document.adminform.promo != null) {
    if(document.adminform.promo.length == null) {
	  document.adminform.promo.checked = true;
    }
    else {	  
      for(var i=0;i < document.adminform.promo.length;i++)
        document.adminform.promo[i].checked = true;
    }
  }
}

function setpag(pag) {
  document.adminform.pag.value = pag;
}

function NewWindow(mypage,myname,w,h,scrolling){
  if(w != '' && h!= '') {
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings = 'resizable=yes,height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scrolling;
  }
  else
    settings = 'resizable=yes,scrollbars='+scrolling;  
  win = window.open(mypage,myname,settings);
}

  


// Effetto Fade
function high(which2) {
  theobject=which2
  highlighting=setInterval("highlightit(theobject)",30)
}

function low(which2){
  clearInterval(highlighting)
  if(which2.style.MozOpacity)
    which2.style.MozOpacity=0.3
  else if (which2.filters)
    which2.filters.alpha.opacity=50
}

function highlightit(cur2){
  if (cur2.style.MozOpacity<1)
    cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
  else if (cur2.filters&&cur2.filters.alpha.opacity<100)
    cur2.filters.alpha.opacity+=10
  else if (window.highlighting)
    clearInterval(highlighting)
}


// DATE AZIENDE
function SetData(valore) {
  document.adminform.expdate.value = valore;
}

function disabilitaDateDa(date) {
	var ctr_date = new Date(document.getElementById('data_inizio').value.substr( 0,4 ),document.getElementById('data_inizio').value.substr( 5,2 )-1,document.getElementById('data_inizio').value.substr( 8,2 ));
	if (date.getTime() < ctr_date.getTime())
		return true;
	return false;
}
// FINE DATE AZIENDE


// BANNER
function disabilitaDateDaBanner1(date) {
	var ctr_date = new Date();
	if (date.getTime() < ctr_date.getTime())
		return true;
	return false;
}

function disabilitaDateDaBanner2(date) {
	var ctr_date = new Date(document.getElementById('registrazione').value.substr( 0,4 ),document.getElementById('registrazione').value.substr( 5,2 )-1,document.getElementById('registrazione').value.substr( 8,2 ));
	if (date.getTime() < ctr_date.getTime())
		return true;
	return false;
}

/*function SetData1(valore) {
	var ctr_date = new Date(document.getElementById('registrazione').value.substr( 0,4 ),document.getElementById('registrazione').value.substr( 5,2 )-1,document.getElementById('registrazione').value.substr( 8,2 ));
	var domani;
  document.adminform.registrazione.value = valore;
	if(document.adminform.scadenza.value == 1)
	  domani = new Date(ctr_date.getTime()+(1000*3600*24*30));
	else if(document.adminform.scadenza.value == 2)
	  domani = new Date(ctr_date.getTime()+(1000*3600*24*60));
	else if(document.adminform.scadenza.value == 3)
	  domani = new Date(ctr_date.getTime()+(1000*3600*24*90));
	else if(document.adminform.scadenza.value == 6)
	  domani = new Date(ctr_date.getTime()+(1000*3600*24*180));
	else if(document.adminform.scadenza.value == 12)
	  domani = new Date(ctr_date.getTime()+(1000*3600*24*360));		
  document.adminform.scadenza1.value = domani.getYear(domani) + "-" + domani.getMonth(domani) + "-" + domani.getDate(domani) ;
}*/

function SetData1(valore) {
  document.adminform.registrazione.value = valore;
}
// FINE BANNER
