function delitem(id,mod, del) {
	if (confirm('Do You really want to delete this element?\n Please select [OK] to confirm or [CANCEL] to discard.'))
		{
			location.href="index.php?mod=" +mod+ "&submod="+del+"&id="+id;
		}
}

 function showpicture(url,width, height)
{
        LeftPosition=(screen.width)?(screen.width-width)/2:100;
     TopPosition=(screen.height)?(screen.height-height)/2:100;
        var Win = window.open(url,'showpic','width=' + width + ',height=' + height + ',top='+TopPosition+',left='+LeftPosition+',resizable=0,scrollbars=no,menubar=no,toolbar=no,status=no')
}
 function showpicture_pos(url,width, height)
{
        LeftPosition=(screen.width)?(screen.width-width)/2:100;
     TopPosition=(screen.height)?(screen.height-height)/2:100;
	LeftPosition+=340;
        var Win = window.open(url,'showpic','width=' + width + ',height=' + height + ',top='+TopPosition+',left='+LeftPosition+',resizable=0,scrollbars=no,menubar=no,toolbar=no,status=no')
}
 function showpicture_scroll(url,width, height)
{
        LeftPosition=(screen.width)?(screen.width-width)/2:100;
     TopPosition=(screen.height)?(screen.height-height)/2:100;
        var Win = window.open(url,'showpic','width=' + width + ',height=' + height + ',top='+TopPosition+',left='+LeftPosition+',resizable=0,scrollbars=yes,menubar=no,toolbar=no,status=no')
}

function descr (header, content)
{
	html = '';
	if (content != '')
		html += '<span class="sh"><b>'+ header + ':\n\r </b></span>' + content;
	//if (html == '') return;
	return overlib (html);
}

function doff()
{
	return nd();
}

