var xmlHttp // xmlHttp variable

function GetXmlHttpObject(){ // This function we will use to call our xmlhttpobject.
var objXMLHttp=null // Sets objXMLHttp to null as default.
if (window.XMLHttpRequest){ // If we are using Netscape or any other browser than IE lets use xmlhttp.
objXMLHttp=new XMLHttpRequest() // Creates a xmlhttp request.
}else if (window.ActiveXObject){ // ElseIf we are using IE lets use Active X.
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP") // Creates a new Active X Object.
} // End ElseIf.
return objXMLHttp
} 

function check_dbs(care,mod,unde,tabel){ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){ 
alert ("Browser does not support HTTP Request")
return // Returns.
} // End If.
var username = document.getElementById(care).value;
var url="check.php?mod="+mod+"&care="+username+"&tabel="+tabel+"&nume="+care
xmlHttp.open("GET",url,true)
xmlHttp.onreadystatechange = function () { 
if (xmlHttp.readyState == 4) { 
display(unde);
var ajaxDisplay = document.getElementById(unde);
ajaxDisplay.innerHTML = xmlHttp.responseText;
}
};
xmlHttp.send(null);
}

function arata(id,unde){ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){ 
alert ("Browser does not support HTTP Request")
return // Returns.
} // End If.
var url="admin/show.php?id="+id
xmlHttp.open("GET",url,true)
xmlHttp.onreadystatechange = function () { 
if (xmlHttp.readyState == 4) { 
var ajaxDisplay = document.getElementById(unde);
ajaxDisplay.innerHTML = xmlHttp.responseText;
}
};
xmlHttp.send(null);
}



function ReverseContentDisplay(d) 
{
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = ""; }
else { document.getElementById(d).style.display = "none"; }
}

function display(d)
{
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = ""; }
}
function hide(d)
{
if(document.getElementById(d).style.display != "none") { document.getElementById(d).style.display = "none"; }
}
function check_style(x,d)
{
if (x.value.length>=6 && x.value.length<=20) document.getElementById(d).style.display = "";
else document.getElementById(d).style.display = "none";
}
function check_style3(x,d)
{
if (x.value.length>=6 && x.value.length<=50) document.getElementById(d).style.display = "";
else document.getElementById(d).style.display = "none";
}

function check_style2(x,d)
{
if (x.value.length>=6 && x.value.length<=20) document.getElementById(d).style.display = "";
else document.getElementById(d).style.display = "none";
}

function checkform()
{
if (document.inreg.user.value=='')
{
	alert('Nu ai introdus username-ul!');
	document.inreg.user.focus();
	return false;
}
else if (document.inreg.user.value.length<6 || document.inreg.user.value.length>20)
{
	alert('Username-ul trebuie sa fie de minim 6 caractere si maxim 20!');
	document.inreg.user.focus();
	return false;
}
else if (document.inreg.pass.value=='')
{
	alert('Nu ai introdus parola!');
	document.inreg.pass.focus();
	return false;
}
else if (document.inreg.pass.value.length<6)
{
	alert('Parola trebuie sa fie de minim 6 caractere!');
	document.inreg.pass.focus();
	return false;
}
else if (document.inreg.rpass.value=='')
{
	alert('Nu ai confirmat parola!');
	document.inreg.rpass.focus();
	return false;
}
else if (document.inreg.pass.value!=document.inreg.rpass.value)
{
	alert('Cele 2 parole nu coincid!');
	document.inreg.rpass.focus();
	return false;
}

else if (document.inreg.nume.value=='')
{
	alert('Nu ai introdus numele!');
	document.inreg.nume.focus();
	return false;
}
else if (document.inreg.nume.value.length>20)
{
	alert('Numele trebuie sa fie de maxim 20 de caractere!');
	document.inreg.nume.focus();
	return false;
}
else if (document.inreg.prenume.value=='')
{
	alert('Nu ai introdus prenumele!');
	document.inreg.prenume.focus();
	return false;
}
else if (document.inreg.prenume.value.length>20)
{
	alert('Prenumele trebuie sa fie de maxim 20 de caractere!');
	document.inreg.prenume.focus();
	return false;
}

else if (document.inreg.email.value=='')
{
	alert('Nu ai introdus adresa de e-mail!');
	document.inreg.email.focus();
	return false;
}
else if ((document.inreg.email.value.indexOf('@') < 0) || ((document.inreg.email.value.charAt(document.inreg.email.value.length-4) != '.') && (document.inreg.email.value.charAt(document.inreg.email.value.length-3) != '.')))
{alert("Introdu o adresa de e-mail valida!");
document.inreg.email.focus();
return false;
} 
else if (document.inreg.tara.value=='0')
{
	alert('Nu ai selectat tara!');
	document.inreg.tara.focus();
	return false;
}
else if (document.inreg.oras.value=='')
{
	alert('Nu ai introdus orasul!');
	document.inreg.oras.focus();
	return false;
}
else if (document.inreg.school.value=='')
{
	alert('Nu ai introdus scoala!');
	document.inreg.school.focus();
	return false;
}
else
{
return true;
}
}

