
function JS_ConfirmLink(thelink, confirm_text)
{
   is_confirmed = confirm(confirm_text);
   
   if (is_confirmed)
      thelink.href += "&is_confirmed=1";

   return is_confirmed;
}

function JS_equalPasswords(id1, id2, notequal_text)
{
	p1 = document.getElementById(id1);
	p2 = document.getElementById(id2);

	if (p1.value != p2.value)
	{
		p1 = "";
		p2 = "";
		alert(notequal_text);
		return false;
	}
}


var jsc_open = null;


function JS_ShowById(id, close)
{  //close == false -> store opened in jsc_open;
   //close == true  -> close jsc_open
   //close == id    -> close getElementById(id)
   
   var tmp = null;

   if (close == true)
   { //close the last opened "object"
    
      if (jsc_open != null)
      {
//         jsc_open.style.display = 'none';
//         jsc_open.style.visibility = 'hidden';
         jsc_open.className = 'hidden';

         if (jsc_open == document.getElementById(id))
         {
            jsc_open = null;
            return;
         }
         jsc_open = null;
      }
      else
      {
         tmp = document.getElementById(id); 
         if (tmp.className == 'shown')
         {
            tmp.className = 'hidden';
            return;
         }
      }
   }
   else if (close == id)
   { //close id

      tmp = document.getElementById(id);
      

//      tmp.style.display = 'none';
//      tmp.style.visibility = 'hidden';
      tmp.className = 'hidden';

      if (tmp == jsc_open)
         jsc_open = null;
   
      return;
   }
   
   jsc_open = document.getElementById(id); 

//   jsc_open.style.display = '';
//   jsc_open.style.visibility = 'visible';
   jsc_open.className = 'shown';

}

var tColor = "";

function JS_checkDate(i, wrong_dateformat)
{ //change dateformat to DD-MM-YYYY
   d = i.value;
   l = d.length;
   
   if (!d.match(/^(0[1-9]|[12][0-9]|3[01])-{0,1}(0[1-9]|1[0-2])-{0,1}([0-9]{2}|20[0-9]{2})$/))
   {
      tColor = i.style.color;
      i.style.color = "#FF3333";
      alert(wrong_dateformat);
      return;
   }
   else
   {
      if (i.style.color == "#FF3333")
         i.style.color = tColor;

      if (d.match(/^\d{6}$/))
      { // DDMMYY
         i.value = d.substr(0, 2) + "-" + d.substr(2, 2) + "-20" + d.substr(4, 2);
      }
      else if (d.match(/^\d{8}$/))
      { // DDMMYYYY
         i.value = d.substr(0, 2) + "-" + d.substr(2, 2) + "-" + d.substr(4, 4);
      }
      else if (d.match(/^\d{2}-\d{2}-\d{2}$/))
      { // DDMMYYYY
         i.value = d.substr(0, 6) + "20" + d.substr(6, 2);
      }
   }
}

function JS_killInit(i, m)
{
   if (i.value == m)
      i.value = "";
}
