$(function() {
	$("input[@type=file]").filestyle({
	    image: "fileadmin/images/browse.gif",
	    imageheight : 31,
	    imagewidth : 84,
	    width : 221	});
	$('input[@type=text], input[@type=password]').addClass('textInput');
	$('input[@type=submit]').addClass('submitInput');
	$('.back_inactive, .tostart_inactive, .forward_inactive, .toend_inactive').attr('href', 'javascript:void(0)');
});
function sfHover() {
	if (document.getElementById("searchForm")) {
		var sfEls = document.getElementById("searchForm").getElementsByTagName("select");
		/*for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onchange=function() {
				//document.getElementById("searchForm").parentNode.submit();
				console.log(this.options[this.selectedIndex].value);
			}
		}*/
		if (document.getElementById("refineSearch")) {
			document.getElementById("refineSearch").onclick = function() {
				//document.getElementById("searchForm").parentNode.submit();
				//return false;
			}
		}
	}
	if(document.getElementById('powermaildiv_uid47')) document.getElementById('powermaildiv_uid47').getElementsByTagName('input')[0].onclick=modify;
}

function ajaxCategory(obj,divID){
	//console.log(obj);
	url = document.location.href;
	if(url.indexOf("?")>0) url += "&eID=ajaxcategory";
	else url += "?eID=ajaxcategory";
	$.ajax({
	  url: url,
	  cache: false,
	  type: "GET",
	  data: "parentID="+ obj.options[obj.selectedIndex].value ,

	  success: function(html){
	    $("#"+divID).html(html);
		
	    if(html.length>1) $("#"+divID).show();
		
	  }
});
}

function modify() {
	var option=document.getElementById('uid40').getElementsByTagName('option');
	var option2=document.getElementById('uid41').getElementsByTagName('option');
	for(i=0; i<option.length; i++) { option[i].blur();	}
	var opLength = option2.length;
	for(z=0; z<opLength; z++) {
		newOptions = new Option(option2[0].text,option2[0].value);
		newOptions.setAttribute('selected','selected');
		document.getElementById('uid41').options.add(newOptions,opLength);
		document.getElementById('uid41').removeChild(option2[0]);
	}
}

function submitSearchForm(){
	document.getElementById("realSubmit").value=1;
	document.getElementById("search").submit();
}
window.onload=sfHover;

function changeOption(object)
{
	var i,j;
	for(i=0; i < category.length; i++)
	{
		if (category[i][0] == object.options[object.selectedIndex].value)
		{
			document.getElementById('category1').options.length = 0;
			for(j=0; j<localitati[i][2].length; j++)
			{
				document.getElementById('category2').options[j] = new Option(category[i][2][j][1], category[i][2][j][0])
			}
			return;
		}
	}
	return;
}
