//**********************************************************************//
// Global Function for Show & UnShow object
//**********************************************************************//

var bshow=true;
var bshowes=1;

/*objGet('showextendsearchbox').value = GetbShowes();*/

function SetUnderline(element)
{	
	document.getElementById('searchdate0').className='normal';
	document.getElementById('searchdate1').className='normal';
	document.getElementById('searchdate2').className='normal';
	document.getElementById('searchdate3').className='normal';
	document.getElementById('searchdate4').className='normal';
	document.getElementById('searchdate5').className='normal';

	document.getElementById(element).className="darkblue_underline";
}

function SetbShowes(bshowesa)
{
	bshowes = bshowesa;
}

function GetbShowes()
{
	return bshowes;
}


function objShow (obj,on) 
{
	return objSetStyle(obj,'visibility',(on) ? 'visible':'hidden');
}
function objSetStyle (obj,prop,val) 
{
	var o = objGet(obj);
	if (o && o.style) {
		eval ('o.style.'+prop+'="'+val+'"');
		return true;
		}
	else return false;	
}
function objGet(x) 
{
	if (typeof x != 'string') return x;
	else if (Boolean(document.getElementById)) return document.getElementById(x);
	else if (Boolean(document.all)) return eval('document.all.'+x);
	else return null;
}
function objDisplay (obj,on,type) {
	if (on && !type) type = 'block';
	return objSetStyle(obj,'display',(on) ? type:'none');
	}

function ShowUnShow () {

if(bshow == true)
	{
	objDisplay('nabidkytydne',true,'block')
	bshow = false;
	}
	else
	{
	objDisplay('nabidkytydne',false,'block')
	bshow = true;
	}

	
}

function ShowUnShowExtendSearch () {
 

/*alert(bshowes == 1)*/
/*alert(bshowes);*/


if(bshowes == 1)
	{
	objDisplay('extendsearchbox',true,'block')
	
	objGet('linkextendsearchbox').className = 'bold';
	objGet('showextendsearchbox').value = 1;
/*	alert(objGet('showextendsearchbox').value);*/
	objShow ('searchgoogle1',false);
	objShow ('searchgoogle2',false);
/*	alert(objGet('searchtype').value);*/
	objGet('searchtype1').checked = true;
	objGet('searchtype2').checked = false;
	bshowes = 0;
	}
	else
	{
	objDisplay('extendsearchbox',false,'block')
	bshowes = 1;
/*	document.GetElementById('linkextendsearchbox').className = 'bold';*/
	objGet('linkextendsearchbox').className = 'normal';
	objGet('showextendsearchbox').value = 0;
	objShow ('searchgoogle1',true);
	objShow ('searchgoogle2',true);

	}

	
}

function SetShowUnShowExtendSearch ()
{
/*	alert(objGet('showextendsearchbox').value);*/

	if(objGet('showextendsearchbox').value == 1) 
		{
		objDisplay('extendsearchbox',true,'block')
		bshowes = false;
		objGet('linkextendsearchbox').className = 'bold';
		objGet('showextendsearchbox').value = 1;
		objShow ('searchgoogle1',false);
		objShow ('searchgoogle2',false);
		objGet('searchtype1').checked = true;
		objGet('searchtype2').checked = false;
		}
		else
		{
		objDisplay('extendsearchbox',false,'block')
		bshowes = true;
		objGet('linkextendsearchbox').className = 'normal';
		objGet('showextendsearchbox').value = 0;
		objShow ('searchgoogle1',true);
		objShow ('searchgoogle2',true);
		}

}

//**********************************************************************//



/*
 * Převrácení mailu
 */
function mailReverse(str) {
	if (str.substr(0, 7) != 'mailto:') return str;
	var res = 'mailto:';
	for(var i=1; i<=str.length-7;i++) res+=str.charAt(str.length-i);
	return res;
}

function moveSelectItems(from, to, max) {
	if (max != 0 && to.length >= max)
		return;
	
	for (var i = 0; i < from.length; i++) {
		if (from.options[i].selected == true) {
			appendSelectItem(to, from.options[i].value, from.options[i].text);
			from.options[i].selected = false;
			from.options[i] = null;
			break;
		}
	}
}

function appendSelectItem(select, itemID, itemName) {
	select.options[select.length] = new Option(itemName, itemID);
} 


/**
 * Formulař 
 */ 
function checkBox(type) {
    if(type == 'sk') {
        $('tarif_sk').checked = true;
    }
}

/**
 * input text value
 * CLASS name 'not-active' deactivate this function
 */
window.addEvent('domready', function() {
	var elInputText = $$('input.tip')	
	var arrDefVal = new Array();
	var arrDefId = new Array();
	elInputText.each(function(e){
		arrDefVal.push(e.getValue());
		arrDefId.push(e.getProperty('id')); 
	});	
	elInputText.addEvents({
		'focus': function(){
			this.addClass('focus');
			this.removeClass('tip');
			if(this.value == arrDefVal[arrDefId.indexOf(this.id)]){
				this.value = '';				
			}
		},
		'blur': function(){
			this.removeClass('focus');			
			if(this.value == ''){
				this.addClass('tip');
				this.value = arrDefVal[arrDefId.indexOf(this.id)];				
			}
		}
	});	
	elInputText.getParent('form').addEvent('submit', function(){
		elInputText.each(function(e){
			if(e.value == arrDefVal[arrDefId.indexOf(e.id)]){
				e.value = '';    				
			}
		});
	});
});