var GLOBAL_LABELS_PORTAL = new Array();
	GLOBAL_LABELS_PORTAL['PL'] = new Array();
	GLOBAL_LABELS_PORTAL['PL']['flats'] = 'Mieszkania i domy';
	GLOBAL_LABELS_PORTAL['PL']['offices'] = 'Biura i lokale użytkowe';
	GLOBAL_LABELS_PORTAL['PL']['contact_data'] = 'Dane kontaktowe';	
	GLOBAL_LABELS_PORTAL['PL']['contact_header'] = 'Kontakt';	
	GLOBAL_LABELS_PORTAL['PL']['contact_form'] = 'Formularz kontaktowy';	
	GLOBAL_LABELS_PORTAL['PL']['contact_map'] = 'Mapa dojazdu';	
	GLOBAL_LABELS_PORTAL['PL']['mandatComm'] = '<sup>*</sup> Pole wymagane</span>';
	GLOBAL_LABELS_PORTAL['PL']['email'] = '* Adres e-mail:';
	GLOBAL_LABELS_PORTAL['PL']['phone'] = 'Telefon:';
	GLOBAL_LABELS_PORTAL['PL']['companyname'] = '* Imię i nazwisko / firma';
	GLOBAL_LABELS_PORTAL['PL']['message'] = '* Treść wiadomości';
	GLOBAL_LABELS_PORTAL['PL']['faq_info'] = 'Jeśli mają Państwo jakiekolwiek pytania, wątpliwości lub uwagi, prosimy o ich przekaznie za pomocą poniższego formularza.';

	
	GLOBAL_LABELS_PORTAL['EN'] = new Array();
	GLOBAL_LABELS_PORTAL['EN']['flats'] = 'Flats and houses';
	GLOBAL_LABELS_PORTAL['EN']['offices'] = 'Offices and business establishments';
	GLOBAL_LABELS_PORTAL['EN']['contact_data'] = 'Contact details';	
	GLOBAL_LABELS_PORTAL['EN']['contact_header'] = 'Contact';	
	GLOBAL_LABELS_PORTAL['EN']['contact_form'] = 'Contact form';	
	GLOBAL_LABELS_PORTAL['EN']['contact_map'] = 'Map';	
	GLOBAL_LABELS_PORTAL['EN']['mandatComm'] = '<sup>*</sup> Required fields</span>';
	GLOBAL_LABELS_PORTAL['EN']['email'] = '* E-mail address:';
	GLOBAL_LABELS_PORTAL['EN']['phone'] = 'Telephone:';
	GLOBAL_LABELS_PORTAL['EN']['companyname'] = '* Name and surname/the name of the company:';
	GLOBAL_LABELS_PORTAL['EN']['message'] = '* Message';
	GLOBAL_LABELS_PORTAL['EN']['faq_info'] = 'If you have any questions, doubts or comments, please contact us via this form.';
	
	

	
var notnullTips = new Array();
	notnullTips['PL'] = new Array(); 
	notnullTips['PL'][0] = '-- wpisz ulicę --';
	notnullTips['PL'][1] = '-- wpisz numer --';
	notnullTips['PL'][2] = '-- wpisz wartość --';
	notnullTips['PL'][3] = '-- wpisz --';
	notnullTips['PL'][4] =  '-- wpisz poprawny adres --';

	notnullTips['EN'] = new Array(); 
	notnullTips['EN'][0] = '-- wpisz ulicę --';
	notnullTips['EN'][1] = '-- wpisz numer --';
	notnullTips['EN'][2] = '-- wpisz wartość --';
	notnullTips['EN'][3] = '-- fill in --';
	notnullTips['EN'][4] =  '-- fill in correct address --';



function FillBanner(id,data){
	document.getElementById(id).style.display = 'block';
	document.getElementById(id).innerHTML = data;
};

function SetTopMenuHandlers(objID){
	var langPrefix = "";
	if(LANG == 'EN'){
		langPrefix = "_EN";
	}

	if(objID=="" || objID==2 || objID==0 || objID==1 || objID==270 || objID==110){
			var btn = document.getElementById("button-menu_01");
			btn.className = 'activeBtn_110'+langPrefix;
	}else{
	btns = ["button-menu_01","button-menu_02","button-menu_03","button-menu_04","button-menu_05"];	
	ids = ["110","120","130","140","150"];
	
	for(var j in ids){
		if(objID==ids[j]){
			var btn = document.getElementById(btns[j]);
			btn.className = 'activeBtn_'+objID+langPrefix;
		};
	};	
	
	};



};

