﻿

var currentArea = 0;

function OfficeCalculate()
{
	var tpfield = document.getElementById('totalpeople');
	var totalpeople = document.getElementById('totalpeople').value;
	if(totalpeople == ''){
		tpfield.style.backgroundColor = "#ff6666";
		tpfield.focus();
	}
	else
	{
		var cabinetpeople = document.getElementById('cabinetpeople').value;
		var meetingrooms = document.getElementById('meetingrooms').value;
		var officeclass = document.getElementById('officeclass');
		officeclass = officeclass.options[officeclass.selectedIndex].value;
		var uri = "/applications/officecalc.html?totalpeople=" + totalpeople + "&cabinetpeople=" +  cabinetpeople + "&meetingrooms=" + meetingrooms + "&class=" + officeclass;		
		resultDiv = $('calcresponse');				
		if(resultDiv != null){		
			var req = new Request.HTML({url:uri + '&r=' + Math.random(), 
				onSuccess: function(html) {								
					resultDiv.set('text', '');				
					resultDiv.adopt(html);
				},
				onFailure: function() {				
					resultDiv.set('text', 'The request failed.');
				}
			});
			req.send();
		}
	}
}


function toggle_visibility(id)
{
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
}


function ResetForm(id)
{
	
	var frm_elements = document.getElementById(id).elements; 	
	for(i=0; i<frm_elements.length; i++) {
		field_type = frm_elements[i].type.toLowerCase();
		if(field_type == "checkbox" && frm_elements[i].checked) frm_elements[i].checked = false;
		if(field_type == "select-one") frm_elements[i].selectedIndex = 0;
		if(field_type == "text") frm_elements[i].value = ""; 
	}
}

function OverSubArea(id, dir)
{	
	var selector = document.getElementById('subcategory-selector-' + id);
	if(selector.className != "subcategory-selector-item ssi-hit")
	{
		if(dir == "over")
		{
			selector.className = "subcategory-selector-item ssi-over";
		}
		else
		{
			selector.className = "subcategory-selector-item ssi-default";
		}
	}
}

function ChangeSubArea(id)
{	
	var selector = document.getElementById('subcategory-selector-' + id);
	var area = document.getElementById('subcategory-selector-area-' + id);
	if(currentArea != 0){
		document.getElementById('subcategory-selector-' + currentArea).className = "subcategory-selector-item ssi-default";
		document.getElementById('subcategory-selector-area-' + currentArea).className = "subcategory-selector-area passive";
	}
	if(area.className == "subcategory-selector-area passive")
	{
		selector.className = "subcategory-selector-item ssi-hit";
		area.className = "subcategory-selector-area active";
	} else {
		selector.className = "subcategory-selector-item ssi-default";
		area.className = "subcategory-selector-area passive";
	}
	currentArea = id;
}

function Recall(phone, uri, lang)
{
	var numberfield = document.getElementById('recallnumber');
	if(phone == ""){
		numberfield.style.backgroundColor = "#ff6666";
	}
	else
	{
		window.open ("/applications/recall.html?number=" + phone + "&uri=" + uri + "&time=" + document.getElementById('time').value + "&lang=" + lang,"recallwin","status=1,toolbar=0,height=300,width=400");
	}
}

function TabulatorSwitch(id)
{
	var photos = document.getElementById('GalleryPhotos');
	var map = document.getElementById('GalleryMap');
	var tour = document.getElementById('GalleryTour');
	var video = document.getElementById('GalleryVideo');
		
	
	if(photos && id != 'GalleryPhotos'){
		photos.className = "gallery-bg passive";
		document.getElementById('GalleryPhotosBg').className = "tabulator-passive";
	}
	if(map && id != 'GalleryMap'){
		map.className = "gallery-bg passive";
		document.getElementById('GalleryMapBg').className = "tabulator-passive";
	}
	if(tour && id != 'GalleryTour'){
		tour.className = "gallery-bg passive";
		document.getElementById('GalleryTourBg').className = "tabulator-passive";
	}
	if(video && id != 'GalleryVideo'){
		video.className = "gallery-bg passive";
		document.getElementById('GalleryVideoBg').className = "tabulator-passive";
	}
	
	document.getElementById(id).className = "gallery-bg active";
	document.getElementById(id + 'Bg').className = "tabulator-active";
}

var wrapper;
var carousel;
var items;
var item_width;
var max_margin;
var totalposes;
var animation;
var prevpos = 1;

var wrapper1;
var carousel1;
var items1;
var item_width1;
var max_margin1;
var totalposes1;
var animation1;
var prevpos1 = 1;


