
var current_radio = 0;

function loading( dest_div )
{
	var _loading = '<img src="/img/loading.gif" border="0">';
	$(dest_div).innerHTML = _loading;
}

function check_radio(id)
{
	if (current_radio!=id && current_radio){
		var box_id='t'+current_radio;
		var frm_id='r'+current_radio;
		var b=document.getElementById(box_id);
		b.style.background='#FFFFFF';
	}
	current_radio=id;
	var box_id='t'+current_radio;
	var frm_id='r'+current_radio;
	var f=document.getElementById(frm_id).value;
	var b=document.getElementById(box_id);
	b.style.background='#FFDFBD';
	//document.getElementById(id).value=el;
}

function form_colorize(id)
{
	var box_id='t'+id;
	var b=document.getElementById(box_id);
	b.style.background='#FFDFBD';
	current_radio=id;
}

function dropCart(url)
{
	if ( confirm('Opravdu chcete košík vysypat?') ){
		pageRedir( url );
	}
}

function ifConfirm(url, str)
{
	if ( confirm('Opravdu '+str+'?') ){
		pageRedir( url );
	}
}

function check_if_show_address(div, is_delivery)
{
	//var el = document.getElementById(div);
	var it = document.getElementById( is_delivery );
	if (!it.checked){
		//divShow(div);
		new Effect.SlideDown( $(div) , { duration: 0.3 } );
	} else {
		//divHide(div);
		new Effect.SlideUp( $(div), { duration: 0.4 } );
	}
}

function changeImage(path, title)
{
        var pic = document.getElementById('changer');
	
	var view  = '/view.php?image='+path;

	//var zoom = '<a href="'+view+'" title=""><img src="/img/ico_zoom.gif" alt="Zoom" rel="lightbox[him]" border="0">plus</a>';

	var str = '<a class="navibtn" title="'+title+'" href="'+view+'" rel="lightbox[him]"><img src="/resample.php?w=300&image='+path+'" alt="'+title+'"  border="0"/></a>';
  //      var str = '<img src="/resample.php?w=300&h=400&image='+path+'" border="0" align="middle" alt="'+title+'" />';
        pic.innerHTML = str;
}

function update_icodic(check_field)
{

	var it = document.getElementById( check_field );
	
	if (it.checked){
		new Effect.SlideDown( $('klient_ico') , { duration: 0.3 } );
		new Effect.Highlight( $('klient_ico') , { duration: 1 } );
		new Effect.SlideDown( $('klient_dic') , { duration: 0.3 } );
		new Effect.Highlight( $('klient_dic') , { duration: 1 } );
	} else {
		new Effect.Fade( $('klient_ico') , { duration: 0.3 } );
		new Effect.Fade( $('klient_dic') , { duration: 0.3 } );
	}
}

function update_other_email()
{
	var el = document.getElementById('klientUsermail');
	var it = document.getElementById('klientEmail');
	it.value = el.value;
}


function show_hlt( smenu, menu)
{
	divShow(smenu);
	hlt(menu);
	set_distance(smenu, menu);

}

function hide_unhlt(smenu, menu, layout)
{
	divHide(smenu);
	if (layout=="GOLFSKI"){
		unhlt(menu);
	} else {
		unhlt_skopovy(menu);
	}
}


function open_mailto(path)
{
	var id = 'intercomm';
	//var _sub = document.getElementById(id);
	//_sub.style.width = '400px';
	//_sub.style.height = '600px';
	//_sub.style.display = 'block';
	//divShow(id);
	//alert(_sub);
	//new Effect.Appear( $(id) );
	//divShow('cBox');
	//divShow(id);
	new Ajax.Updater( id, '/gates/mailem?path='+path, { 'evalScripts': true });
	new Effect.Appear( $(id) );
}


var _item = null;

function open_question(item)
{
	var id = 'intercomm1';
	_item = item;
	new Ajax.Updater( id, '/gates/question?item='+item, { 'evalScripts': true });
	new Effect.Appear( $(id) );
}

function loader( div )
{
	var out = '<img src="/img/khaki/loading-spinner.gif" border="0" align="middle" hspace="10"/> pracuji, čekejte prosím... ';
	$(div).innerHTML = out;
}

function hideIntercomm()
{
	new Effect.Fade( $('intercomm') );
}

function hideIntercomm1()
{
	new Effect.Fade( $('intercomm1') );
	var id = 'questions-list';
	//alert(_item);
	new Ajax.Updater( id, '/gates/questions/' + _item, { 'evalScripts': true } );

}


