var curpic = 1;

function prev(w)
{
	var npic = document.getElementById("npic").value;
	var id = document.getElementById("ofid").value;
	
	if (npic > 0)
	{
		curpic--;
		if (curpic < 1) curpic = npic;
		window.document.pic.src = "?page=thumbnail&id=" + id + "&imgid=" + curpic + "&w=" + w;
		document.getElementById("imglink").href = "?page=thumbnail&id=" + id + "&imgid=" + curpic + "&w=full";
		return;
	}
}

function next(w)
{
	var npic = document.getElementById("npic").value;
	var id = document.getElementById("ofid").value;
	
	if (npic > 0)
	{
		curpic++;
		if (curpic > npic) curpic = 1;
		window.document.pic.src = "?page=thumbnail&id=" + id + "&imgid=" + curpic + "&w=" + w;
		document.getElementById("imglink").href = "?page=thumbnail&id=" + id + "&imgid=" + curpic + "&w=full";
		return;
	}
}

function popUp(URL)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar = 0, scrollbars = 0, location = 0, statusbar = 0, menubar = 0, resizable = 1, width = 660, height = 500, left = 320, top = 272');");
}

function limitText(limitField, limitCount, limitNum)
{
	if (limitField.value.length > limitNum)
	{
		limitField.value = limitField.value.substring(0, limitNum);
	} else
	{
		limitCount.value = limitNum - limitField.value.length;
	}
}

function confirmDelete(id)
{
	data = document.getElementById("data" + id).value.split("_");
	if (confirm("Sigur doriti sa stergeti " + data[1] + "?"))
	{
		window.location = data[0];
	}
}

function setData(url)
{
	Ajax.Request(url, Page.onResponse);
}

function getData(mode, dropDown)
{
	oid = document.getElementById("offertype").selectedIndex;
	bid = document.getElementById("bldtype").selectedIndex;
	cid = document.getElementById("city").selectedIndex;
	if (cid != 0) cid = document.getElementById("city").options[document.getElementById("city").selectedIndex].value;
	
	url = 'connector.php?method=get&mode=' + mode + '&dropdown=' + dropDown.name + '&oid=' + oid + '&bid=' + bid + '&cid=' + cid;
	
	Ajax.Request(url, Page.onResponse);
}

function smtpAuthChange()
{
	document.getElementById("smtpuser").disabled = !document.getElementById("smtpauth").checked;
	document.getElementById("smtppass").disabled = !document.getElementById("smtpauth").checked;
}

function noEnter()
{
	return !(window.event && window.event.keyCode == 13);
}

function setClass(element, class)
{
	element.className = class;
}

function validateForm(form)
{
	switch (form.id)
	{
		
	}
}