function ActiveClass(obj){
	var frmElms = new Array();
	frmElms = ["button-menu_01","button-menu_02","button-menu_03","button-menu_04","button-menu_05"];	
	
	obj.className = 'activeBtn';
	alert(obj.className);
};
	function getFrameByName(name){
	  for (var i = 0; i < frames.length; i++)
	    if (frames[i].name == name)
	      return frames[i];
	 
	  return null;
	}

function setChanged(){

};
		
function ClearClass(obj,mode,param,paramOff){

	switch(mode){
		case "textarea":
			var parent = obj.parentNode;
			var rootID = parent.id;
//			alert('obj.value ' +obj.value);
		
				obj.innerHTML = '';
				obj.setAttribute('value','');
				obj.onfocus=null;
/*
			var alertLayer = document.getElementById(rootID+'_alert'); 

			if(obj.value=="" || obj.value==notnullTips[parseInt(param)]){
				obj.value = notnullTips[parseInt(param)];
				alertLayer.style.display = 'block'; 
				parent.style.display = 'none';
			};
*/			
		break;
		case "blur_input":
		 //	var emptyVal = "-- wpisz --";
			if(obj.value==""){
		 		obj.value = notnullTips[LANG][parseInt(param)];
			};
		break;
		case "input":
			var emptyVal = "";
			obj.value = emptyVal;

		break;
		case "hover_input":
			var parent = obj.parentNode;
			var rootID = parent.id;
			var alertLayer = document.getElementById(rootID+'_alert'); 

			if(obj.value=="" || obj.value==notnullTips[LANG][parseInt(param)]){
				obj.value = notnullTips[LANG][parseInt(param)];
				alertLayer.style.display = 'block'; 
				parent.style.display = 'none';
			};
		break;
		case "mail_on":
			obj.className='';
			if(obj.value==notnullTips[LANG][parseInt(param)] || obj.value==notnullTips[LANG][parseInt(paramOff)]){
				obj.value="";
			};

		break;
		case "mail_off":
			if(obj.value==""){
				obj.className = 'step_input empty';

				obj.value=notnullTips[LANG][parseInt(param)];
			}else{
				if(!Validate_Email(obj.value)){
					obj.className = 'step_input empty';
					obj.value=notnullTips[LANG][parseInt(paramOff)];
				};
			};
		break;		
		case "name_off":
			if(obj.value==""){
				obj.className = 'step_input empty';
				obj.value=notnullTips[LANG][parseInt(param)];
			};
		break;		
		case "phone_off":
			if(in_array(obj.value,notnullTips)){
			
			}else{
			if(obj.value==""){
//				obj.className = 'step_input empty';

				obj.value=notnullTips[LANG][parseInt(param)];
			}else{
				if(!isPhoneNumber(obj.value)){
					obj.className = 'step_input empty';
					obj.value=notnullTips[LANG][parseInt(param)];
				};
			};
			
			};
		break;		
		case "area_on":
			//obj.className='';
			if(obj.value==notnullTips[LANG][parseInt(param)]){
				obj.innerHTML="";
			};
		break;
		case "area_off":
			if(obj.value=="" || obj.value==notnullTips[LANG][parseInt(param)]){
				obj.className = 'textarea_' + LANG + '_empty';
				obj.innerHTML=notnullTips[LANG][parseInt(param)];
			};
		break;


	};
	
};
function Validate_Email(address){
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(address) == false) {
      return false;
   }else{
   	return true;
   }

};
function InitFormContact(mode){
	switch(mode){
		case 'contact':
			var emailInp = document.getElementById('element_0');
			var nameInp = document.getElementById('element_1');
			var phoneInp = document.getElementById('element_2');
			var bodyInp = document.getElementById('element_3');

			emailInp.value = notnullTips[LANG][3];
			nameInp.value = notnullTips[LANG][3];
			phoneInp.value = notnullTips[LANG][3];
			
			emailInp.setAttribute('onClick','ClearClass(this,\'mail_on\',3,4)');
			emailInp.setAttribute('onFocus','ClearClass(this,\'mail_on\',3,4)');
			emailInp.setAttribute('onBlur','ClearClass(this,\'mail_off\',3,4)');
	
			nameInp.setAttribute('onClick','ClearClass(this,\'mail_on\',3)');
			nameInp.setAttribute('onFocus','ClearClass(this,\'mail_on\',3)');
			nameInp.setAttribute('onBlur','ClearClass(this,\'name_off\',3)');

			phoneInp.setAttribute('onClick','ClearClass(this,\'mail_on\',3)');
			phoneInp.setAttribute('onFocus','ClearClass(this,\'mail_on\',3)');
			phoneInp.setAttribute('onBlur','ClearClass(this,\'phone_off\',3)');

			bodyInp.setAttribute('onClick','ClearClass(this,\'area_on\',3)');
			bodyInp.setAttribute('onFocus','ClearClass(this,\'area_on\',3)');
			bodyInp.setAttribute('onBlur','ClearClass(this,\'area_off\',3)');
			
			bodyInp.innerHTML = notnullTips[LANG][3];
		break;
		case 'faq':
			var emailInp = document.getElementById('faq_input');
			var bodyInp = document.getElementById('faq_msg');
			
			emailInp.setAttribute('onClick','ClearClass(this,\'mail_on\',3,4)');
			emailInp.setAttribute('onFocus','ClearClass(this,\'mail_on\',3,4)');
			emailInp.setAttribute('onBlur','ClearClass(this,\'mail_off\',3,4)');

			bodyInp.setAttribute('onClick','ClearClass(this,\'area_on\',3)');
			bodyInp.setAttribute('onFocus','ClearClass(this,\'area_on\',3)');
			bodyInp.setAttribute('onBlur','ClearClass(this,\'area_off\',3)');
			bodyInp.innerHTML = notnullTips[LANG][3];
			
		break;

	};
	
	
};


