// misc
var currentPromoID;
function hidestatus(){
	window.status=''; return true;
}

if (document.layers)
	document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
document.onmouseover=hidestatus;
document.onmouseout=hidestatus;

function g(str){
	if (document.getElementById(str))
		return document.getElementById(str)
	return false;
}

function changeInputValue(el, currvalue, newvalue){
	//alert("-" + currvalue + "-" + newvalue + "-");
	if (currvalue == newvalue)
		el.value = '';
	else
		el.value = newvalue;
}

function confirmDeleteNews(ID) {
  if (confirm("Stergeti stirea cu ID-ul " + ID + "?")) {
    document.location = 'default.php?p=a_news&m=del&id=' + ID;
  }
}
function confirmDeleteService(ID) {
  if (confirm("Stergeti serviciul cu ID-ul " + ID + "?")) {
    document.location = 'default.php?p=a_services&m=del&id=' + ID;
  }
}
function confirmDeleteArticle(ID) {
  if (confirm("Stergeti articolul cu ID-ul " + ID + "?")) {
    document.location = 'default.php?p=a_articles&m=del&id=' + ID;
  }
}
function confirmDeleteItems(ID) {
  if (confirm("Stergeti anuntul cu ID-ul " + ID + "?")) {
    document.location = 'default.php?p=a_items&m=del&id=' + ID;
  }
}

function switchAddPanel(nr) {
	if (g('additem_step1'))
		g('additem_step1').style.display = 'none';
	if (g('additem_step2'))
		g('additem_step2').style.display = 'none';
	if (g('additem_step3'))
		g('additem_step3').style.display = 'none';
		
	if (g('additem_step'+nr))
		g('additem_step'+nr).style.display = 'block';
}

function setIntTime(id) {
	if (g('selected_time'))
		g('selected_time').value = id;
	g('interval_1').style.background = "transparent";
	g('interval_2').style.background = "transparent";
	g('interval_3').style.background = "transparent";
	
	g('interval_'+id).style.background = "url('img/bg_interval.jpg') no-repeat top center";
}

function showPromo(id, image, total, realid, manual) {
	for (i=1; i<=total; i++) {
		if (g('promo_project_' + i))
			g('promo_project_' + i).style.display = 'none';
		if (g('promolinked_' + i))
			g('promolinked_' + i).className = "promo_home_href";
	}
	if (g('promo_project_' + id))
		g('promo_project_' + id).style.display = 'block';
	g('promo_home_main').style.background = "url('files/assets/img_items/" + image + "_519.jpg')";
	if (g('promolinked_' + id))
		g('promolinked_' + id).className = "promo_home_href2";
	if (manual == '1')
		clearTimeout(promoTimeout);
	currentPromoID = realid;
}

function changeHType(string) {
	if (g('htype_info'))
		g('htype_info').innerHTML = string;
}

/*
function srcform(id) {
	// o gramada de cod ca sa faci disabled alea de care nu ai nevoie !!
	
	// hide all
	g('searcharea_locations').style.display = 'none';
	g('searcharea_rooms').style.display = 'none';
	g('searcharea_floor').style.display = 'none';
	g('searcharea_level').style.display = 'none';
	g('searcharea_division').style.display = 'none';
	g('searcharea_price').style.display = 'none';
	g('searcharea_year').style.display = 'none';
	g('searcharea_surface').style.display = 'none';
	g('searcharea_acc').style.display = 'none';
	
	// apartamente
	if (id == 1) {
		g('hidden_clid').value = '1';
		g('searcharea_locations').style.display = "block";
		g('searcharea_rooms').style.display = "block";
		g('searcharea_floor').style.display = "block";
		g('searcharea_division').style.display = "block";
		g('searcharea_price').style.display = "block";
		g('searcharea_year').style.display = "block";
		g('searcharea_acc').style.display = "block";
	}
	// case / vile
	else if (id == 2) {
		g('hidden_clid').value = '2';
		g('searcharea_locations').style.display = "block";
		g('searcharea_rooms').style.display = "block";
		g('searcharea_level').style.display = "block";
		g('searcharea_division').style.display = "block";
		g('searcharea_price').style.display = "block";
		g('searcharea_year').style.display = "block";
		g('searcharea_acc').style.display = "block";
	}
	// terenuri
	else if (id == 3) {
		g('hidden_clid').value = '3';
		g('searcharea_price').style.display = "block";
		g('searcharea_surface').style.display = 'block';
	}
	// proiecte rezidentiale
	else if (id == 4) {
		g('hidden_clid').value = '4';
		g('searcharea_price').style.display = "block";
		g('searcharea_year').style.display = "block";
	}
}
*/

// AS-JS communication
function thisMovie(movieName) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}

function showImage(index) {
	if (g('map_viewer'))
		g('map_viewer').style.display = "none";
	if (g('picture_viewer'))
		g('picture_viewer').style.display = "block";
    thisMovie("image_viewer").selectImage(index);
}

function flipPage(index) {
    document.inForm.inField.value = "indexImage: " + str;
}

function selectedLatest(args) {
	loadSection('latest', args);
}

function showSuggest() {
	if (g('suggestpop'))
		g('suggestpop').style.display = "block";
}
function closeSuggest() {
	if (g('suggestpop'))
		g('suggestpop').style.display = "none";
}

function showMessaging() {
	location.href = "#top";
	if (g('messagingpop'))
		g('messagingpop').style.display = "block";
}
function closeMessaging() {
	if (g('messagingpop'))
		g('messagingpop').style.display = "none";
}

function flipNL(currentItem, newItem, lastItem) {
	if (newItem > lastItem)
		newItem = 1;
	if (newItem < 1)
		newItem = lastItem;
	if (g('newsletter_' + currentItem) && g('newsletter_' + newItem))
		g('newsletter_' + currentItem).style.display = "none";
	if (g('newsletter_' + newItem))
		g('newsletter_' + newItem).style.display = "block";
	if(g('newsletter_form'))
		g('newsletter_form').style.display = "block";
}

function updateTotal(check) {
	if (g('total_amount')) {
		if (check) {
			status = check.checked;
			check_value = parseFloat(check.value);
			initial_value = parseFloat(g('total_amount').innerHTML);
			if (check.checked) {
				newvalue = initial_value + check_value;
			}
			else {
				newvalue = initial_value - check_value;
			}
			//alert("Status: " + status + " Value: " + check_value + " Total value: " + newvalue);
			g('total_amount').innerHTML = newvalue;
		}
		//alert(status);
		//innerHTML = "tester";
	}
}

function calcUpdate(op1, op2) {
	if (g('calc_test'))
		g('calc_test').value = op1*op2;
}
