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_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 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 checkform()
{
if (document.inreg.user.value=='')
{
	alert('You have not write the username!');
	document.inreg.user.focus();
	return false;
}
else if (document.inreg.user.value.length<6 || document.inreg.user.value.length>20)
{
	alert('The username must have min 6 chars and max 20 chars!');
	document.inreg.user.focus();
	return false;
}
else if (document.inreg.pass.value=='')
{
	alert('You have not write password!');
	document.inreg.pass.focus();
	return false;
}
else if (document.inreg.pass.value.length<6)
{
	alert('The password must have min 6 chars!');
	document.inreg.pass.focus();
	return false;
}
else if (document.inreg.rpass.value=='')
{
	alert('You have not confirm the password!');
	document.inreg.rpass.focus();
	return false;
}
else if (document.inreg.pass.value!=document.inreg.rpass.value)
{
	alert('You have not write same password!');
	document.inreg.rpass.focus();
	return false;
}

else if (document.inreg.nume.value=='')
{
	alert('You have not write the last name!');
	document.inreg.nume.focus();
	return false;
}
else if (document.inreg.nume.value.length>20)
{
	alert('The last name must have max 20 chars!');
	document.inreg.nume.focus();
	return false;
}
else if (document.inreg.prenume.value=='')
{
	alert('You have not write the first name!');
	document.inreg.prenume.focus();
	return false;
}
else if (document.inreg.prenume.value.length>20)
{
	alert('The first name must have max 20 chars!');
	document.inreg.prenume.focus();
	return false;
}

else if (document.inreg.email.value=='')
{
	alert('You have not write the 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("Type a valid e-mail!");
document.inreg.email.focus();
return false;
} 
else if (document.inreg.tara.value=='0')
{
	alert('Choose the country!');
	document.inreg.tara.focus();
	return false;
}
else if (document.inreg.oras.value=='')
{
	alert('Type the city!');
	document.inreg.oras.focus();
	return false;
}
else if (document.inreg.school.value=='')
{
	alert('Type the school!');
	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("Please insert a valid e-mail address!");
d.email.focus();
return false;
} 
else
{return true;}
}

function checkform2()
{
if (document.inreg.pass.value=='')
{
	alert('You have not write the password!');
	document.inreg.pass.focus();
	return false;
}
else if (document.inreg.rpass.value=='')
{
	alert('You have not confirm the password!');
	document.inreg.rpass.focus();
	return false;
}
else if (document.inreg.pass.value!=document.inreg.rpass.value)
{
	alert('You have not write same password!');
	document.inreg.rpass.focus();
	return false;
}
else if (document.inreg.nume.value=='')
{
	alert('You have not write the last name!');
	document.inreg.nume.focus();
	return false;
}
else if (document.inreg.prenume.value=='')
{
	alert('You have not write the first name!');
	document.inreg.prenume.focus();
	return false;
}
else if (document.inreg.email.value=='')
{
	alert('You have not write the 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("Type a valid e-mail!");
document.inreg.email.focus();
return false;
} 
else if (document.inreg.oras.value=='0')
{
	alert('You have not choose e-mail!');
	document.inreg.oras.focus();
	return false;
}
else if (document.inreg.school.value=='')
{
	alert('You have not write the school!');
	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('You have not write the last name!');
	document.inreg.nume.focus();
	return false;
}
else if (document.inreg.prenume.value=='')
{
	alert('You have not write the first name!');
	document.inreg.prenume.focus();
	return false;
}
else if (document.inreg.email.value=='')
{
	alert('You have not write the 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("Please insert a valid e-mail address!");
document.inreg.email.focus();
return false;
} 
else if (document.inreg.judet.value=='0')
{
	alert('You have not choose the city!');
	document.inreg.judet.focus();
	return false;
}
else if (document.inreg.oras.value=='0')
{
	alert('You have not write the city!');
	document.inreg.oras.focus();
	return false;
}
else if (document.inreg.school.value=='')
{
	alert('You have not write the the school!');
	document.inreg.school.focus();
	return false;
}
else if (document.inreg.tel.value=='')
{
	alert('You have not write the phone number!');
	document.inreg.tel.focus();
	return false;
}
else
{
return true;
}
}

function contest()
{
if (document.upload.denumire.value=='')
{
	alert('You have not write the name!');
	document.upload.denumire.focus();
	return false;
}
else if (document.upload.descriere.value=='')
{
	alert('You have not write the descrtion!');
	document.upload.descriere.focus();
	return false;
}
else
{
return true;
}
}

function tutorial(x)
{
if (document.tut.titlu.value=='')
{
	alert('Type in the title!');
	document.tut.titlu.focus();
	return false;
}
else if (document.tut.description.value=='')
{
	alert('Type in the description!');
	document.tut.description.focus();
	return false;
}
else if (document.tut.text.value=='')
{
	alert('Type in the text!');
	document.tut.text.focus();
	return false;
}

else
{
return true;
}
}


function anunt()
{
if (document.news.titlu.value=='')
{
	alert('You have not write the title!');
	document.news.titlu.focus();
	return false;
}
else if (document.news.continut.value=='')
{
	alert('You have not write the content!');
	document.news.continut.focus();
	return false;
}
else
{
return true;
}
}

function sterge_user()
{
var answer = confirm ("Are you sure you want delete the account? This action is definitive.")
if (answer)
{
window.location="index.php?pag=delete";
return true;
}
else
{
return false;
}
}

function sterge_avatar(d)
{
var answer = confirm ("Are you sure you want to delete the avatar? The action is definitive.")
if (answer)
{
window.location="index.php?pag=delete_avatar&id="+d;
return true;
}
else
{
return false;
}
}

function sterge_obj(d,x)
{
var answer = confirm ("Are you sure you want delete the object? This action is definitive.")
if (answer)
{
window.location="index.php?pag=delete2&concurs="+d+"&obj="+x;
return true;
}
}

function sponsor()
{
if (document.sponsor.nume.value=='')
{
	alert('You have not write the last name!');
	document.sponsor.nume.focus();
	return false;
}
else
{
return true;
}
}

function premiul()
{
if (document.premiu.nume.value=='')
{
	alert('You have not write the type!');
	document.premiu.nume.focus();
	return false;
}
else
{
return true;
}
}

function adaugarea()
{
if (document.adauga.nume.value=='')
{
	alert('You have not write the name!');
	document.adauga.nume.focus();
	return false;
}
else if (document.adauga.userfile.value=='')
{
	alert('You have not choose the work!');
	document.adauga.userfile.focus();
	return false;
}
else if (document.adauga.concurs.value=='0')
{
	alert('You have not choose the contest!');
	document.adauga.concurs.focus();
	return false;
}
else
{
return true;
}
}

function adaugarea2()
{
if (document.adauga2.nume.value=='')
{
	alert('You have not write the name of tutorial!');
	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, "","");
   } 
