 function textCounter(field, countfield, maxlimit){
				if (field.value.length > maxlimit)
					field.value = field.value.substring(0, maxlimit);
				else 
					countfield.value = maxlimit - field.value.length;
			}

function PopupPic(sPicURL){ 
						
				window.open("./viewImage.php?"+sPicURL, "","resizable=1,HEIGHT=50,WIDTH=50"); 
	} 
	var checkobj

	function agreesubmit(el){
	checkobj=el
	if (document.all||document.getElementById){
	for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
	var tempobj=checkobj.form.elements[i]
	if(tempobj.type.toLowerCase()=="submit")
	tempobj.disabled=!checkobj.checked
	}
	}
	}
	
	function defaultagree(el){
	if (!document.all&&!document.getElementById){
	if (window.checkobj&&checkobj.checked)
	return true
	else{
	alert("Palun loe ja nõustu tingimustega")
	return false
	}
	}
	}
	
	function passwordStrength(password)
	{
	var desc = new Array();
	desc[0] = "Kehv";
	desc[1] = "Juba parem";
	desc[2] = "Veel parem";
	desc[3] = "Keskmine";
	desc[4] = "Tugev";
	desc[5] = "Parim";

	var score   = 0;

	//if password bigger than 6 give 1 point
	if (password.length > 6) score++;

	//if password has both lower and uppercase characters give 1 point	
	if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;

	//if password has at least one number give 1 point
	if (password.match(/\d+/)) score++;

	//if password has at least one special caracther give 1 point
	if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) )	score++;

	//if password bigger than 12 give another 1 point
	if (password.length > 12) score++;

	 document.getElementById("passwordDescription").innerHTML = desc[score];
	 document.getElementById("passwordStrength").className = "strength" + score;
	}
	
function showHide(shID) {
   if (document.getElementById(shID)) {
      if (document.getElementById(shID+'-show').style.display != 'none') {
         document.getElementById(shID+'-show').style.display = 'none';
         document.getElementById(shID).style.display = 'block';
      }
      else {
         document.getElementById(shID+'-show').style.display = 'inline';
         document.getElementById(shID).style.display = 'none';
      }
   }
}

function shHi(shID) {
   if (document.getElementById(shID)) {
      if (document.getElementById(shID+'-show').style.display != 'none') {
         document.getElementById(shID+'-show').style.display = 'none';
         document.getElementById(shID).style.display = 'block';
      }
      else {
         document.getElementById(shID+'-show').style.display = 'inline';
         document.getElementById(shID).style.display = 'none';
      }
   }
}

 function setbg(color)
{
document.getElementById("styled").style.background=color
}

	function Show(e)
    {
        e = e ? e : event;
        var Popup = document.getElementById('Popup');
        /* get the mouse left position */
        x = e.clientX + document.body.scrollLeft;
        /* get the mouse top position  */
        y = e.clientY + document.body.scrollTop + 35;
        /* display the pop-up */
        Popup.style.display="block";
        /* set the pop-up's left */
        Popup.style.left = x;
        /* set the pop-up's top */
        Popup.style.top = y;
    }
    /* this function hides the pop-up when
     user moves the mouse out of the link */
    function Hide()
    {
        /* hide the pop-up */
        document.getElementById('Popup').style.display="none";
    }
    window.onload = function(){
        var ele = document.getElementById('testiks');
        ele.onmouseout = Hide;
        ele.onmouseover = Show;
        ele.onmousemove = Show;
    } 
	
	function showHide(shID) {
	if (document.getElementById(shID)) {
		if (document.getElementById(shID+'-show').style.display != 'none') {
			document.getElementById(shID+'-show').style.display = 'none';
			document.getElementById(shID).style.display = 'block';
		}
		else {
			document.getElementById(shID+'-show').style.display = 'inline';
			document.getElementById(shID).style.display = 'none';
		}
	}
}