function checkemail(d)
{
if ((d.email.value.indexOf('@') < 0) || ((d.email.value.charAt(d.email.value.length-4) != '.') && (d.email.value.charAt(d.email.value.length-3) != '.')))
{alert("Introdu o adresa de e-mail valida!");
d.email.focus();
return false;
} 
else
{return true;}
}

function checkform2()
{
if (document.inreg.pass.value=='')
{
	alert('Nu ai introdus parola!');
	document.inreg.pass.focus();
	return false;
}
else if (document.inreg.rpass.value=='')
{
	alert('Nu ai confirmat parola!');
	document.inreg.rpass.focus();
	return false;
}
else if (document.inreg.pass.value!=document.inreg.rpass.value)
{
	alert('Cele 2 parole nu coincid!');
	document.inreg.rpass.focus();
	return false;
}
else if (document.inreg.nume.value=='')
{
	alert('Nu ai introdus numele!');
	document.inreg.nume.focus();
	return false;
}
else if (document.inreg.prenume.value=='')
{
	alert('Nu ai introdus prenumele!');
	document.inreg.prenume.focus();
	return false;
}
else if (document.inreg.email.value=='')
{
	alert('Nu ai introdus adresa de e-mail!');
	document.inreg.email.focus();
	return false;
}
else if ((document.inreg.email.value.indexOf('@') < 0) || ((document.inreg.email.value.charAt(document.inreg.email.value.length-4) != '.') && (document.inreg.email.value.charAt(document.inreg.email.value.length-3) != '.')))
{alert("Introdu o adresa de e-mail valida!");
document.inreg.email.focus();
return false;
} 
else if (document.inreg.judet.value=='0')
{
	alert('Nu ai selectat judetul!');
	document.inreg.judet.focus();
	return false;
}
else if (document.inreg.oras.value=='0')
{
	alert('Nu ai selectat orasul!');
	document.inreg.oras.focus();
	return false;
}
else if (document.inreg.school.value=='')
{
	alert('Nu ai introdus scoala!');
	document.inreg.school.focus();
	return false;
}
else if (document.inreg.tel.value=='')
{
	alert('Nu ai introdus numarul de telefon!');
	document.inreg.tel.focus();
	return false;
}
else
{
return true;
}
}

function checkform3()
{
if (document.inreg.nume.value=='')
{
	alert('Nu ai introdus numele!');
	document.inreg.nume.focus();
	return false;
}
else if (document.inreg.prenume.value=='')
{
	alert('Nu ai introdus prenumele!');
	document.inreg.prenume.focus();
	return false;
}
else if (document.inreg.email.value=='')
{
	alert('Nu ai introdus adresa de e-mail!');
	document.inreg.email.focus();
	return false;
}
else if ((document.inreg.email.value.indexOf('@') < 0) || ((document.inreg.email.value.charAt(document.inreg.email.value.length-4) != '.') && (document.inreg.email.value.charAt(document.inreg.email.value.length-3) != '.')))
{alert("Introdu o adresa de e-mail valida!");
document.inreg.email.focus();
return false;
} 
else if (document.inreg.judet.value=='0')
{
	alert('Nu ai selectat judetul!');
	document.inreg.judet.focus();
	return false;
}
else if (document.inreg.oras.value=='0')
{
	alert('Nu ai selectat orasul!');
	document.inreg.oras.focus();
	return false;
}
else if (document.inreg.school.value=='')
{
	alert('Nu ai introdus scoala!');
	document.inreg.school.focus();
	return false;
}
else if (document.inreg.tel.value=='')
{
	alert('Nu ai introdus numarul de telefon!');
	document.inreg.tel.focus();
	return false;
}
else
{
return true;
}
}