window.addEvent('domready',InitSpecialOffers);

window.addEvent('domready',InitSpecialOffers1);

function InitSpecialOffers() {
	PopulateFavoritesInformer(document.getElementById('lang').value);
	wrapper = $('so-wrap');	
	if(wrapper != null){	
		carousel = $('so-carousel');
		items = $$('.so-citem');
		item_width = 246;
		max_margin = items.length * item_width - item_width;	
		totalposes = items.length;
		animation = new Fx.Tween(carousel, {duration: 200});	
		
		
		$('so-next').addEvent('click', function(){
			var position = parseInt(carousel.getStyle('left'));
			//alert(position);
			next_item(position);
		});
		
		$('so-prev').addEvent('click', function(){
			var position = parseInt(carousel.getStyle('left'));
			//alert(position);
			previous_item(position);
		});
	}
	
}

function InitSpecialOffers1() {
	PopulateFavoritesInformer(document.getElementById('lang').value);
	wrapper1 = $('so-wrap1');	
	if(wrapper1 != null){	
		carousel1 = $('so-carousel1');
		items1 = $$('.so-citem1');
		item_width1 = 246;
		max_margin1 = items1.length * item_width1 - item_width1;	
		totalposes1 = items1.length;
		animation1 = new Fx.Tween(carousel1, {duration: 200});	
		
		
		$('so-next1').addEvent('click', function(){
			var position1 = parseInt(carousel1.getStyle('left'));
			//alert(position1);
			next_item1(position1);
		});
		
		$('so-prev1').addEvent('click', function(){
			var position1 = parseInt(carousel1.getStyle('left'));
			//alert(position1);
			previous_item1(position1);
		});
	}
	
}



function previous_item(pos){
	var newpos = prevpos - 1;
	var newposition;
	if(newpos == 0){
		//newpos = max_margin / item_width + 1;
		newpos = totalposes;
		//newposition = -max_margin;
		newposition = (totalposes - 3) * item_width * -1;
	} else { 
		//newposition = pos + item_width;
		newposition = (newpos - 1) * item_width * -1;
		if(newpos > totalposes - 2) newposition = (totalposes - 3) * item_width * -1;
	}	
	document.getElementById('so-img-' + prevpos).src = '/p/catalogue/dot-passive.gif';
	var img = document.getElementById('so-img-' + newpos);
	img.src = '/p/catalogue/dot-active.gif';		
	prevpos = newpos;
	animation.start('left', newposition);
}

function next_item(pos){
	var newpos = prevpos + 1;		
	//if(pos == -max_margin){	
	if(newpos > totalposes){	
		animation.start('left', 0);
		newpos = 1;
	} else { 
		if(newpos <= totalposes - 2){
			var newposition = pos - item_width;
			animation.start('left', newposition);
		}
	}
	document.getElementById('so-img-' + prevpos).src = '/p/catalogue/dot-passive.gif';
	var img = document.getElementById('so-img-' + newpos);
	img.src = '/p/catalogue/dot-active.gif';
	prevpos = newpos;
}

function soGoto(newpos){	
	document.getElementById('so-img-' + prevpos).src = '/p/catalogue/dot-passive.gif';
	var img = document.getElementById('so-img-' + newpos);
	img.src = '/p/catalogue/dot-active.gif';
	var position = parseInt(carousel.getStyle('left'));
	var newposAlt = newpos;	
	var prevposAlt = prevpos;
	if(newpos > totalposes - 2) newposAlt = totalposes - 2;
	if(prevpos > totalposes - 2) prevposAlt = totalposes - 2;
	var newposition = position - item_width * (newposAlt - prevposAlt);
	animation.start('left', newposition);
	prevpos = newpos;
}


function previous_item1(pos1){
	var newpos1 = prevpos1 - 1;
	var newposition1;
	if(newpos1 == 0){
		//newpos1 = max_margin1 / item_width1 + 1;
		newpos1 = totalposes1;
		//newposition = -max_margin;
		newposition1 = (totalposes1 - 3) * item_width1 * -1;
	} else { 
		//newposition1 = pos + item_width1;
		newposition1 = (newpos1 - 1) * item_width1 * -1;
		if(newpos1 > totalposes1 - 2) newposition1 = (totalposes1 - 3) * item_width1 * -1;
	}	
	document.getElementById('so-img1-' + prevpos1).src = '/p/catalogue/dot-passive.gif';
	var img = document.getElementById('so-img1-' + newpos1);
	img.src = '/p/catalogue/dot-active.gif';		
	prevpos1 = newpos1;
	animation1.start('left', newposition1);
}

