function SetDepDate(ArrDateId, DepDateId)
{
    try
    {
        var ArrDateObj = null;
        ArrDateObj = document.getElementById(ArrDateId);
        if(ArrDateObj != null)
        {
            var DepDateObj = null;
            var DayPart = '';
            var MonthPart = '';
            var DepDate = '';
            var ArrArr = ArrDateObj.value.split('.');
            var ArrDate = new Date(ArrArr[2], ArrArr[1] - 1, ArrArr[0]);
            ArrDate.setUTCDate(ArrDate.getUTCDate() + 1);
				
            DayPart = ArrDate.getDate().toString();
            MonthPart = (ArrDate.getMonth() + 1).toString();
				
            DepDate = ((DayPart.length > 1) ? DayPart : '0' + DayPart) + '.' +  ((MonthPart.length > 1) ? MonthPart : '0' + MonthPart) + '.' +  ArrDate.getFullYear();
            DepDateObj = document.getElementById(DepDateId);
            if(DepDateObj != null)
            {
   		      DepDateObj.value = DepDate;
            }
        }
    }
    catch(exception)
    {
	   alert(exception.number & 0xFFFF);
	   alert(exception.description);
    }
}

function ChangeImages() 
{
   if(document.images) 
   {
	   for (var i = 0; i < ChangeImages.arguments.length; i += 2) 
	   {
		   document[ChangeImages.arguments[i]].src = ChangeImages.arguments[i + 1];
		}
   }
}

function ApplaySpecialDesign()
{
 /* 
  for(var i = 0; i < document.forms[0].CityList.options.length; i++)
   {
      var Item = document.forms[0].CityList.options[i];
      if((Item.value == 12) || (Item.value == 13) || (Item.value == 14))
      {
         Item.style.backgroundColor = "#8B262C";
         Item.style.color = "#FFFFFF";
      }
   }
 */
   for(var i = 0; i < document.forms[0].HotelList.options.length; i++)
   {
      var Item = document.forms[0].HotelList.options[i];
      if((Item.value == 12) || (Item.value == 13) || (Item.value == 14))
      {
         Item.style.backgroundColor = "#8B262C";
         Item.style.color = "#FFFFFF";
      }
   }
}

function Synchronize(sIdx) 
{
   document.forms[0].HotelList.selectedIndex = sIdx;
   document.forms[0].CityList.selectedIndex = sIdx;
   document.forms[0].SelectedHotelId.value = document.forms[0].CityList.options[sIdx].value;
   return;
}


function zmienhotel(idHotel) 
{
   var i;
   for(i=0; i < document.forms[0].HotelList.length; i++) 
   {
      if(document.forms[0].HotelList.options[i].value == idHotel)
      {   
         break;
      }
   }
   document.forms[0].HotelList.selectedIndex = i;
   document.forms[0].CityList.selectedIndex = i;
   document.forms[0].SelectedHotelId.value = idHotel;
   return;
}

function PopUpWindowSized(link, title, width, height)
{ 
   window.open(link, title, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=25, top=25, width=' + width + ', height=' + height); 
}

function PopUpWindowManualScrolled(link, title, width, height)
{ 
   window.open(link,title,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=5, top=25, width=' + width + ', height=' + height);
}

function ClearString(Variable)
{
   var what;
   what = /"/g;
   var ret = Variable.replace(what, '');
   what = /\'/g;
   ret = ret.replace(what, '');
   what = /\</g;
   ret = ret.replace(what, '');
   what = /\>/g;
   ret = ret.replace(what, '');
   return (ret);
}

function SubmitMainForm()
{
   var MainForm = document.getElementById('MainForm');
   if(MainForm)
	{
      MainForm.submit();
   }
   else
   {
	   alert('There is no MainForm in the document DOM tree.');
   }
}

function SubmitIndex()
{
   var Validator = document.getElementById('CityListCompareValidator');
   var MainForm = document.getElementById('MainForm');
	
	  ArrDateObj = document.getElementById('ArrDate_foo');
	  DepDateObj = document.getElementById('DepDate_foo');	
		
	  var ArrArr = ArrDateObj.value.split('.');
	  var DepArr = DepDateObj.value.split('.');		
	
	
	
	
	
   if(MainForm)
	{
      if((MainForm.HotelList.value > 0) && (MainForm.HotelList.value < 8))
      {
                   if(ArrArr[1] > DepArr[1])
                   {
                   alert('Niepoprawna data.');		
	          		 return;
                   } 
					  
						  if(ArrArr[1] < DepArr[1])
                   {
							 MainForm.action = 'strona,h'+MainForm.HotelList.value+',rezerwacje.html';
                   MainForm.submit();
						  return;
                   } 
						 
						 
						 	  if(ArrArr[1] = DepArr[1])
                   {
                  
					    		  if(ArrArr[0] > DepArr[0])
                        {
                        alert('Data wyjazdu przed datą przyjazdu.');		
	          	     	 return;
                        } else {
								 MainForm.action = 'strona,h'+MainForm.HotelList.value+',rezerwacje.html';
					    	   MainForm.submit();
						 
					       	 }
					 
						
					 						
						
                   } 
						 
						  if((document.getElementById('ArrDate_foo').value=='') || (document.getElementById('DepDate_foo').value==''))
                   {
                   alert('Podaj datę.');		
	          		 return;
                   } 
						 
						 
						
						
      }
      else
      {
        	alert('Proszę wybrać hotel.');		
			return;
      }
		
		
		
		
		
   }
}


	function wypisz()
	{
		if (document.nlregform.email.value == '')
		{
			alert('Proszę podać email');
			document.nlregform.email.focus();
			return;
		}

		if (!isEmailAddr(document.nlregform.email.value))
		{
			alert('Proszę podać prawidłowy adres email');
			document.nlregform.adres_email.focus();
			return;
		}
		
		document.nlregform.action = 'index.php';
		document.nlregform.subname.name = 'action';
		document.nlregform.whattodo.value = 'usun';
		document.nlregform.submit();
	}


function CheckEmail(email)
{
   bc = new Array('^','\\','[','..',']','*','(','[',']','+',')','$','/','@','{','}','"',"'",'%','&','#','!',';',':',',','`','~','=','|','?');

  	fs = email.substring(0,email.indexOf('@',0));
   ss = email.substring(email.indexOf('@',0)+1,email.indexOf('.',email.indexOf('@',0)));
   ts = email.substring(email.indexOf('.',email.indexOf('@',0))+1,email.length);
 
	for (a=0 ;a<bc.length ;a++)
	{
     if((fs.indexOf(bc[a],0) != -1) || (ss.indexOf(bc[a],0) != -1) || 
	  		 (ts.indexOf(bc[a],0) != -1) || (email.indexOf('..',0) != -1) || 
			 (email.substring(email.length-1,email.length) == '.') || 
			 (email.indexOf('@',0) == -1)|| (email.indexOf('.',email.indexOf('@',0)) == -1) || 
			 (fs == '') || (ss == '') || (ts == ''))
	   {
	    		 return false;
		}
   }	
	return true;	
}