function bookmark(url,title){
	try{
		window.external.AddFavorite(url,title);
	}
	catch(e){
		if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
			window.external.AddFavorite(url,title);
		} else if (navigator.appName == "Netscape") {
			window.sidebar.addPanel(title,url,"");
		} else {
			alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
		}
	}
	return void(0);
}

function initCalendar(field){
    Calendar.setup({
        inputField     :    field,     // id of the input field
        ifFormat       :    "%d.%m.%Y ",      // format of the input field
        button         :    field + "_button",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true,
	showsTime      :    true,
        timeFormat     :    "24"
    });
}
/*
var wndCalc = null;
function getCalculator(c_id){
	try{
		wndCalc.close();
	}
	catch(e){}
	var w = 400;
	var h = 200
	if(c_id == 1001){
		w = 600;
		h = 250;
	}
	wndCalc = window.open('calc.php?calc=' + c_id, '', 'width=200,height=200,location=0');
	return void(0);
}
*/
var dRotate = 0;
var currentPic = 0;

function startRotate(){
	if(dRotate == 1){
		return;
	}
	dRotate = 1;
	return showImg(1);
	
}

function pauseRotate(){
	dRotate = 0;
	return void(0);
}

function showImg(){
	try{
	var args = showImg.arguments;
	direction = 0;
	if(args.length){
		direction = args[0];
	}
	
	//var incr = direction ? 1 : -1;
	if(currentPic + direction < 0){
		currentPic = pics.length;
	}
	if(pics[currentPic + direction]){
		currentPic = currentPic + direction
	}
	else{
		currentPic = 0;
	}
	var pd = document.getElementById('picDiv');
	//alert(pics[currentPic][0]);
	//pd.style.backgroundImage = pics[currentPic][0];
	pd.style.backgroundImage = 'url(' + pics[currentPic][1] + ')';
	var a = document.getElementById('lightBoxA');
	//alert(a);
	a.href = pics[currentPic][0];
	if(dRotate){
		setTimeout('showImg(1)', 2000);
	}
	}
	catch(e){
	
	}
	return void(0);
}

var pics = new Array();


var areas = new Array();

var statuses = new Array();

function fillGolfAreasArr(){
	if(areas.length){
		return;
	}
	try{
		var ar = document.getElementById('area_block');
		for(var i = 0; i < ar.length; i++){
			//var op = new Option(ar.options[i].text, ar.options[i].value);
			areas[areas.length] = new Option(ar.options[i].text, ar.options[i].value);
		}
		//alert(areas.length);
	}
	catch(e){
	}
}

function fillStatusesArr(){
	if(statuses.length){
		return;
	}
	try{
		var ar = document.getElementById('cnd_block');
		for(var i = 0; i < ar.length; i++){
			//var op = new Option(ar.options[i].text, ar.options[i].value);
			statuses[statuses.length] = new Option(ar.options[i].text, ar.options[i].value);
		}
	}
	catch(e){
	}
}

function fillAreaSeslect(is_golf, obj){
	obj.options.length = 0;
	for(var i = 0; i < areas.length; i++){
		if(is_golf && (i != 2 && i != 4 && i !=0)){
			continue;
		}
		var op = new Option();
		op.text = areas[i].text;
		op.value = areas[i].value;
		obj.options[obj.options.length] = op;
	}
}

function fillStatuses(is_dev, obj){
	obj.options.length = 0;
	for(var i = 0; i < statuses.length; i++){
		if(is_dev == 1 && (i != 3 && i != 4 && i !=0)){
			continue;
		}
		if(is_dev == -1 && (i != 1 && i != 2 && i !=0)){
			continue;
		}
		var op = new Option();
		op.text = statuses[i].text;
		op.value = statuses[i].value;
		obj.options[obj.options.length] = op;
	}
}

function checkForGolfAreas(obj){
	fillGolfAreasArr();
	fillStatusesArr()
	var ar = document.getElementById('area_block');
	var cnd = document.getElementById('cnd_block');
	fillAreaSeslect(obj.selectedIndex == 2 ? 1 : 0, ar);
	fillStatuses(obj.selectedIndex == 3 ? 1 : (obj.selectedIndex == 0 ? 0 : -1), cnd)
}

function checkForGolfAreasModule(obj){
	fillGolfAreasArr();
	fillStatusesArr()
	var ar = document.getElementById('area_module');
	var cnd = document.getElementById('cnd_module');
	fillAreaSeslect(obj.selectedIndex == 2 ? 1 : 0, ar);
	fillStatuses(obj.selectedIndex == 3 ? 1 : (obj.selectedIndex == 0 ? 0 : -1), cnd)
}

function setDisticts(){
	var a = document.getElementById('area_module');
	var d = document.getElementById('distr');
	if(!a || !d){
		return;
	}
	d.options.length = 0;
	var op = new Option();
	op.text = ' - ANY - ';
	op.value = '';
	d.options[d.options.length] = op;
	for(var i = 0; i < distrColl.length; i++){
		if(a.options[a.selectedIndex].value != distrColl[i][1]){
			continue;
		}
		var op = new Option();
		op.text = distrColl[i][0];
		op.value = distrColl[i][0];
		d.options[d.options.length] = op;
	}
}