function set_distance(smenu, menu)
{
	var _sub = document.getElementById(smenu);
	var _m = document.getElementById(menu);
	_sub.style.left = (_m.offsetLeft-10)+'px';
	//alert(_sub.offsetLeft);
}

function hlt(id)
{
	var el = document.getElementById(id);
	if (el){
		el.style.background = 'white';
		el.style.color='black';
		//el.style.border='1px solid white';
		//alert(el.offsetWidth + ' | ' + el.offsetLeft);
	}
}

function unhlt(id)
{
	var el = document.getElementById(id);
	if (el){
		el.style.background = '';
		el.style.color='white';
		//el.style.border='0';

	}
}

function unhlt_skopovy(id)
{
	var el = document.getElementById(id);
	if (el){
		el.style.background = '';
		el.style.color='black';
		//el.style.border='0';

	}
}




function show_hlt2( smenu, menu)
{
	divShow(smenu);
	//hlt2(menu);
	set_distance(smenu, menu);

}

function hide_unhlt2(smenu, menu)
{
	divHide(smenu);
	//unhlt2(menu);
}



function hlt2(id) // petrskopovy
{
	var el = document.getElementById(id);
	if (el){
		el.style.backgroundImage = "url('../img/petrskopovy/menu_sel_hover.png')";
		el.style.backgroundPosition ="left center";
		el.style.backgroundRepeat = "no-repeat";
		el.style.color='black';
		//el.style.border='1px solid white';
		//alert(el.offsetWidth + ' | ' + el.offsetLeft);
	}
}

function unhlt2(id)
{
	var el = document.getElementById(id);
	if (el){
		el.style.background = '';
		el.style.color='black';
		//el.style.border='0';
	}
}


function inputWin(text)
{
	var answer = prompt(text);
	return answer;
}

function checkAddr(id, id2)
{
	alert(id + id2);
	if (document.id.checked){
		divHide(id2);
	} else {
		divShow(id2);
	}
}

function divHide(id)
{
	var mid=document.getElementById(id);
	new Effect.Fade( $(id), { duration: 0.2 } );
	//mid.style.visibility='hidden';
	//mid.style.display='none';
}

function divShow(id)
{
	var mid=document.getElementById(id);
	//alert(id + ' - ' + mid);
	//alert(mid.innerHTML);
	mid.style.visibility='visible';
	//mid.style.display='block';
	new Effect.Appear( $(id), { duration: 0.5 } );
}

function pageRedir(id){
	document.location.replace( id );
}

function OpenWin(adresa,jake,nastaveni)
{
	msg=open(adresa,jake,nastaveni);
}

function OpenWinEdit(url, file)
{
	msg=OpenWin(url + '&fsrc='+file, 'WinEdit', 'toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,top=50,left=120,width=950,height=650');
}

function OpenWinImg(url, width, height)
{
	//window.imgdetail.close();
	msg=OpenWin(url, 'imgdetail', 'toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,top=150,left=100,width='+width+',height='+height);
}





function fAddInput(tableName, text4Input) 
{		// pridej do tabuky radek s inputem
	var oTable= document.getElementById(tableName);
	var vNewRow = oTable.insertRow(oTable.rows.length);
	var vFileCell1= vNewRow.insertCell(0);
	var vFileCell2= vNewRow.insertCell(1);
	var vFileCell3= vNewRow.insertCell(2);
	vFileCell1.innerHTML= '<input type="text" name="data[NewVoteAnswer][][sort_order]" value="" size="2" />';
	vFileCell2.innerHTML= '<input type="text" name="data[NewVoteAnswer][][answer]" value="'+text4Input+'" size="90" />';
	vFileCell3.innerHTML= '<input type="button" id="'+eval(oTable.rows.length-1)+'" class="btSmall" onClick="fDelInput(\''+tableName+'\', this)" value="Smazat" />';
}

function fDelInput(tableName, oInput)
{ 	// smazni drive pridany radek inputu , ktery jeste neni v DB
	var oTable= document.getElementById(tableName);
	oTable.deleteRow(oInput.id);
}

function _gel(id)
{
	var e = document.getElementById(id);
	return e;
}

function adjust_inc(id)
{
	var f = _gel(id);
	var l = f.value;
	l++;
	if (l>50){
		l=50;
	}
	f.value=l;
}


function adjust_dec(id)
{
	var f = _gel(id);
	var l = f.value;
	l--;
	if (l<=0){
		l=1;
	}
	f.value=l;
}