function next_item1(pos1){
	var newpos1 = prevpos1 + 1;		
	//if(pos1 == -max_margin){	
	if(newpos1 > totalposes1){	
		animation1.start('left', 0);
		newpos1 = 1;
	} else { 
		if(newpos1 <= totalposes1 - 2){
			var newposition1 = pos1- item_width1;
			animation1.start('left', newposition1);
		}
	}
	document.getElementById('so-img1-' + prevpos1).src = '/p/catalogue/dot-passive.gif';
	var img = document.getElementById('so-img1-' + newpos1);
	img.src = '/p/catalogue/dot-active.gif';
	prevpos1 = newpos1;
}

function soGoto1(newpos1){	
	document.getElementById('so-img1-' + prevpos1).src = '/p/catalogue/dot-passive.gif';
	var img = document.getElementById('so-img1-' + newpos1);
	img.src = '/p/catalogue/dot-active.gif';
	var position1 = parseInt(carousel1.getStyle('left'));
	var newposAlt1 = newpos1;	
	var prevposAlt1 = prevpos1;
	if(newpos1 > totalposes1 - 2) newposAlt1 = totalposes1 - 2;
	if(prevpos1 > totalposes1 - 2) prevposAlt1 = totalposes1 - 2;
	var newposition1 = position1 - item_width1 * (newposAlt1 - prevposAlt1);
	animation1.start('left', newposition1);
	prevpos1 = newpos1;
}


function SwitchSearchForm(formid)
{
	
	var form = document.getElementById(formid);
	var selector = document.getElementById("searchform-list-selector");	
	if (form.style.display == "")
	{
		selector.style.backgroundColor = "#ffffff";
		form.style.display = "none";	
	}
	else
	{
		selector.style.backgroundColor = "#efefef";
		form.style.display = "";
	}
}

function GoSimilar()
{
	var similars = $$('.similarvalue');
	var uri = $('similarbase').value + "?linkid=similar";
	for (var i = 0; i < similars.length; i++){
		if(similars[i].checked != ""){			
			uri = uri + "&" + similars[i].value;
		}
	}
	if (uri != $('similarbase').value + "?linkid=similar") window.location = uri;
}
	