function check_explorer() {
	   var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
	   if (navigator.userAgent.indexOf('Mac') >=0) {win_ie_ver = 0;}
	   if (navigator.userAgent.indexOf('Windows CE') >=0) {win_ie_ver = 0;}
	   if (navigator.userAgent.indexOf('Gecko') >=0) {win_ie_ver = 0;}
	   if (navigator.userAgent.indexOf('Opera') >=0) {win_ie_ver = 0;}
	   return win_ie_ver;
}

	function addopt(sel, sel2, btn1,btn2)
	{
		for (p = sel.length - 1; p >= 0; p--){
			if (sel.options [p].selected)	{
			opt = sel.options [p];
			if (check_explorer()==0)
			    sel2.add (new Option (opt.text, opt.value),null);
			else
				sel2.add (new Option (opt.text, opt.value));
			sel.remove (p);}
}
			if (sel.length== 0)
			{
				btn1.disabled = true;
			}
			else 
				btn1.disabled = false;

			if (sel2.length== 0)
			{
				btn2.disabled = true;
			}
		else 
			btn2.disabled = false;

	}


	function delopt(sel, sel2, btn1,btn2)
	{
		if (sel.length>0) {
		for (p = sel.length - 1; p >= 0; p--){
			if (sel.options [p].selected)	{
			opt = sel.options [p];
			if (check_explorer()==0)
			    sel2.add (new Option (opt.text, opt.value),null);
			else 
				sel2.add (new Option (opt.text, opt.value));
			sel.remove (p);}
		}
		if (sel.length == 0)
		{
			btn2.disabled = true;
		}
		else 
			btn2.disabled = false;

		if (sel2.length== 0)

		{
			btn1.disabled = true;
		}
		else 
			btn1.disabled = false;
    }
	}

	function up(sel)
	{
		if (sel.selectedIndex > 0) {
			var tab=new Array;
			opt = sel.options [sel.selectedIndex];
			which=opt.index;
			for (i=0;i<sel.length;i++) {
			if (i==which) {
				tab[i]=sel[i-1];
				tab[i-1]=sel[i];
			}    
			else
			tab[i]=sel[i];
			}
			    for (i=0;i<sel.length;i++)    
			    {	sel.remove (i);}
			for (i=0;i<tab.length;i++) {
			    sel[i]=tab[i];
			}
			
	    }
	}
	function down(sel)
	{
		if (sel.selectedIndex <sel.length) {
			var tab=new Array;
			opt = sel.options [sel.selectedIndex];
			which=opt.index;
			for (i=0;i<sel.length;i++) {
			if (i==which+1) {
				tab[i-1]=sel[i];
				tab[i]=sel[i-1];
			}    
			else
			tab[i]=sel[i];
			}
			    for (i=0;i<sel.length;i++)    
			    {	sel.remove (i);}
			for (i=0;i<tab.length;i++) {
			    sel[i]=tab[i];
			}
			
	    }
	}	
	function select_all()
	{
		sel1 = document.forms['editstructure'].elements ['leftset[]'];
		for (p = 0; p < sel1.length; p++)		sel1.options[p].selected = true;

		sel1 = document.forms['editstructure'].elements ['middleset[]'];
		for (p = 0; p < sel1.length; p++)		sel1.options[p].selected = true;

		sel1 = document.forms['editstructure'].elements ['rightset[]'];
		for (p = 0; p < sel1.length; p++)		sel1.options[p].selected = true;

      return true;
	}
	
	function count_selected(sel) {
		howmany="<span class='header'>You have selected <b>" + sel + "</b> email addresses</span>";
		document.getElementById("counter").innerHTML=howmany;
	}
	
	
	function addopt2(sel, sel2, btn1,btn2)
	{
		for (p = sel.length - 1; p >= 0; p--){
			if (sel.options [p].selected)	{
			opt = sel.options [p];
			if (check_explorer()==0)
			    sel2.add (new Option (opt.text, opt.value),null);
			else
				sel2.add (new Option (opt.text, opt.value));
			sel.remove (p);}
}
			if (sel.length== 0)
			{
				btn1.disabled = true;
			}
			else 
				btn1.disabled = false;

			if (sel2.length== 0)
			{
				btn2.disabled = true;
			}
		else 
			btn2.disabled = false;

			count_selected(sel2.length);
	}


	function delopt2(sel, sel2, btn1,btn2)
	{
		if (sel.length>0) {
		for (p = sel.length - 1; p >= 0; p--){
			if (sel.options [p].selected)	{
			opt = sel.options [p];
			if (check_explorer()==0)
			    sel2.add (new Option (opt.text, opt.value),null);
			else 
				sel2.add (new Option (opt.text, opt.value));
			sel.remove (p);}
		}
		if (sel.length == 0)
		{
			btn2.disabled = true;
		}
		else 
			btn2.disabled = false;

		if (sel2.length== 0)

		{
			btn1.disabled = true;
		}
		else 
			btn1.disabled = false;
    }
			count_selected(sel.length);	 
	}
	
		
		function select_all3()
	{
		sel1 = document.forms['send'].elements ['receivers[]'];
		for (p = 0; p < sel1.length; p++)		sel1.options[p].selected = true;

  
      return true;
	}	
	
			function select_all4()
	{
		sel1 = document.forms['send'].elements ['all'];
		for (p = 0; p < sel1.length; p++)		sel1.options[p].selected = true;

  
      return true;
	}	
	
	function showdetails(state, val) {
			 if (state==true) 	document.getElementById(val).style.display="block";
			 else document.getElementById(val).style.display="none";
	}

function check_enquiry() {
	var nameerr="";
	var emailerr="";
	var phoneerr="";
	var houseerr="";

	var dateserr="";

	if (document.enquiry_form.cname.value=="" ) nameerr="Please complete name field.\n";
	if (document.enquiry_form.cemail.value=="") emailerr="Please complete email field.\n";
	if (document.enquiry_form.cphone.value=="") phoneerr="Please complete phone field.\n";
	if (document.enquiry_form.chouse.value=="") phoneerr="Please complete house field (av. options: 25 or 26).\n";
	if (document.enquiry_form.cdates.value=="") dateserr="Please complete dates field.\n";
		if (nameerr!="" || emailerr!="" || phoneerr!="" || dateserr!="") {
		alert ('All fields marked with * are required!\n'+nameerr+emailerr+phoneerr+dateserr);
		return false;
	}
	else {
		return true; 
	}
}