function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}




function successSend(msg,mode){
				document.getElementById('form_mask').className = 'form_mask hide_this';
				document.getElementById('form_elements').className = 'contact_elements hide_this';
				document.getElementById('form_info').innerHTML = msg;
				document.getElementById('form_info').className = 'show_this';
				document.getElementById('form_btn').className = 'hide_this';
				document.getElementById('form_foot').className = 'hide_this';
			
				InitializeTimer('contact');
};

function successSendFaq(msg){
				document.getElementById('faq_mask').className = 'form_mask hide_this';
				document.getElementById('faq_elements').className = 'contact_elements hide_this';
				document.getElementById('faq_info').innerHTML = msg;
				document.getElementById('faq_info').className = 'show_this';
				
				document.getElementById('faq_btn').className = 'hide_this';
				document.getElementById('faq_foot').className = 'hide_this';
					InitializeTimer('faq');
};
 

var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;

function InitializeTimer(mode) {
    // Set the length of the timer, in seconds
    secs = 3;
    StopTheClock();
    StartTheTimer2(mode);
}

function StopTheClock() {
    if (timerRunning) clearTimeout(timerID);
    timerRunning = false;
}

function StartTheTimer2(mode) {
    secs = secs - 1;

    if (secs <= 0) {
        StopTheClock();
        if(mode=='contact'){

				document.contact_form.reset();
				InitFormContact(mode);
				document.getElementById('form_elements').className = 'contact_elements show_this';
				document.getElementById('form_info').className = 'hide_this';
				document.getElementById('form_btn').className = 'show_this';
				document.getElementById('form_foot').className = 'show_this';
        		
        
        
        
        };
        if(mode=='faq'){
				document.faq_form.reset();
				InitFormContact(mode);
				document.getElementById('faq_elements').className = 'contact_elements show_this';
				document.getElementById('faq_info').className = 'hide_this';
				document.getElementById('faq_btn').className = 'show_this';
				document.getElementById('faq_foot').className = 'show_this';
        };

        /*window.location.href='view_data.php?view_name=cms.view&o=1';*/

    } else {

        var sec = secs % 60;
        var min = (secs - sec) / 60;
        if (sec < 10) sec = '0' + sec;

        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer2('"+mode+"')", delay);
    }
}



