var loader = '<div id="loader" align="center"><img src="/media/img/layout/loader.gif"></div>';
var loader2 = '<div id="loader2" align="center"><img src="/media/img/layout/loader2.gif"></div>';
var close_link = '<div align="right" id="close"><a href="#" onclick="closeEvent(); return false;"><img src="/media/img/layout/close.gif" border="0"></a></div>';


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function check_login()
{	
	if (document.login.email.value=="" || document.login.email.value=="adresa@email") {
		showDialog("Eroare", "Va rugam adaugati adresa de e-mail pentru a continua.", "errors");
		document.login.email.focus();
		return false;
	}
	
	if (document.login.password.value=="") {
		showDialog("Eroare", "Va rugam adaugati parola pentru a continua.", "errors");
		document.login.password.focus();
		return false;
	}
	return true;
}

function check_update()
{	
	if (document.profile.name.value=="") {
		showDialog("Eroare", "Va rugam adaugati numele pentru a continua.", "errors");
		document.profile.name.focus();
		return false;
	}

	if (document.profile.password.value=="") {
		showDialog("Eroare", "Va rugam adaugati parola pentru a continua.", "errors");
		document.profile.password.focus();
		return false;
	}

	if (document.profile.password.value!=document.profile.password_again.value) {
		showDialog("Eroare", "La rescriere parola nu se potriveste.", "errors");
		document.profile.password.focus();
		return false;
	}
	return true;
}

function check_new_pass()
{	
	if (document.new_pass.old_pass.value=="") {
		showDialog("Eroare", "Va rugam adaugati parola actuala pentru a continua.", "errors");
		document.new_pass.old_pass.focus();
		return false;
	}

	if (document.new_pass.password.value=="") {
		showDialog("Eroare", "Va rugam adaugati parola noua pentru a continua.", "errors");
		document.new_pass.password.focus();
		return false;
	}

	if (document.new_pass.password.value!=document.new_pass.password_again.value) {
		showDialog("Eroare", "La rescriere parola noua nu se potriveste.", "errors");
		document.new_pass.password_again.focus();
		return false;
	}
	return true;
}

function check_register()
{
	if (document.register.name.value=="") {
		showDialog("Eroare", "Va rugam adaugati Numele pentru a continua.", "errors");
		document.register.name.focus();
		return false;
	}

	if (document.register.email.value=="") {
		showDialog("Eroare", "Va rugam adaugati adresa de e-mail pentru a continua.", "errors");
		document.register.email.value="";
		document.register.email.focus();
		return false;
	} else {
		ast=document.register.email.value.indexOf("@");
		dot=document.register.email.value.lastIndexOf(".");
		if(!(ast>0 && dot>0 && dot>ast)){
			showDialog("Eroare", "Va rugam adaugati o adresa de e-mail valida pentru a continua.", "errors");
			document.register.email.focus();
			return false;
	}}

	if (document.register.email_again.value!=document.register.email.value) {
		showDialog("Eroare", "Atentie, adresa de e-mail este gresita la rescriere.", "errors");
		document.register.email_again.focus();
		return false;
	}
	
	if (document.register.password.value=="") {
		showDialog("Eroare", "Va rugam adaugati parola pentru a continua.", "errors");
		document.register.password.focus();
		return false;
	}

	if (document.register.password_again.value!=document.register.password.value) {
		showDialog("Eroare", "Atentie, parola este gresita la rescriere.", "errors");
		document.register.password_again.focus();
		return false;
	}

	if (document.register.code.value==""){
		showDialog("Eroare", "Va rugam adaugati codul de siguranta din imaginea de mai sus pentru a continua.", "errors");
		document.register.code.focus();
		return false;
	}
/*	
	if (document.register.conditii.checked==false) {
		alert("Pentru a continua trebuie sa fiti de acord cu regulamentul.");
		document.register.conditii.focus();
		return false;
	}
*/
	return true;
}

function check_fpassword_form(){
	if (document.f_password.fpass_email.value=="") {
		showDialog("Eroare", "Va rugam adaugati adresa de e-mail pentru a continua.", "errors");
		document.f_password.fpass_email.focus();
		return false;
	}
	
	return true;	
}

function check_add_quote(){
	if (document.quote_add_form.name.value=="") {
		showDialog("Eroare", "Va rugam introduceti numele autorului.", "errors");
		document.quote_add_form.name.focus();
		return false;
	}
	
	if (document.quote_add_form.ro_text.value=="" && document.quote_add_form.en_text.value=="") {
		showDialog("Eroare", "Va rugam introduceti textul citatului (in romana, engleza sau ambele).", "errors");
		document.quote_add_form.ro_text.focus();
		return false;
	}
	
	if (document.quote_add_form.code.value=="") {
		showDialog("Eroare", "Va rugam introduceti codul din imagine.", "errors");
		document.quote_add_form.code.focus();
		return false;
	}
	
	return true;	
}