function check_contact() {
	if (document.contact_form.cname.value=="" || document.contact_form.cemail.value=="" ||	document.contact_form.cphone.value=="" || 
		document.contact_form.csubject.options[document.contact_form.csubject.options.selectedIndex].value=="") {
		alert ('All fields marked with * are required!');
		return false;
	}
	else {
		return true; 
	}
}

	function showdetails(state, val) {
	if (state==true) 	document.getElementById(val).style.display="block";
	else document.getElementById(val).style.display="none";
	}

	
		 tiptext='select <b>START</b> day';
	 var startday='';
	 var endday='';
	 var startdate='';
	 var enddate='';
	 var start='';
	 var end='';
	 	
		 
			
  

	 	function setday(actdate,actday,index,av,actyear, house,finday) {
				
				  if (startday=='' || startday=='undefined') {
				<!-- setting proper index for startday and name for startdate ->	
					 start=actday;
					 startdate=actdate;
					 startday=finday;
					 tiptext='select <b>END</b> day';
					 document.getElementById(index).style.backgroundImage="url('../images/scard2.gif')";
					 }
					else {
				<!-- setting proper index for endday and name for enddate ->
					endday=finday;
					end=actday;
  				    enddate=actdate;					
   				    document.getElementById(index).style.backgroundImage="url('../images/scard2.gif')";
				 }
				 	

				if (startday!='' && endday!='') {
					<!-- if there are any errors ...->
					if (startday > endday) {
					   alert('End day cannot be earlier than Start day!');
					   endday='';
					   document.getElementById(index).style.backgroundImage="url('../images/scard.gif')";	
					}
					else {
							
				err=0;	
				var avtab=av.split("|");
				for (a=startday;a<=endday;a++) {
					if (avtab[a]==1) err++;
				}
				if (err>0) {
				alert ('There is no availability for dates selected - please reselect');
				location.href='index.php?mod=availability&submod=edititem&year='+actyear;			
	}
				else {
				   if (confirm('You have chosen: \n' + startdate + ' to ' + enddate + '\n\n Is this correct ?\n If yes, then click [OK] to proceed,otherwise click [CANCEL] to start new selection')) {
   	 	 location.href='index.php?mod=availability&submod=edititem&set=1&start=' + start + '&end=' + end+'&house='+house;
				   }  
				   else {
				location.href='index.php?mod=availability&submod=edititem&year='+actyear;

				 
						 }	
				}			 
				   }
				 }	
				}


function setday_enq(actdate,actday,index,av,actmonth, house) {
				  if (startday=='' || startday=='undefined') {
				<!-- setting proper index for startday and name for startdate ->				  
				  	 startday=index;
					 start=actday;
					 startdate=actdate;
					 tiptext='select <b>END</b> day';
					 document.getElementById(index).style.backgroundImage="url('../images/scard2.gif')";
					 }
					else {
				<!-- setting proper index for endday and name for enddate ->
					endday=index;
					end=actday;
  				    enddate=actdate;					
   				    document.getElementById(index).style.backgroundImage="url('../images/scard2.gif')";
				 }
				 	

					
					<!-- proceeding with confirmation ->					
				if (startday!='' && endday!='') {
					<!-- if there is any error ...->

					if (startday > endday) {
					   alert('End day cannot be earlier than Start day!');
					   endday='';
					   document.getElementById(index).style.backgroundImage="url('../images/scard.gif')";	
					}
					else {
					<!-- no error - changing whole period into reds ->
						for (i=startday;i<endday;i++) {
						document.getElementById(i).style.backgroundImage="url('../images/scard2.gif')";	
						}			
				var err=0;	  		

var avtab=av.split("|");
				for (a=startday;a<=endday;a++) {
				if (avtab[a]==1) err++;
	}
				if (err>0) {
				alert ('There is no availability for dates selected - please reselect');
				this.location.href='reservation_callendar.php?date='+actmonth+'&house='+house;
				}
				else {
				   if (confirm('You have chosen: \n' + startdate + ' to ' + enddate + '\n\n Is this correct ?\n If yes, then click [OK] to proceed,otherwise click [CANCEL] to start new selection')) {
				   	window.opener.document.getElementById("dates").value=startdate+' - '+enddate;
					window.opener.document.getElementById("house").value=house;
					window.close();
				   }  
				   else {
				this.location.href='reservation_callendar.php?date='+actmonth+'&house='+house;

				 
						 }	
				}			 
				   }
				 }	
				}


		 	function showtip2 ()	
			{		
				tiptext2="Select day";		 
				return overlib ('<p align=center>' + tiptext2 +'</p>');
			}	
		 	function showtip3 (text)	
			{				 
				return overlib ('<p align=center>' + text +'</p>');
			}	
			function setday2(actday, house) {
	 							
				if (actday!='') {
	   window.frames["framka"].location.href='_core/reservation.php?date=' + actday +'&house='+house;
					    actday='';
				 }	
				}	
					 
		function showtip ()
			{				 
				return overlib ('<p align=center>' + tiptext +'</p>');
			}

		function doff()
		 {
		 	return nd();
		}