function SendMessage(mode,path){
	var frmElms = new Array();
	var err = 0;
		if(mode=='contact'){
			frmElms = ["element_0","element_1","element_3"]	
		};

		if(mode=='faq'){
			frmElms = ["faq_input","faq_msg"]	
		};
	
	for(i in frmElms){
		var inp = document.getElementById(frmElms[i]);
		if(inp.className == 'step_input empty'){
			err = err+1;
		};
		if(in_array(inp.value,notnullTips[LANG])){
			inp.className = 'step_input empty'; 
			err = err+1;
		};
		
	};
	if(err>0){
		return false;
	}else{
		if(mode=='contact'){
	
				document.getElementById('form_mask').className = 'form_mask show_this';

				var emailInp = document.getElementById('element_0');
				var nameInp = document.getElementById('element_1');
				var phoneInp = document.getElementById('element_2');
				var bodyInp = document.getElementById('element_3');
				var dataStr = "uMail="+emailInp.value+"&uName="+nameInp.value+"&uPhone="+phoneInp.value+"&uBody="+bodyInp.value;
				var url = "../php/mail.php";
         $.ajax({  
               type: "POST",  
               url: url,  
               data: dataStr,
               success: successSend
  				});

		};
		if(mode=='faq'){
				document.getElementById('faq_mask').className = 'form_mask show_this';
				var emailInp = document.getElementById('faq_input');
				var bodyInp = document.getElementById('faq_msg');
				var dataStr = "uMail="+emailInp.value+"&uBody="+bodyInp.value;
				var url = "../php/faq_mail.php";
         $.ajax({  
               type: "POST",  
               url: url,  
               data: dataStr,
               success: successSendFaq
  				});

		};
		
		
	};
	
};

function isPhoneNumber(s) 
{
     // Check for correct phone number
     rePhoneNumber = new RegExp(/^[0-9\(\)\+\- ]+$/);

     if (!rePhoneNumber.test(s)) {
          return false;
     }

return true;
}


function SwitchLayers(object){

			var rootID = object.id.split("_")[0];
			var alertLayer = document.getElementById(rootID+'_alert'); 
			var inputLayer = document.getElementById(rootID); 
				alertLayer.style.display = 'none'; 
				inputLayer.style.display = 'block'; 

};		
function ResetStreet(objID){
	var cValue = objID.options[objID.selectedIndex].value;
	var inputs = document.forms['pricingForm'].elements['known_street'];

	if(in_array(cValue,cityPrecincts)){
			for (i=0;i<inputs.length;i++) {
				inputs[i].disabled=true;
			};
	}else{
			for (i=0;i<inputs.length;i++) {
				inputs[i].disabled=false;
			};
	};	
};
		
		
		
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function in_array (needle, haystack, argStrict) {
    var key = '', strict = !!argStrict;
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }
 
    return false;
};




function	LoadObjects(){



};














































function SwitchTab(tabID,leftLink,rightLink){
	var tArray = new Array();
	tArray[0] = '01';
	tArray[1] = '02';	
	var tLinks = new Array();
	tLinks[0] = leftLink;
	tLinks[1] = rightLink;	
	
	
	for(var i in tArray){
		if(tArray[i]==tabID){
			var tTab = document.getElementById('tab_'+tabID);
			var tBody = document.getElementById('tabbody_'+tabID);
				tTab.className = 'tab_'+tabID+' on_'+tabID+'_'+LANG;
				tBody.innerHTML = '<iframe src='+tLinks[i]+' width="970" height="100%" frameborder="0" scrolling="no" class="price_frame" id="price_frame" name="price_frame"></iframe>';
				tBody.style.display = 'block';
				document.getElementById('tab_'+tabID+'_trace').className = 'show_inl';
		}else{
			var tTab = document.getElementById('tab_'+tArray[i]);
			var tBody = document.getElementById('tabbody_'+tArray[i]);
				tTab.className = 'tab_'+tArray[i]+' off_'+tArray[i]+'_'+LANG;
				tBody.innerHTML = '&nbsp;'
				tBody.style.display = 'none';
				document.getElementById('tab_'+tArray[i]+'_trace').className = 'hide_this';
		
		};
	};
};
function doRequest(){
	var page = $.ajax({url: "../php/mail.php", 
					   type: "GET",
					   success: function(html){
							$("#my_div").append(html)
							}
					  });
					  
};

function ValidForm(type){

	switch(type){
		case "contact_form":
			var Elements = new Array();
			Elements[0] = 'tEmInput';
			Elements[1] = 'tNamInput';
			Elements[2] = 'tPhInput';
			Elements[3] = 'tConInput';



		break;
	
	};

	return true;
}


function CloseAdv(obj){
	var advBox = obj.parentNode;
	advBox.className = advBox.className + ' hide_this'; 
};

