Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif';// reference local blank image

function locationWindow(trig){ // change location window
	if (!Ext.getCmp('setLocationWin')){
		countyStore=new Ext.data.Store({ url:'requests/counties.php', autoLoad:true, baseParams:{ lang: Ext.get('set_location_lang').dom.value },
			reader: new Ext.data.XmlReader({ record:'item' }, ['id','name', 'selected' ]),
			listeners: { load:function(){try {Ext.getCmp('weatherCounty').setValue(countyStore.find('selected','true')+1)}catch(e){}}}
		}); 

		var params=(location.search?location.search+'&':'?');
		new Ext.Window({ id:'setLocationWin', title:Ext.get('set_location_title').dom.value, modal:true, width:200, height:110, closeAction:'hide', 
			plain: true, resizable:false, buttonAlign:'center', bodyStyle:'padding:10px 0 0 20px',
			items: new Ext.form.ComboBox({ id:'weatherCounty', triggerAction: 'all', mode: 'local', editable:false, width:150, store: countyStore, displayField:'name', valueField:'id' }),
			buttons: [ {text:'OK', handler: function(){ Ext.getCmp('setLocationWin').hide(); top.location.href=params+'countyid='+Ext.getCmp('weatherCounty').getValue(); }}]
		});
	}
	Ext.getCmp('setLocationWin').show(trig);
}




function idToggle(id){
	var el=document.getElementById(id);
	if (el.style.display=='none')el.style.display='';
	else el.style.display='none';
}

function combox_toggle(i){ var cbx=document.getElementById('commbox'+i); cbx.style.display=(cbx.style.display=='none'?'':'none'); }

function error_clear(el){ err=document.getElementById(el).innerHTML='&nbsp;'; }

function inputFocus(){
	var inps=document.getElementsByTagName('input');
	for (i=0; i<inps.length; i++)
		if (inps[i].type=='text' || inps[i].type=='password'){
			try{ inps[i].focus(); } catch(e){}
			break; 
		}
}


function manage_locations(id){
	var w=800; var h=600;
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2-100 : 0;
	var settings ='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,  resizable=no, height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',screenX='+LeftPosition+',screenY='+TopPosition;
	window.open('requests/locations.php','locations',settings);
}

function chart_window(href){
	var w=500; var h=700;
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2-100 : 0;
	var settings ='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,  resizable=no, height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',screenX='+LeftPosition+',screenY='+TopPosition;
	window.open(href,'rules',settings);
	return false;
}

function commentform(id){
	document.getElementById('link_'+id).style.display='none';
	form=document.getElementById('form_'+id).style.display='block';
}


// LOCATIONS **************************************
function show_on_map(id,x,y){	document.getElementById('map').src='inc/gmap_small.php?empty=true&x='+x+'&y='+y; }
function location_seek(){ 
//	document.getElementById('map').src='inc/gmap_small.php?loc='+document.getElementById('location').value; 
	document.getElementById('loc_name').value=document.getElementById('location').value;
	document.getElementById('add_form').style.display="block"
}
// ************************************************

function divhov(co,jak){ // chyba juz nie potrzebne
	if (jak){
		co.style.backgroundColor='#E8F9C3'
		co.style.borderTop="2px solid #ccc"; 
		co.style.borderLeft="2px solid #ccc"; 

		co.style.borderRight="2px solid #666"; 
		co.style.borderBottom="2px solid #666"; 
	}
	else{
		co.style.backgroundColor='#FFF'
		co.style.border="2px solid #FFF"; 
	}
}

function tr_hov(tr,bg){ 
	var tr=document.getElementById(tr);	
	tr.style.backgroundColor=bg;
}


function hidecombo(){ var sc=document.getElementById('school_combo').style.display='none'; }
function school_combo(show){
	var sc=document.getElementById('school_combo'); 
	if (show && sc.innerHTML.length>0) school_lookup();
	else setTimeout("hidecombo()",200);
}

function pass_check(){
	var p1=document.getElementById('pass');
	var p2=document.getElementById('pass2');
	var out1=document.getElementById('pass1_res');
	var out2=document.getElementById('pass2_res');
	if (p1.value.length>2){
		if (p1.value==p2.value)
			out2.innerHTML='<img src="img/ok.png" alt="Password accepted"  onmouseover="return overlib(\'Password accepted\',FGCOLOR, \'#006BD7\', TEXTCOLOR, \'#FFF\');" onmouseout="return nd();"/>'; 
		else out2.innerHTML='<img src="img/nok.png" alt="Password do not match" onmouseover="return overlib(\'Password does not match\');" onmouseout="return nd();"/>';
		out1.innerHTML=''; 
	}
	else {
		out1.innerHTML='<img src="img/nok.png" alt="Enter your password" onmouseover="return overlib(\'Enter your password\');" onmouseout="return nd();"/>';
		out2.innerHTML=''; 
	}
	nd(); // hide tooltip
}

function pass_check2(){
	var p1=document.getElementById('pass1');
	var p2=document.getElementById('pass2');
	var out1=document.getElementById('pass1_res');
	var out2=document.getElementById('pass2_res');
	if (p1.value.length>2){
		if (p1.value==p2.value)
			out2.innerHTML='<img src="img/ok.png" alt="Password accepted"  onmouseover="return overlib(\'Password accepted\',FGCOLOR, \'#006BD7\', TEXTCOLOR, \'#FFF\');" onmouseout="return nd();"/>'; 
		else out2.innerHTML='<img src="img/nok.png" alt="Password do not match" onmouseover="return overlib(\'Password does not match\');" onmouseout="return nd();"/>';
		out1.innerHTML=''; 
	}
	else {
		out1.innerHTML='<img src="img/nok.png" alt="Enter your password (>2 characters)" onmouseover="return overlib(\'Enter your password\');" onmouseout="return nd();"/>';
		out2.innerHTML=''; 
	}
	nd(); // hide tooltip
}

/***********************************************************************************************************************/


//form validators
function validate(f,v,a,x){ for(a=0;x=f[a++];) if((v=window[x.getAttribute('valid')])&&!v(x.value)) {alert(x.getAttribute('alert'));return!x.focus()} }
function notempty(x){return x>''}
function ismail(e){return /^[\w\.-]{2,}@[\w\.-]+\.[a-z]{2,5}$/i.test(e)}

