

/*
This doesn't work together with Jquery's datePicker, I don't think it's needed anymore

// To cover IE 5.0's lack of the push method
Array.prototype.push = function(value) {
  this[this.length] = value;
}
*/

function showSearchInfo(select)
{
	var value = select.options[select.selectedIndex].text;
	document.getElementById("searchInfo").innerHTML = "";
	if(value == "datum")
	{
		document.getElementById("searchInfo").innerHTML = "Exempel: 2007-01-25";
	}
}

function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}

function change_visibility(id,show) 
{
	var e = document.getElementById(id);

   	if (show == true)
		e.style.display = 'block';
   	else if (show == false)
 		e.style.display = 'none';
}

$(document).ready(function() 
 {
	$("#password").val("asdfasdf"); //Dummy password as default.
	$("#passwordCheck").val("asdfasdf");

 	toggleDisplay("#passwordTriggerON","#changePassword","show");	
 	toggleDisplay("#passwordTriggerOFF","#changePassword","hide");	

 	toggleDisplay("#passwordTriggerON","#activatePassword","hide");	
 	toggleDisplay("#passwordTriggerOFF","#activatePassword","show");	
 	
 	
 	if ($("#showError").val() == "1")
 	{
		$("#changePassword").css({'display': 'block'});
		$("#activatePassword").css({'display': 'none'});
 	}
 	
 	$("#passwordTriggerON").click(function(e)
 	{
 		$("#newPassword").val("1");
 		$("#password").val("");
 		$("#passwordCheck").val("");

 	});

 	$("#passwordTriggerOFF").click(function(e)
 	{
 		$("#newPassword").val("0");
 		$("#password").val("asdfasdf");
 		$("#passwordCheck").val("asdfasdf");
 		
 	});
 });

function toggleDisplay(trigger,object,display)
{
	if (display == "show")
		$(trigger).click(function(e)
		{
			$(object).css({'display': 'block'});
		}); 
	
	if (display == "hide")
		$(trigger).click(function(e)
		{
			$(object).css({'display': 'none'});
		}); 

}
 
 