function contest()
{
if (document.upload.denumire.value=='')
{
	alert('Nu ai introdus denumirea!');
	document.upload.denumire.focus();
	return false;
}
else if (document.upload.descriere.value=='')
{
	alert('Nu ai introdus descrierea!');
	document.upload.descriere.focus();
	return false;
}
else
{
return true;
}
}

function tutorial(x)
{
if (document.tut.titlu.value=='')
{
	alert('Nu ai introdus titlul!');
	document.tut.titlu.focus();
	return false;
}
else if (document.tut.description.value=='')
{
	alert('Nu ai introdus descrierea!');
	document.tut.description.focus();
	return false;
}
else if (document.tut.text.value=='')
{
	alert('Nu ai introdus textul!');
	document.tut.text.focus();
	return false;
}

else
{
return true;
}
}




function anunt()
{
if (document.news.titlu.value=='')
{
	alert('Nu ai introdus titlul!');
	document.news.titlu.focus();
	return false;
}
else if (document.news.continut.value=='')
{
	alert('Nu ai introdus continutul!');
	document.news.continut.focus();
	return false;
}
else
{
return true;
}
}

function sterge_user()
{
var answer = confirm ("Sigur doresti stergerea contului? Actiunea aceasta este definitiva si irevocabila.")
if (answer)
{
window.location="index.php?pag=delete";
return true;
}
else
{
return false;
}
}

function sterge_avatar(d)
{
var answer = confirm ("Sigur doresti stergerea avatarului? Actiunea aceasta este definitiva.")
if (answer)
{
window.location="index.php?pag=delete_avatar&id="+d;
return true;
}
else
{
return false;
}
}

function sterge_obj(d,x)
{
var answer = confirm ("Sigur doresti stergerea obiectului? Actiunea aceasta este definitiva si irevocabila.")
if (answer)
{
window.location="index.php?pag=delete2&concurs="+d+"&obj="+x;
return true;
}
}

function sponsor()
{
if (document.sponsor.nume.value=='')
{
	alert('Nu ai introdus numele!');
	document.sponsor.nume.focus();
	return false;
}
else
{
return true;
}
}

function premiul()
{
if (document.premiu.nume.value=='')
{
	alert('Nu ai introdus tipul!');
	document.premiu.nume.focus();
	return false;
}
else
{
return true;
}
}

function adaugarea()
{
if (document.adauga.nume.value=='')
{
	alert('Nu ai introdus numele lucrarii!');
	document.adauga.nume.focus();
	return false;
}
else if (document.adauga.userfile.value=='')
{
	alert('Nu ai selectat lucrarea!');
	document.adauga.userfile.focus();
	return false;
}
else if (document.adauga.concurs.value=='0')
{
	alert('Nu ai selectat concursul!');
	document.adauga.concurs.focus();
	return false;
}
else
{
return true;
}
}

function adaugarea2()
{
if (document.adauga2.nume.value=='')
{
	alert('Nu ai introdus numele tutorialului!');
	document.adauga2.nume.focus();
	return false;
}
else
{
return true;
}
}

function PopupPic(sPicURL) {
     window.open( "./core/popup.htm?"+sPicURL, "","resizable=0,HEIGHT=200,WIDTH=200,scrollbars=1");
   }
function PopupPic2(sPicURL) {
     window.open( "../core/popup.htm?"+sPicURL, "","resizable=0,HEIGHT=200,WIDTH=200,scrollbars=1");
   } 
 function PopupVid(sPicURL) {
     window.open( "./core/video.php?pag="+sPicURL, "","resizable=0,HEIGHT=310,WIDTH=410,scrollbars=1");
   } 
 function PopupSwf(sPicURL) {
     window.open( "./core/flash.php?pag="+sPicURL, "","resizable=0,HEIGHT=320,WIDTH=420,scrollbars=1");
}
 function PopupVid2(sPicURL) {
     window.open( "../core/video.php?pag="+sPicURL, "","resizable=0,HEIGHT=310,WIDTH=410,scrollbars=1");
   } 
 function PopupSwf2(sPicURL) {
     window.open( "../core/flash.php?pag="+sPicURL, "","resizable=0,HEIGHT=320,WIDTH=420,scrollbars=1");
}
 function PopupTut(sPicURL) {
     window.open( "./core/tut.php?act="+sPicURL, "","");
   } 