function valbaza(id, text){
	if (id.value == ""){
		id.value = text;
	}
}
function valnula(id, text){
	if (id.value == text){
		id.value = "";
	}
}
function sendtofriend(id){
	if (document.getElementById){
		obj = document.getElementById(id);
		ad = document.getElementById('sendtofriend');
		if (obj.style.display == "none"){
			obj.style.display = "";
		} else {
			obj.style.display = "none";
		}
	}
}
function check_pass(password, confirmpassword, updatefield)
{
	var pass = document.getElementById(password).value;
	var confirmpass = document.getElementById(confirmpassword).value;
	var result;
	if(pass == confirmpass){
		if(pass == ''){
			result = '';
		} else {
			result = '<span style="color: green; font-size: 11px; font-weight: bold;">Parolele coincid</span>';
		}
	} else {
		result = '<span style="color: red; font-size: 11px; font-weight: bold;">Parolele difera</span>';
	}

	document.getElementById(updatefield).innerHTML = result;
	return;
} 
function Blank_TextField_Validator(type){
	if(type==3){
		nume = document.getElementById('name');
		prenume = document.getElementById('surname');
		virsta = document.getElementById('age');
		localitate = document.getElementById('city');
		tel = document.getElementById('tel');
		email = document.getElementById('email');
		if (nume.value == ""){
			alert("Va rugam sa introduceti Numele.");
			nume.focus();
			return (false);
		}
		if (prenume.value == ""){
			alert("Va rugam sa introduceti Prenumele.");
			prenume.focus();
			return (false);
		}
		if (virsta.value == ""){
			alert("Va rugam sa introduceti Virsta.");
			virsta.focus();
			return (false);
		}
		if (localitate.value == ""){
			alert("Va rugam sa introduceti Localitatea.");
			localitate.focus();
			return (false);
		}
		if ((tel.value == "") && (email.value == "")){
			alert("Va rugam sa introduceti Telefonul sau Email-ul Dvs.");
			tel.focus();
			return (false);
		}
	} else {
		nume = document.getElementById('commentname');
		comentariu = document.getElementById('commenttext');
		if (nume.value == ""){
			alert("Va rugam sa va introduceti numele.");
			nume.focus();
			return (false);
		}
		if (comentariu.value == ""){
			if(type==1){
				alert("Introduceti comentariul.");
			}else{
				alert("Introduceti intrebarea.");
			}
			comentariu.focus();
			return (false);
		}
	}
	return (true);
}

var browser=navigator.userAgent.toLowerCase();
var isFF=((browser.indexOf('mozilla')!=-1) && (browser.indexOf('spoofer')==-1) && (browser.indexOf('compatible')==-1) && (browser.indexOf('opera')==-1) && (browser.indexOf('webtv')==-1) && (browser.indexOf('hotjava')==-1));
var isIE=((browser.indexOf("msie")!=-1) && (browser.indexOf("opera")==-1));
var isOP=(browser.indexOf("opera")!=-1);

function insert(insert, type, elem){
	if(type==1){
		if(isIE){
			el = document.getElementById(elem);
			el.focus();
			document.selection.createRange().text='['+insert+']'+document.selection.createRange().text+'[/'+insert+']';
		}else{
			el = document.getElementById(elem);
			var text=el;
			el.focus();
			text=text.value.substring(0, text.selectionStart)+'['+insert+']'+text.value.substring(text.selectionStart, text.selectionEnd)+'[/'+insert+']'+text.value.substring(text.selectionEnd, text.value.length);
			el.value=text;
		}
	}else{
		if(isIE){
			el = document.getElementById(elem);
			el.focus();
			document.selection.createRange().text='['+insert+']http://'+document.selection.createRange().text+'[/'+insert+']';
		}else{
			el = document.getElementById(elem);
			var text=el;
			el.focus();
			text=text.value.substring(0, text.selectionStart)+'['+insert+']http://'+text.value.substring(text.selectionStart, text.selectionEnd)+'[/'+insert+']'+text.value.substring(text.selectionEnd, text.value.length);
			el.value=text;
		}
	}
}
function CheckBefore(form){
	tx=form.comment.value;
	if (tx.length==0){ form.comment.focus(); return false;}
	tx=form.code.value;
	if (tx.length==0){ form.code.focus(); return false;}
	return true;
}
function DisplayMail(Server, Login, Display){
	if ((Display.length == 0) || (Display.indexOf('@')+1)) {
		document.write('<a href=' + '"mai' + 'lto:' + Login + '@' + Server + '">' + Login + '@' + Server + '<\/a>');
	} else {
		document.write('<a href=' + '"mai' + 'lto:' + Login + '@' + Server + '">' + Display + '<\/a>');
	}
}

function ChangeCountry()
{
	var country
	country = document.getElementById("country")
	var city
	city = document.getElementById("city")
	var citydrop
	citydrop = document.getElementById("cityselect")

	if(country.selectedIndex==0)
	{
		citydrop.selectedIndex = 0;
		city.style.display = "none";
		city.style.visibility = "hidden";
		city.value = citydrop.options[0].value;
		citydrop.style.display = "";
		citydrop.style.visibility = "";
		ChangeCity();
	}else{
		city.value = "";
		city.style.display = "";
		city.style.visibility = "";
		citydrop.style.display = "none";
		citydrop.style.visibility = "hidden";
	}
}

function ChangeCity()
{
	var city
	city = document.getElementById("city")
	var citydrop
	citydrop = document.getElementById("cityselect")
	city.value = citydrop.options[citydrop.selectedIndex].value;
}

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
	document.getElementById(containerid).innerHTML="<div class='loading'><img src='img/common/loading.gif'></div>"
	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {page_request = new ActiveXObject("Msxml2.XMLHTTP")}
		catch (e){
			try{page_request = new ActiveXObject("Microsoft.XMLHTTP")}
			catch (e){}
		}
	} else
		return false
	page_request.onreadystatechange=function(){
		loadpage(page_request, containerid)
	}
	if (bustcachevar) //if bust caching of external page
	bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
}

function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
		document.getElementById(containerid).innerHTML=page_request.responseText
}
