var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

//********************************
//	Cookies funkcijas 
//********************************
	
function Count(info){
var WWHCount = GetCookie('WWHCount')
if (WWHCount == null) {
WWHCount = 0;
}else{
WWHCount++;
}

SetCookie ('WWHCount', WWHCount, exp);
return WWHCount;
}


function set(){
visitornamec = prompt("");
SetCookie ('visitornamec', visitornamec, exp);
SetCookie ('WWHCount', 0, exp);
}

function getCookieVal (offset) { 
var endstr = document.cookie.indexOf (";", offset); 
if (endstr == -1) 
endstr = document.cookie.length; 
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) { 
var arg = name + "="; 
var alen = arg.length; 
var clen = document.cookie.length; 
var i = 0; 
while (i < clen) { 
var j = i + alen; 
if (document.cookie.substring(i, j) == arg) 
return getCookieVal (j); 
i = document.cookie.indexOf(" ", i) + 1; 
if (i == 0) break; 
} 
return '';
}

function SetCookie (name, value) { 
	
var argv = SetCookie.arguments; 
var argc = SetCookie.arguments.length; 
var expires = (argc > 2) ? argv[2] : null; 
var path = (argc > 3) ? argv[3] : null; 
var domain = (argc > 4) ? argv[4] : null; 
var secure = (argc > 5) ? argv[5] : false; 
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) + 
((domain == null) ? "" : ("; domain=" + domain)) + 
((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) { 
var exp = new Date(); 
exp.setTime (exp.getTime() - 1); 
var cval = GetCookie (name); 
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


//SetCookie ('visitornamec', 'reinis', exp);
//alert(GetCookie('visitornamec'));
//DeleteCookie ('visitornamec') 		

function SetRepseCookies(){
	forma = document.forms['Repse'];
	
	SetCookie ('popPERS',forma['popPERS'].value, exp);
	SetCookie ('popSTEXT',forma['popSTEXT'].value, exp);
	SetCookie ('popSUTITAJS',forma['popSUTITAJS'].value, exp);
	SetCookie ('popTALR',forma['popTALR'].value, exp);
	SetCookie ('popEMAIL',forma['popEMAIL'].value, exp);	
	SetCookie ('popPARAKSTS',forma['popPARAKSTS'].value, exp);
	//Checkboxu setoshana
		if(forma['popChkSTEXT'].checked == true){
			SetCookie ('popChkSTEXT','checked', exp);
		}else{SetCookie ('popChkSTEXT','unchecked', exp);}
		
		if(forma['popChkITEXT'].checked == true){
			SetCookie ('popChkITEXT','checked', exp);
		}else{SetCookie ('popChkITEXT','unchecked', exp);}	

		if(forma['popChkDAVANA'].checked == true){
			SetCookie ('popChkDAVANA','checked', exp);
		}else{SetCookie ('popChkDAVANA','unchecked', exp);}			

		if(forma['popChkZIEDI'].checked == true){
			SetCookie ('popChkZIEDI','checked', exp);
		}else{SetCookie ('popChkZIEDI','unchecked', exp);}
		
	//Diasableta lodzinja
		if(forma['popSTEXT'].disabled == true){
			SetCookie ('popSTEXTD','true', exp);
		}else{SetCookie ('popSTEXTD','false', exp);}				
		
	//Set cookies lai saprastu ka nāk no Repses	
		typ = document.forms['Repse'].typ.value
		ca  = document.forms['Repse'].ca.value
		SetCookie ('typ',typ, exp);
		SetCookie ('ca',ca, exp);
		
}
function GetRepseCookies(){

	forma = document.forms['Repse'].popPERS.value=GetCookie('popPERS');
	forma = document.forms['Repse'].popSTEXT.value=GetCookie('popSTEXT');
	forma = document.forms['Repse'].popSUTITAJS.value=GetCookie('popSUTITAJS');
	forma = document.forms['Repse'].popTALR.value=GetCookie('popTALR');	
	forma = document.forms['Repse'].popEMAIL.value=GetCookie('popEMAIL');
	forma = document.forms['Repse'].popPARAKSTS.value=GetCookie('popPARAKSTS');	
			
	//ieguustam checkboxa statusu
		if(GetCookie('popChkSTEXT')=="checked"){
			forma = document.forms['Repse'].popChkSTEXT.checked=true;
		}	
		if(GetCookie('popChkITEXT')=="checked"){
			forma = document.forms['Repse'].popChkITEXT.checked=true;
		}			
		if(GetCookie('popChkDAVANA')=="checked"){
			forma = document.forms['Repse'].popChkDAVANA.checked=true;
		}	
		if(GetCookie('popChkZIEDI')=="checked"){
			forma = document.forms['Repse'].popChkZIEDI.checked=true;
		}
	//ieguustam disableta lodzinja stat
		if(GetCookie('popSTEXTD')=="true" || GetCookie('popSTEXTD')==''){
			forma = document.forms['Repse'].popSTEXT.disabled=true;
			forma = document.forms['Repse'].popSTEXT.style.backgroundColor='#dcdcdc'
		}else{
		forma = document.forms['Repse'].popSTEXT.style.backgroundColor='#ffffff';	
		forma = document.forms['Repse'].popSTEXT.disabled=false;}			
}

function DeleteRepseCookies(){
	DeleteCookie('popPERS');
	DeleteCookie('popSTEXT');
	DeleteCookie('popSUTITAJS');
	DeleteCookie('popTALR');
	DeleteCookie('popEMAIL');
	DeleteCookie('popPARAKSTS');
	DeleteCookie('popChkSTEXT');
	DeleteCookie('popChkITEXT');
	DeleteCookie('popChkDAVANA');
	DeleteCookie('popChkZIEDI');
	DeleteCookie('popSTEXTD');
	DeleteCookie('typ');
	DeleteCookie('ca');
}

function GetSetCategoryRepse(forma){
	typ = GetCookie('typ');
	ca =GetCookie('ca');
	if(typ=="26"){
	document.forms[forma].bsk_path.value ="typ="+typ+"&ca="+ca;	
	}	
return true;	
}
/**************************************************************************/

function openwin ($str){
  Win1 = window.open($str,'NewWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=750,height=550,top=10,left=10');
}
function openwin2 ($str){
  $adres='http://www.zemenitessniega.lv/gettext.php?id='+$str; 	
  Win1 = window.open($adres,'NewWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=250,height=290,top=10,left=10');
}

function banner_typ(typ){
if(typ=='bilde'){
 document.forms['NewBann'].bann_image.disabled=false;
 document.forms['NewBann'].bann_image.style.backgroundColor='white';
 
 document.forms['NewBann'].bann_html.disabled=true;
 document.forms['NewBann'].bann_html.style.backgroundColor='#dcdcdc';
}else{
 document.forms['NewBann'].bann_image.disabled=true;
 document.forms['NewBann'].bann_image.style.backgroundColor='#dcdcdc';
 
 document.forms['NewBann'].bann_html.disabled=false;
 document.forms['NewBann'].bann_html.style.backgroundColor='white'; 
}
}
function chBskAction(action,prd){
document.forms['basketForm'].bsk_action.value=action;
document.forms['basketForm'].prd_id.value=prd;	
}

function ps_apsveikt(el){
pas_n = document.forms['Pasutit'].ps_rec_vards;
//pas_u = document.forms['Pasutit'].ps_rec_uzvards;
pas_v = document.forms['Pasutit'].ps_rec_vecums;

  if (el.checked==true){
  pas_n.disabled = true;
  pas_n.style.backgroundColor='#dcdcdc'
  
  //pas_u.disabled = true;
  //pas_u.style.backgroundColor='#dcdcdc'

  pas_v.disabled = true;
  pas_v.style.backgroundColor='#dcdcdc'
  
  }else{
   if(el.checked==false){
	  pas_n.disabled = false;
	  pas_n.style.backgroundColor='#ffffff'
	  
 	//  pas_u.disabled = false;
	//  pas_u.style.backgroundColor='#ffffff'
	  
  	  pas_v.disabled = false;
	  pas_v.style.backgroundColor='#ffffff'


    }		  
  }
}
function ch_repse(elm){
rep_n = document.forms['Repse'].popSTEXT;

  if (elm.checked==true){
  rep_n.disabled = false;
  rep_n.style.backgroundColor='#ffffff'


  }else{
   if(elm.checked==false){
	  rep_n.disabled = true;
  	  rep_n.style.backgroundColor='#dcdcdc'

    }
  }
}
function FormSubmit(formname){
    document.forms[formname].submit();
    return false;
}
/* Paziņojumi */
function Message(id){
mess = new Array(2);
mess[0] = 'Nav aizpildīti visi obligātie lauciņi!';
mess[1] = 'Lūdzu aizpildiet visus lauciņus!';
mess[2] = 'Nekorekta e-mail adrese!';
mess[3] = 'Lūdzu aizpildiet vismaz vienu atgādināmo personu';
mess[4] = 'Ievadiet lūdzu korektu datumu';
mess[5] = 'Lai nosūtītu šo formu, jums jāpiekrīt līguma nosacījumiem';
mess[6] = 'Lūdzu izvēlaties vienu no apsveikuma veidiem!';
alert(mess[id]);
return false;
}
/* Validate */		
function Validate(ActiveForm){
ret = true;
forma = document.forms[ActiveForm];
	switch(ActiveForm){
		 case 'Reg':
			if(forma.reg_vards.value == ''){ret = Message(0); if(ret==false){return false;}}
			if(forma.reg_uzvards.value == ''){ret = Message(0); if(ret==false){return false;}}
			if(forma.reg_talr.value == ''){ret = Message(0); if(ret==false){return false;}}
			if(forma.reg_email.value == '' || !ValidateEmail(forma.reg_email.value)){ret = Message(2); if(ret==false){return false;}}
			if(forma.reg_niks.value == ''){ret = Message(0); if(ret==false){return false;}}
			if(forma.reg_parole1.value == ''){ret = Message(0); if(ret==false){return false;}}
			if(forma.reg_parole2.value == ''){ret = Message(0); if(ret==false){return false;}}
         break;	
		 case 'Login':
			if(forma.lg_name.value == ''){ret = Message(1); if(ret==false) return false;}
			if(forma.lg_pass.value == ''){ret = Message(1); if(ret==false) return false;}
         break;
		 case 'Pasutit':
			//if(forma.ps_niks.value == ''){ret = Message(0); if(ret==false) return false;}
			if(forma.ps_talr.value == ''){ret = Message(0); if(ret==false) return false;}
			if(forma.ps_niks.value == ''){ret = Message(0); if(ret==false) return false;}
			//if(forma.ps_uzvards.value == ''){ret = Message(0); if(ret==false) return false;}
		    if(forma.ps_email.value != ''){
		     	if(!ValidateEmail(forma.ps_email.value)){ret = Message(2); if(ret==false) return false;} 
			}
			if(forma.ps_pieg_adrese.value == ''){ret = Message(0); if(ret==false) return false;}
			if(forma.ps_pieg_piez.value == ''){ret = Message(0); if(ret==false) return false;}
			if(forma.ps_agree.checked != true){ret = Message(5); if(ret==false) return false;}			
         break;	         	
		 case 'guestbook':
			if(forma.Vards.value == ''){ret = Message(0); if(ret==false) return false;}
			if(forma.Text.value == ''){ret = Message(0); if(ret==false) return false;}
			if(forma.Email.value == '' || !ValidateEmail(forma.Email.value)){ret = Message(2); if(ret==false) return false;}	
         break;
		 case 'konkurss':
			if(forma.Vards.value == ''){ret = Message(0); if(ret==false) return false;}
			if(forma.e_pasts.value == ''){ret = Message(0); if(ret==false) return false;}
			myOption = -1;
			for (i=0; i<forma.Atbilde.length; i++) {
			if (forma.Atbilde[i].checked) {
			myOption = i;
			}
			}
			if (myOption == -1) {
			ret = Message(0); if(ret==false) return false;}
         break;
		 
		 
		 case 'frmAtgadinat':
		 	 P=false;
			for(i=1;i<11;i++){
				atgVU = 'atgVU'+i;
				atgDAT = 'atgDAT'+i;
			if(forma[atgVU].value != "" && forma[atgDAT].value !=""){P=true}
			}//endfor
				if(P==true){
					for(i=1;i<11;i++){
						atgDAT = 'atgDAT'+i;
						if( forma[atgDAT].value !=""){
							if (validateDate (forma[atgDAT].value) != true){ret = Message(4); if(ret==false) return false;} 
						}
					}	
				}else{
					ret = Message(3); if(ret==false) return false;
				}//if P
			if((forma['atgMOB'].value == '') && (forma['atgEMA'].value == '')){ret = Message(0); if(ret==false) return false;
			}else{
			 if(forma['atgEMA'].value != ''){
			 	if(!ValidateEmail(forma['atgEMA'].value)){ret = Message(2); if(ret==false) return false;} 
			 }
			}
			if(forma['atgPERS'].value == ''){ret = Message(0); if(ret==false) return false;}
			if(forma['atgKONT'].value == ''){ret = Message(0); if(ret==false) return false;}			
			if(forma['atgLIG'].checked != true){ret = Message(5); if(ret==false) return false;}

			//if(DA==false){ret = Message(3); if(ret==false) return false;} 
			
			//if(forma.atgVU1.value == ''){ret = Message(0); if(ret==false) return false;}
			//if(forma.Text.value == ''){ret = Message(0); if(ret==false) return false;}
			//if(forma.Email.value == '' || !ValidateEmail(forma.Email.value)){ret = Message(2); if(ret==false) return false;}	
         break;
		 case 'Repse':
		 	 if(forma.popPERS.value == ''){ret = Message(0); if(ret==false) return false;}
		 	 if(forma.popChkSTEXT.checked == false && forma.popChkITEXT.checked == false && forma.popChkDAVANA.checked == false && forma.popChkZIEDI.checked == false){
		 	 	ret = Message(6); if(ret==false) return false; 
		 	 } 
		 	 if(forma.popSUTITAJS.value == ''){ret = Message(0); if(ret==false) return false;}
		 	 if(forma.popTALR.value == ''){ret = Message(0); if(ret==false) return false;}
		 	 if(forma.popEMAIL.value != ''){
		 	 	if(!ValidateEmail(forma['popEMAIL'].value)){ret = Message(2); if(ret==false) return false;}  
		 	 }
		 	 if(forma.popPARAKSTS.value == ''){ret = Message(0); if(ret==false) return false;}
		 	 if(forma['popAGREE'].checked != true){ret = Message(5); if(ret==false) return false;}
		 break;	
		 case 'jaut_mums':
		 	 if(forma.jaut_vards.value == ''){ret = Message(0); if(ret==false) return false;}
		 	 if(forma.jaut_email.value == '' || !ValidateEmail(forma.jaut_email.value)){ret = Message(2); if(ret==false) return false;}	
		 	 if(forma.jaut.value == ''){ret = Message(0); if(ret==false) return false;}		 	 		 	 
		 break;
		 case 'pasutit_idejas':
		 	 if(forma.jaut_vards.value == ''){ret = Message(0); if(ret==false) return false;}
		 	 if(forma.jaut_email.value == '' || !ValidateEmail(forma.jaut_email.value)){ret = Message(2); if(ret==false) return false;}	
             if(forma['popAGREE'].checked != true){ret = Message(5); if(ret==false) return false;}		 	 
		 	 //if(forma.jaut.value == ''){ret = Message(0); if(ret==false) return false;}		 	 		 	 
		 break;		 	           

	}//switch
	if(!clicked){forma.submit();}
   	return ret;
}
function ValidateEmail(theinput)
{
	s=theinput
	if(s.search)
	{
		return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0)
	}
	if(s.indexOf)
	{
		at_character=s.indexOf('@')
		if(at_character<=0 || at_character+4>s.length)
			return false
	}
	if(s.length<6)
		return false
	else
		return true
}
function ValidateCreditCard(theinput,cardtype)
{
	val=theinput.value
	len=val.length
	for(position=0;position<len;)
	{
		if(val.charAt(position)==' ' || val.charAt(position)=='.' || val.charAt(position)=='-')
		{

			val=val.substring(0,position)+val.substring(position+1,len)
			len--
		}
		else
			position++
	}
	if(len<13)
		return false
	if(cardtype!='unknown')
	{
		if(isNaN(first=parseInt(val.charAt(0),10)))
			return false
		if(isNaN(second=parseInt(val.charAt(1),10)))
			return false
		if(isNaN(third=parseInt(val.charAt(2),10)))
			return false
		if((cardtype=='mastercard') && (len!=16 || first!=5 || second<1 || second>5))
			return false
		if((cardtype=='visa') && ((len!=16 && len!=13) || first!=4))
			return false
		if((cardtype=='amex') && (len!=15 || first!=3 || (second!=4 && second!=7)))
			return false
		if((cardtype=='dinersclub' || cardtype=='carteblanche') && (len!=14 || first!=3 || ((second!=0 || third<0 || third>5) && second!=6 && second!=8)))
			return false
		if((cardtype=='discover') && (len!=16 || first!=5 || second<1 || second>5))
			return false
		if((cardtype=='enroute') && (len!=15 || (val.substring(0,4)!='2014' && val.substring(0,4)!='2149')))
			return false
		if((cardtype=='jcb') && ((len!=16 || first!=3) && (len!=15 || (val.substring(0,4)!='2031' && val.substring(0,4)!='1800'))))
			return false
	}
	for(check=0,position=1;position<=len;position++)
	{
		if(isNaN(digit=parseInt(val.charAt(len-position),10)))
			return false
		if(!(position % 2))
			digit=parseInt('0246813579'.charAt(digit),10)
		check+=digit
	}
	return((check % 10)==0)
}
//----------------------------------------------------------------------------
// Code to determine the browser and version.
//----------------------------------------------------------------------------

function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

//----------------------------------------------------------------------------
// Code for handling the menu bar and active button.
//----------------------------------------------------------------------------

var activeButton = null;

// Capture mouse clicks on the page so any active button can be
// deactivated.

if (browser.isIE)
  document.onmousedown = pageMousedown;
else
  document.addEventListener("mousedown", pageMousedown, true);

function pageMousedown(event) {

  var el;

  // If there is no active button, exit.

  if (activeButton == null)
    return;

  // Find the element that was clicked on.

  if (browser.isIE)
    el = window.event.srcElement;
  else
    el = (event.target.tagName ? event.target : event.target.parentNode);

  // If the active button was clicked on, exit.

  if (el == activeButton)
    return;

  // If the element is not part of a menu, reset and clear the active
  // button.

  if (getContainerWith(el, "DIV", "menu") == null) {
    resetButton(activeButton);
    activeButton = null;
  }
}

function buttonClick(event, menuId) {

  var button;

  // Get the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  // Blur focus from the link to remove that annoying outline.

  button.blur();

  // Associate the named menu to this button if not already done.
  // Additionally, initialize menu display.

  if (button.menu == null) {
    button.menu = document.getElementById(menuId);
    if (button.menu.isInitialized == null)
      menuInit(button.menu);
  }

  // Reset the currently active button, if any.

  if (activeButton != null)
    resetButton(activeButton);

  // Activate this button, unless it was the currently active one.

  if (button != activeButton) {
    depressButton(button);
    activeButton = button;
  }
  else
    activeButton = null;

  return false;
}

function buttonMouseover(event, menuId) {

  var button;

  // Find the target button element.

  if (browser.isIE)
    button = window.event.srcElement;
  else
    button = event.currentTarget;

  // If any other button menu is active, make this one active instead.

  if (activeButton != null && activeButton != button)
    buttonClick(event, menuId);
}

function depressButton(button) {

  var x, y;

  // Update the button's style class to make it look like it's
  // depressed.

  button.className += " menuButtonActive";

  // Position the associated drop down menu under the button and
  // show it.

  x = getPageOffsetLeft(button);
  y = getPageOffsetTop(button) + button.offsetHeight;

  button.menu.style.left = x + "px";
  button.menu.style.top  = y + "px";
  button.menu.style.visibility = "visible";
}

function resetButton(button) {

  // Restore the button's style class.

  removeClassName(button, "menuButtonActive");

  // Hide the button's menu, first closing any sub menus.

  if (button.menu != null) {
    closeSubMenu(button.menu);
    button.menu.style.visibility = "hidden";
  }
}

//----------------------------------------------------------------------------
// Code to handle the menus and sub menus.
//----------------------------------------------------------------------------

function menuMouseover(event) {

  var menu;

  // Find the target menu element.

  if (browser.isIE)
    menu = getContainerWith(window.event.srcElement, "DIV", "menu");
  else
    menu = event.currentTarget;

  // Close any active sub menu.

  if (menu.activeItem != null)
    closeSubMenu(menu);
}

function menuItemMouseover(event, menuId) {

  var item, menu, x, y;

  // Find the target item element and its parent menu element.

  if (browser.isIE)
    item = getContainerWith(window.event.srcElement, "A", "menuItem");
  else
    item = event.currentTarget;
  menu = getContainerWith(item, "DIV", "menu");

  // Close any active sub menu.

  if (menu.activeItem != null)
    closeSubMenu(menu);

  // Set pointers.

  menu.activeItem = item;
  item.subMenu    = document.getElementById(menuId);

  // Highlight the item element.

  item.className += " menuItemHighlight";

  // Initialize the sub menu, if not already done.

  if (item.subMenu == null) {
    item.subMenu = document.getElementById(menuId);
    if (item.subMenu.isInitialized == null)
      menuInit(item.subMenu);
  }

  // Get position for submenu based on the menu item.

  x = getPageOffsetLeft(item) + item.offsetWidth;
  y = getPageOffsetTop(item);

  // Adjust position to fit in view.

  var maxX, maxY;

  if (browser.isNS) {
    maxX = window.scrollX + window.innerWidth;
    maxY = window.scrollY + window.innerHeight;
  }
  if (browser.isIE) {
    maxX = (document.documentElement.scrollLeft   != 0 ? document.documentElement.scrollLeft   : document.body.scrollLeft)
         + (document.documentElement.clientWidth  != 0 ? document.documentElement.clientWidth  : document.body.clientWidth);
    maxY = (document.documentElement.scrollTop    != 0 ? document.documentElement.scrollTop    : document.body.scrollTop)
         + (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
  }
  maxX -= item.subMenu.offsetWidth;
  maxY -= item.subMenu.offsetHeight;

  if (x > maxX)
    x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
      + (menu.offsetWidth - item.offsetWidth));
  y = Math.max(0, Math.min(y, maxY));

  // Position and show it.

  item.subMenu.style.left = x + "px";
  item.subMenu.style.top  = y + "px";
  item.subMenu.style.visibility = "visible";

  // Stop the event from bubbling.

  if (browser.isIE)
    window.event.cancelBubble = true;
  else
    event.stopPropagation();
}

function closeSubMenu(menu) {

  if (menu == null || menu.activeItem == null)
    return;

  // Recursively close any sub menus.

  if (menu.activeItem.subMenu != null) {
    closeSubMenu(menu.activeItem.subMenu);
    menu.activeItem.subMenu.style.visibility = "hidden";
    menu.activeItem.subMenu = null;
  }
  removeClassName(menu.activeItem, "menuItemHighlight");
  menu.activeItem = null;
}

//----------------------------------------------------------------------------
// Code to initialize menus.
//----------------------------------------------------------------------------

function menuInit(menu) {

  var itemList, spanList;
  var textEl, arrowEl;
  var itemWidth;
  var w, dw;
  var i, j;

  // For IE, replace arrow characters.

  if (browser.isIE) {
    menu.style.lineHeight = "2.5ex";
    spanList = menu.getElementsByTagName("SPAN");
    for (i = 0; i < spanList.length; i++)
      if (hasClassName(spanList[i], "menuItemArrow")) {
        spanList[i].style.fontFamily = "Webdings";
        spanList[i].firstChild.nodeValue = "4";
      }
  }

  // Find the width of a menu item.

  itemList = menu.getElementsByTagName("A");
  if (itemList.length > 0)
    itemWidth = itemList[0].offsetWidth;
  else
    return;

  // For items with arrows, add padding to item text to make the
  // arrows flush right.

  for (i = 0; i < itemList.length; i++) {
    spanList = itemList[i].getElementsByTagName("SPAN");
    textEl  = null;
    arrowEl = null;
    for (j = 0; j < spanList.length; j++) {
      if (hasClassName(spanList[j], "menuItemText"))
        textEl = spanList[j];
      if (hasClassName(spanList[j], "menuItemArrow"))
        arrowEl = spanList[j];
    }
    if (textEl != null && arrowEl != null)
      textEl.style.paddingRight = (itemWidth 
        - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
  }

  // Fix IE hover problem by setting an explicit width on first item of
  // the menu.

  if (browser.isIE) {
    w = itemList[0].offsetWidth;
    itemList[0].style.width = w + "px";
    dw = itemList[0].offsetWidth - w;
    w -= dw;
    itemList[0].style.width = w + "px";
  }

  // Mark menu as initialized.

  menu.isInitialized = true;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------

function getContainerWith(node, tagName, className) {

  // Starting with the given node, find the nearest containing element
  // with the specified tag name and style class.

  while (node != null) {
    if (node.tagName != null && node.tagName == tagName &&
        hasClassName(node, className))
      return node;
    node = node.parentNode;
  }

  return node;
}

function hasClassName(el, name) {

  var i, list;

  // Return true if the given element currently has the given class
  // name.

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}

function removeClassName(el, name) {

  var i, curList, newList;

  if (el.className == null)
    return;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}

function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);
    y=75;
  return y;
}

//datuma funkcijas
function validateDate (strDate) {
   var parsedDate = strDate.split (".");
   if (parsedDate.length != 3) return false;
   var day, month, year;
   month = parsedDate[1];
   day = parsedDate[0];
   year = parsedDate[2];
   
   strDate=month+'-'+day+'-'+year;
   var objDate = new Date (strDate);
   if (month-1 != objDate.getMonth()) return false;
   if (day != objDate.getDate()) return false;
   if (year != objDate.getFullYear()) return false;

   return true;
} 
