function submitnewsletter(obj) {

	var nume = obj.nume.value;
	var email = obj.email.value;

	if (nume == 'Nume' || nume == '')
	{
		alert('Introdu te rog numele tau');
		return false;
	}
	AtPos = email.indexOf("@")
	StopPos = email.lastIndexOf(".")
	if (email == '' || AtPos == -1 || StopPos == -1 || StopPos < AtPos || StopPos - AtPos == 1)
	{
		
		alert('Introdu te rog o adresa de email valida');
		return false;
	}
	remote_data_request("/remote.html", "cmd=newsletter&nume="+encodeURIComponent(nume)+"&email="+encodeURIComponent(email));
	return false;
}
function loopindex(id)
{
	changeimage(id);
	START = id+1;
	if (START > MAXIM) START = 0;
	window.setTimeout("loopindex("+START+")", 5000);
}

function preloadimage(src){

	var obj = document.getElementById('preload');
	obj.innerHTML += '<img src="'+src+'" alt="'+src+'" title="preload image"> asd';

}

function changeimage(id) {

	setOpacity('dreapta1', 0);
	document.getElementById('dreapta1').style.background = 'url("'+dr1[id]+'") no-repeat';
	window.setTimeout("setOpacity('dreapta1', 1)", 50);

	setOpacity('dreapta2', 0);
	document.getElementById('dreapta2').style.background = 'url("'+dr2[id]+'") no-repeat';
	window.setTimeout("setOpacity('dreapta2', 1)", 50);	
	
	setOpacity('dreapta3', 0);
	document.getElementById('dreapta3').style.background = 'url("'+dr3[id]+'") no-repeat';
	window.setTimeout("setOpacity('dreapta3', 1)", 50);	
	
	setOpacity('dreapta4', 0);
	document.getElementById('dreapta4').style.background = 'url("'+dr4[id]+'") no-repeat';
	window.setTimeout("setOpacity('dreapta4', 1)", 50);
	return false;
}

function imageloop(id) {

	changeimage(id);
	id = parseInt(id);
	if (id == 4) id = 1;
	else id = (id+1);
	window.setTimeout("imageloop("+id+" )", 6000);
}

function setOpacity(id, value) {

	testObj = document.getElementById(id);
	testObj.style.opacity = value/10;
	testObj.style.filter = 'alpha(opacity=' + value*10 + ')';

	if (value < 10)
	{

		value = (value+1);
		window.setTimeout("setOpacity('"+id+"', "+value+")", 120);
	}
}

function previmg(obj, id)
{
	var curtop = curleft = 0;
	if (obj.offsetParent) {
		do {
			curtop += obj.offsetTop;
			curleft += obj.offsetLeft;
		} while (obj = obj.offsetParent);
	}

	previ = document.getElementById('prev');
	previ.style.display = '';
	previ.style.position = 'fixed';
	previ.innerHTML = "<img src='/img/up/"+id+".jpg' />";
	previ.style.marginLeft = "auto";
	previ.style.marginRight = "auto";

	if (o) document.body.removeChild(o);
	var o = document.createElement("div");
	var t = document.createTextNode("foo");

	previ.style.left = document.documentElement.clientWidth / 2+"px";
	previ.style.top = document.documentElement.clientHeight / 2+"px";
}

function removeprev()
{
	previ = document.getElementById('prev');
	previ.style.display = 'none';
}

var w=1
var h=1

if (document.getElementById || document.all)
document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:-1000px;width:1px;height:1px;border:1px solid #888888;background:#DDDDDD;"><img id="ttimg" src="img/s.gif" /></div>')

function gettrailobj()
{
	if (document.getElementById) return document.getElementById("trailimageid").style
	else if (document.all) return document.all.trailimagid.style
}

function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail()
{
	document.onmousemove=""
	document.getElementById('ttimg').src='img/s.gif'
	gettrailobj().visibility="hidden"
	gettrailobj().left=-1000
	gettrailobj().top=0
}


function showtrail(width,height,file)
{

	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1 && navigator.userAgent.toLowerCase().indexOf('safari') == -1)
	{
		w=width
		h=height

		// followmouse()

		gettrailobj().visibility="visible"
		gettrailobj().width=w+"px"
		gettrailobj().height=h+"px"
		document.getElementById('ttimg').src=file
		document.getElementById('ttimg').style.width=w+"px"
		document.getElementById('ttimg').style.height=h+"px"
		gettrailobj().zIndex = 99;
		document.onmousemove=followmouse
	}
}


function followmouse(e)
{


	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1 && navigator.userAgent.toLowerCase().indexOf('safari') == -1)
	{

		var xcoord=20
		var ycoord=20

		if (typeof e != "undefined")
		{
			xcoord+=e.pageX
			ycoord+=e.pageY
		}
		else if (typeof window.event !="undefined")
		{
			xcoord+=truebody().scrollLeft+event.clientX
			ycoord+=truebody().scrollTop+event.clientY
		}

		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)

		if (xcoord+w+3>docwidth)
		xcoord=xcoord-w-(20*2)

		if (ycoord-truebody().scrollTop+h>docheight)
		ycoord=ycoord-h;
		if (ycoord < 0) ycoord = 20;

		if (ycoord+h > docheight)
		{
			ycoord = docheight-h-20;
		}

		gettrailobj().left=xcoord+"px"
		gettrailobj().top=ycoord+"px"


	}

}

// REMOTE REQUEST FUNCTIONS
var http_request = false;
var http_remote_result = "";



function remote_data_request(url, parameters, callback_function) {

	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType("text/html; charset=iso-8859-2");
		}
	}
	else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
	if (!http_request) {
		alert("Cannot create XMLHTTP instance");
		return false;
	}

	http_request.onreadystatechange = function(){
		if (http_request.readyState == 4) {
			// alert(http_request.status);
			if (http_request.status == 200) {
				http_remote_result = http_request.responseText;
				eval(http_remote_result);
				eval(callback_function);

			}
			else {
				alert("There was a problem with the request.");
			}
		}
	};

	http_request.open("POST", url, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);

}