//	document.getElementById('im12').style.visibility='hidden';




	window.addEvent('load',function(){



	var Dur = 3000; 
	var curInd = 0; 
	var curInd1 = 0; 
	var curInd2 = 0; 
	var curInd3 = 0; 
	var curInd4 = 0; 
	var curInd5 = 0; 
	var curInd6 = 0; 
	var curInd7 = 0; 
	var curInd8 = 0; 
	var curInd9 = 0; 

	
	var images1=new Array();
	var images2=new Array();
	var images3=new Array();
	var images4=new Array();
	var images5=new Array();
	var images6=new Array();
	var images7=new Array();
	var images8=new Array();
	var images9=new Array();

	var img;  
		
	img=document.getElementById('im11');
	if (img!=null)
		{
			images1[0] = document.getElementById('im11'); 
			
	img=document.getElementById('im12');
	if (img!=null)
		{
			images1[1] = document.getElementById('im12'); 
			images1[1].style.visibility='hidden';
		};	
	
	img=document.getElementById('im13');
	if (img!=null)
		{
			images1[2] = document.getElementById('im13');
			images1[2].style.visibility='hidden'; 
		};
	
	img=document.getElementById('im21');
	if (img!=null)
		{
			images2[0] = document.getElementById('im21'); 
		};	
	img=document.getElementById('im22');
	if (img!=null)
		{
			images2[1] = document.getElementById('im22'); 
			images2[1].style.visibility='hidden';
		};	
	
	img=document.getElementById('im23');
	if (img!=null)
		{
			images2[2] = document.getElementById('im23'); 
			images2[2].style.visibility='hidden';			
		};

	img=document.getElementById('im31');
	if (img!=null)
		{
			images3[0] = document.getElementById('im31'); 
		};	
	img=document.getElementById('im32');
	if (img!=null)
		{
			images3[1] = document.getElementById('im32'); 
			images3[1].style.visibility='hidden';			

		};	
	
	img=document.getElementById('im33');
	if (img!=null)
		{
			images3[2] = document.getElementById('im33');
			images3[2].style.visibility='hidden';		
 
		};

	img=document.getElementById('im41');
	if (img!=null)
		{
			images4[0] = document.getElementById('im41'); 
		};	
	img=document.getElementById('im42');
	if (img!=null)
		{
			images4[1] = document.getElementById('im42'); 
			images4[1].style.visibility='hidden';		
		};	
	
	img=document.getElementById('im43');
	if (img!=null)
		{
			images4[2] = document.getElementById('im43');
			images4[2].style.visibility='hidden';		
 
		};
	img=document.getElementById('im51');
	if (img!=null)
		{
			images5[0] = document.getElementById('im51'); 
		};	
	img=document.getElementById('im52');
	if (img!=null)
		{
			images5[1] = document.getElementById('im52');
			images5[1].style.visibility='hidden';		
 
		};	
	
	img=document.getElementById('im53');
	if (img!=null)
		{
			images5[2] = document.getElementById('im53');
			images5[2].style.visibility='hidden';		
		};

	img=document.getElementById('im61');
	if (img!=null)
		{
			images6[0] = document.getElementById('im61'); 
		};	
	img=document.getElementById('im62');
	if (img!=null)
		{
			images6[1] = document.getElementById('im62');
			images6[1].style.visibility='hidden';		
 
		};	
	
	img=document.getElementById('im63');
	if (img!=null)
		{
			images6[2] = document.getElementById('im63');
			images6[2].style.visibility='hidden';		
 
		};

	img=document.getElementById('im71');
	if (img!=null)
		{
			images7[0] = document.getElementById('im71'); 
		};	
	img=document.getElementById('im72');
	if (img!=null)
		{
			images7[1] = document.getElementById('im72');
			images7[1].style.visibility='hidden';		
		};	
	
	img=document.getElementById('im73');
	if (img!=null)
		{
			images7[2] = document.getElementById('im73');
			images7[2].style.visibility='hidden';		
		};

	img=document.getElementById('im81');
	if (img!=null)
		{
			images8[0] = document.getElementById('im81'); 
		};	
	img=document.getElementById('im82');
	if (img!=null)
		{
			images8[1] = document.getElementById('im82');
			images8[1].style.visibility='hidden';		
		};	
	
	img=document.getElementById('im83');
	if (img!=null)
		{
			images8[2] = document.getElementById('im83');
			images8[2].style.visibility='hidden';			
 
		};

	img=document.getElementById('im91');
	if (img!=null)
		{
			images9[0] = document.getElementById('im91'); 
		};	
	img=document.getElementById('im92');
	if (img!=null)
		{
			images9[1] = document.getElementById('im92');
			images9[1].style.visibility='hidden';		
 
		};	
	
	img=document.getElementById('im93');
	if (img!=null)
		{
			images9[2] = document.getElementById('im93');
			images9[2].style.visibility='hidden';		
		};

	};

	var interval;  


	
	// Show next slide
	var show = function() {
			if (images1.length > 0) {			 
				images1[curInd1].style.visibility='hidden'; 
				images1[curInd1 = curInd1 < images1.length - 1 ? curInd1+1 : 0].style.visibility='visible';
			};
			if (images5.length > 0) {			 
				images5[curInd5].style.visibility='hidden'; 
				images5[curInd5 = curInd5 < images5.length - 1 ? curInd5+1 : 0].style.visibility='visible';
			};

			if (images9.length > 0) {			 
				images9[curInd9].style.visibility='hidden'; 
				images9[curInd9 = curInd9 < images9.length - 1 ? curInd9+1 : 0].style.visibility='visible';
			};

				if (images2.length > 0) {			 
					images2[curInd2].style.visibility='hidden'; 
					images2[curInd2 = curInd2 < images2.length - 1 ? curInd2+1 : 0].style.visibility='visible';
				};
				if (images6.length > 0) {			 
					images6[curInd6].style.visibility='hidden'; 
					images6[curInd6 = curInd6 < images6.length - 1 ? curInd6+1 : 0].style.visibility='visible';
				};

				if (images7.length > 0) {			 
					images7[curInd7].style.visibility='hidden'; 
					images7[curInd7 = curInd7 < images7.length - 1 ? curInd7+1 : 0].style.visibility='visible';
				};

				if (images4.length > 0) {			 
					images4[curInd4].style.visibility='hidden'; 
					images4[curInd4 = curInd4 < images4.length - 1 ? curInd4+1 : 0].style.visibility='visible';
				};
				if (images8.length > 0) {			 
					images8[curInd8].style.visibility='hidden'; 
					images8[curInd8 = curInd8 < images8.length - 1 ? curInd8+1 : 0].style.visibility='visible';
				};
				if (images3.length > 0) {			 
					images3[curInd3].style.visibility='hidden'; 
					images3[curInd3 = curInd3 < images3.length - 1 ? curInd3+1 : 0].style.visibility='visible';
				};
	
	};










		interval = show.periodical(Dur); 		
	});