function check_add_comment(){
	if (document.comment_form.comment_name.value=="") {
		showDialog("Eroare", "Va rugam introduceti numele.", "errors");
		document.comment_form.comment_name.focus();
		return false;
	}
	
	if (document.comment_form.comment_text.value=="") {
		showDialog("Eroare", "Va rugam introduceti textul comentariului.", "errors");
		document.comment_form.comment_text.focus();
		return false;
	}
	
	if (document.comment_form.code.value=="") {
		showDialog("Eroare", "Va rugam introduceti codul din imagine.", "errors");
		document.comment_form.code.focus();
		return false;
	}
	
	return true;	
}

function check_add(registering)
{	
	if (registering==1) {
		if (document.post_add.email.value=="") {
			showDialog("Eroare", "Va rugam adaugati adresa de e-mail pentru a continua.", "errors");
			document.post_add.email.value="";
			document.post_add.email.focus();
			return false;
		} else {
			ast=document.post_add.email.value.indexOf("@");
			dot=document.post_add.email.value.lastIndexOf(".");
			if(!(ast>0 && dot>0 && dot>ast)){
				showDialog("Eroare", "Va rugam adaugati o adresa de e-mail valida pentru a continua.", "errors");
				document.post_add.email.focus();
				return false;
			}
		}		
	}

	if (document.post_add.type.value=="0") {
		showDialog("Eroare", "Va rugam selectati un domeniu.", "errors");
		document.post_add.type.focus();
		return false;
	}

	if (document.post_add.type.value=="10"){
		if (document.getElementById('sub_type1').value==""){
			showDialog("Eroare", "Va rugam selectati o categorie", "errors");
			document.getElementById('sub_type1').focus();
			return false;
		}
	}

	if ((document.post_add.sub_type1.value=="14")||(document.post_add.sub_type1.value=="15")||(document.post_add.sub_type1.value=="22")||(document.post_add.sub_type1.value=="23")){
		if (document.getElementById('sub_type2').value==""){
			showDialog("Eroare", "Va rugam selectati o subcategorie", "errors");
			document.getElementById('sub_type2').focus();
			return false;
		}
	}

	if (document.post_add.location.value=="") {
		showDialog("Eroare", "Va rugam selectati o localitate.", "errors");
		document.post_add.location.focus();
		return false;
	}

	if (document.post_add.description.value=="") {
		showDialog("Eroare", "Va rugam adaugati descrierea.", "errors");
		document.post_add.description.focus();
		return false;
	}

	return true;
}

function show_sub_types1(type){
	if (type == 10) {
		document.getElementById('sub_types1').style.display = 'block';
	}
	else {
		document.getElementById('sub_types1').style.display = 'none';
		document.getElementById('sub_types2').style.display = 'none';
		document.getElementById('sub_type1').selectedIndex = 0;
		document.getElementById('sub_type2').selectedIndex = 0;
	}
}

function show_sub_types2(type){
	if ((type == 14)||(type == 15)||(type == 22)||(type == 23))
		document.getElementById('sub_types2').style.display = 'block';
	else
		document.getElementById('sub_types2').style.display = 'none';
}


function change_keep_image(newImage, keep_image)
{
	if (newImage == ""){
		document.getElementById(keep_image).checked = true;
	}
	else{
		document.getElementById(keep_image).checked = false;
	}
}

function delete_new_image(keep_image, image)
{
	if (keep_image){
		document.getElementById('logo').value = "";
	}
}


function clear_field(field,name)
{
		if(field.value==name){
			field.value="";
		}
}


function OnOver(TheId) {
	document.getElementById(TheId).style.background='#80a6c3';
}

function OnOut(TheId) {
	
	document.getElementById(TheId).style.background='#bcd0df';
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oLeft = o.offsetLeft ;           // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent ;   // Get parent object reference
		oLeft += oParent.offsetLeft; // Add parent left position
		o = oParent;
	}
	// Return left postion
	return oLeft;
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId);
	oTop = o.offsetTop       ;     // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent ; // Get parent object reference
		oTop += oParent.offsetTop; // Add parent top position
		o = oParent;
	}
	// Return top position
	return oTop;
}

function key(){
		if (document.search.q.value=="" || document.search.q.value=="cautare..."){
			showDialog("Eroare", "Va rugam adaugati textul cautat.", "errors");
			document.search.q.value="";
			document.search.q.focus();
			return false;
		}
		if(document.search.q.value!="") {
			if(document.search.q.value.length<3) {
			showDialog("Eroare", "Va rugam introduceti minim 3 caractere pentru cautare", "errors");
			document.search.q.focus();
			return false;
		}}
}

/* box */

var persistclose=1 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX =600//set x offset of bar in pixels
var startY = 5 //set y offset of bar in pixels
var verticalpos="frombottom" //enter "fromtop" or "frombottom"

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

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function closebar(){
if (persistclose)
document.cookie="remainclosed=1"
document.getElementById("topbar").style.visibility="hidden"
}

function staticbar(){
	barheight=document.getElementById("topbar").offsetHeight
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
	var d = document;
	function ml(id){
		var el=d.getElementById(id);
		if (!persistclose || persistclose && get_cookie("remainclosed")=="")
		el.style.visibility="visible"
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function(){
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : iecompattest().scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("topbar");
	stayTopLeft();
}

if (window.addEventListener)
window.addEventListener("load", staticbar, false)
else if (window.attachEvent)
window.attachEvent("onload", staticbar)
else if (document.getElementById)
window.onload=staticbar





