
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=430,height=350');");
}

function popUpFoto(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=550,height=620');");
}

function WResize()
{
	if(document.all && document.limage.largeimage) self.resizeTo(document.limage.largeimage.width+20 ,document.limage.largeimage.height+50);
}

var req;
function loadXMLDoc(url) {
	req = false;
	// branch for native XMLHttpRequest object
	if(window.XMLHttpRequest) {
		try {
			req = new XMLHttpRequest();
		} catch(e) {
			req = false;
		}
		// branch for IE/Windows ActiveX version
	} else if(window.ActiveXObject) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				req = false;
			}
		}
	}
	if(req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}
function processReqChange() {
	// only if req shows "loaded"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
			document.getElementById("position_order").innerHTML = req.responseText;
		} else {
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}

function open_popup(link)
{
	if (typeof(cp) == "undefined" || cp.closed) {
		cp = window.open(link, "", "left=50,top=100,width=700,height=600,scrollbars=yes,statusbar=yes");
	} else {
		cp.location.href = link;
		cp.focus();
	}
}

function open_chat(){
	if (typeof(cp) == "undefined" || cp.closed) {
		cp = window.open("./chat.php", "", "left=150,top=150,width=800,height=530,scrollbars=yes,statusbar=no");
	} else {
		cp.location.href = "./chat.php";
		cp.focus();
	}
}

function open_chat_index(){
	if (typeof(cp) == "undefined" || cp.closed) {
		cp = window.open("./forum/chat.php", "", "left=150,top=150,width=800,height=530,scrollbars=yes,statusbar=no");
	} else {
		cp.location.href = "./forum/chat.php";
		cp.focus();
	}
}


function mail_popup(link, title)
{
	if (typeof(cp) == "undefined" || cp.closed) {
		cp = window.open("send_mail.php?link= "+link+"&title="+title+"", "", "left=150,top=150,width=400,height=530,scrollbars=yes,statusbar=yes");
	} else {
		cp.location.href = "send_mail.php?link= "+link+"&title="+title+"";
		cp.focus();
	}
}

function sndRequest(vote,id_num,ip_num,pag) {
	var rating = new ajax();
	rating.get('rating/rpc.php', 'j='+vote+'&q='+id_num+'&t='+ip_num+'&p='+pag, sndRequest_callback);
}

function sndRequest_callback(text){
	update = text.split('|');
	var viewer = document.getElementById(update[0]);
	viewer.innerHTML=update[1];
}







/*
function update_box_order(page_no){
loadXMLDoc("http://www.tree.ro/clients/miriapod/users/update_box_order.inc.php?id_box=" + document.banner_modify.id_box.value);
}
*/

function select_all() {

	c = document.mail["check"].checked;
	for (var i = 0; i < document.mail.elements.length; i++){
		if(document.mail.elements[i].type == 'checkbox' ){
			document.mail.elements[i].checked = c;
		}
	}
}

function validare(){

	var mail = document.mail.elements;
	var b = false;
	for(var i=0;i<mail.length;i++){

		if (mail[i].name!='undefined'){
			var m = mail[i].name.split('_');
			if( m[0] == 'mail' ){
				//				alert(mail[i].checked);
				if( mail[i].checked == true) b=true;
			}
		}
	}
	if( b == false ){
		alert('Pentru a se putea face legatura cu acest grup trebuie bifat cel putin un mail.');
		return false;
	}
	else document.mail.submit();
}

function validare_mail_form(){

	var to = document.mail_send_form.mail_to.value;

	if( document.mail_send_form.subiect.value == ''){
		alert('Subiectul trebuie completat.');
		return false;
	}
	else{
		if( confirm("Newsletterul va fi trimis la adresele introduse.\nEsti sigur ?")){
			document.mail_send_form.submit();
		}
	}
}

function newsletter_preview(){


	var t = document.mail_send_form.newsletter;
	var x = document.mail_send_form.id_text.value;
	
	var lnv1 = '';
	var u;
	
	for( var i=0;i<t.length;i++){
		if( t[0].checked ){
			u=1;
			nv = document.mail_send_form.newsletter_id.value;
			var nv1 = "&nv="+nv;
		}
		if( t[1].checked ) u=2;
		if( t[2].checked ) u=3;
		if( t[3].checked ) u=4;
	}

	var l;
	if( document.mail_send_form.includ_text.checked ){
		l = "&includ_text=1";
	}else l='';
	
	
	lnv1 = l;
	if(typeof(nv1) != "undefined"){
	lnv1= lnv1+nv1;
	}
	
	var link = "newsletter_preview.php?tip="+u+"&id_text="+x+lnv1;
	if (typeof(cp) == "undefined" || cp.closed) {
		cp = window.open(link, "", "left=50,top=100,width=750,height=600,scrollbars=yes,statusbar=yes");
	} else {
		cp.location.href = link;
		cp.focus();
	}
}

function js_back(){

	id = document.mail_send_form.id_text.value;
	window.location = "mail.php?what=create_mail&pas=1&id_text="+id;

}

function next_pict(p){

	var joc = new ajax();
	req = "what=pc";
	joc.get("games1.php", req, next_pict_callback);
	//	document.getElementById("hide_guarantor").innerHTML = text;

	//	alert(document.getElementById("PC").innerHtml);
}

function next_pict_callback(text){

	document.getElementById("PC").innerHTML = text;


}

function show_div(arg){
	var d = document.getElementById(arg);
	d.style.display="";
}

function show_sns(arg){
	if( arg == 1 ) document.getElementById("sns").style.display="";
	else document.getElementById("sns").style.display="none";
}

function change_cinema(id_cin){
	var cinema = new ajax();
	cinema.get('program_cinema.php', 'aj=1&id_localitate='+id_cin+'', change_cinema_callback);
}

function change_cinema_callback(text){
	//	alert(text);
	var cinema = text.split("\n");
	var sel = false;
//	alert(cinema[0]);
	if( typeof(cinema[0]) != "undefined" ){
		document.form_cinema.cinamatograf.options.length = 1;
		for (var i = 0; i < cinema.length - 1; i++) {
			var s = cinema[i].split("|");
			if ( typeof(s[1]) != "undefined" ){
				document.form_cinema.cinamatograf.options[i+1] = new Option(s[1], s[0]);
				if (typeof(idcinema) != "undefined" && s[0] == idcinema) {
					document.form_cinema.cinamatograf.options[i + 1].selected = true;
					sel = true;
				}
			}
		}
	}
}

function change_tara(tara){
	var tara = document.regsiterpas1.tara.value;
	if( tara == "Romania"){

		document.getElementById("showjudslct").style.display = '';
		document.getElementById("showjudinpt").style.display = 'none';

		document.getElementById("judet").id = 'judet';
		document.getElementById("localitate").id = 'localitate';

		document.getElementById("showlocslct").style.display = '';
		document.getElementById("showlocinpt").style.display = 'none';
		var aj = new ajax();
		aj.get('register.php', 'aj=1&id_tara=1', change_tara_callback);
	}else{

		document.getElementById("showjudslct").style.display = 'none';
		document.getElementById("showjudinpt").style.display = '';

		document.getElementById("judet").id = 'judet1';
		document.getElementById("localitate").id = 'localitate1';

		document.getElementById("showlocslct").style.display = 'none';
		document.getElementById("showlocinpt").style.display = '';
	}
}

function change_tara_callback(text){
	var judet = text.split("\n");
	var sel = false;
	document.regsiterpas1.judet.options.length = 1;
	for (var i = 0; i < judet.length - 1; i++) {
		var s = judet[i].split("|");
		document.regsiterpas1.judet.options[i + 1] = new Option(s[1], s[0]);
		if (typeof(judet) != "undefined" && s[0] == val_judet) {
			document.regsiterpas1.judet.options[i + 1].selected = true;
			sel = true;
		}
	}
	if( sel == true ) change_jud();
}

function change_jud(tara){

	var j = document.regsiterpas1.judet.value;
	var aj = new ajax();
	aj.get('register.php', 'aj=1&id_judet='+j+'', change_jud_callback);
}

function change_jud_callback(text){

	var loc = text.split("\n");
	var sel = false;
	document.regsiterpas1.localitate.options.length = 1;
	for (var i = 0; i < loc.length - 1; i++) {
		var s = loc[i].split("|");
		document.regsiterpas1.localitate.options[i + 1] = new Option(s[1], s[0]);
		if (typeof(loc) != "undefined" && s[0] == val_localitate ) {
			document.regsiterpas1.localitate.options[i + 1].selected = true;
			sel = true;
		}
	}
}



function val_callback(text)
{
	if (text !== ""  && text != "no_val") {
		var err1 = text.split("$$");
		for (var i = 0; i < err1.length; i++) {
			var err = err1[i].split("|");
			var el = document.getElementById(err[0]);
			try{
				el.style.color = "red";
			}
			catch(err){

			}
			if( typeof(err[1]) != "undefined"){
				ie = "err_"+err[0];
				abc = document.getElementById(ie);
				try{
					abc.innerHTML = err[1];
				}
				catch(err){
				}
			}
		}
	} else {
		if (window.confirm("The data is valid. Are you sure you want to continue?")) {
			document.forms.regsiterpas1.submit();
		}
	}
}
function validate_form()
{
	var val = new ajax();
	var el = document.getElementById("regsiterpas1").getElementsByTagName("div");
	for (var i = 0; i < el.length; i++) {
		if (el[i].id !== "") {
			try{
				el[i].style.color = "";
				el[i].onmouseover = "";
				el[i].onmouseout = "";
			}
			catch(err){
			}


		}
	}
	var el1 = document.getElementById("regsiterpas1").getElementsByTagName("span");
	for ( var j = 0;j < el1.length;j++){
		w = el1[j].id;

		x = document.getElementById(w);
		x.innerHTML = '';
	}
	var fe = document.regsiterpas1.elements;
	var req = "what=register1";
	var x = 0;
	if( fe.tara.value == "Romania" ){
		x = 1;
	}
	for (var i = 0; i < fe.length; i++) {
		if (typeof(fe[i].name) != "undefined" && fe[i].name !== "") {
			if( fe[i].name == "judet" || fe[i].name == "judet1" ){
				if( ( x == 1 && fe[i].name == "judet") || ( x == 0 && fe[i].name == "judet1" )){
					req += "&" + fe[i].name + "=" + fe[i].value;
				}
			}else if( fe[i].name == "localitate" || fe[i].name == "localitate1"){
				if( ( x == 1 && fe[i].name == "localitate") || ( x == 0 && fe[i].name == "localitate1" )){
					req += "&" + fe[i].name + "=" + fe[i].value;
				}

			}else{
				req += "&" + fe[i].name + "=" + fe[i].value;
			}
		}
	}
	val.post("val.php", req, val_callback);
	return false;
}

function getsinopsis(id,what,c){
	var val = new ajax();
	var f = id;
	var cc='';
	if( c ) cc = "&c="+c;
	val.get('newsletter.php', 'aj=1&id='+f+'&what='+what+cc+'', change_asdf_callback);

}

function change_asdf_callback(text){
	var a = text.split("||");
	var x = document.newsletter_form[a[0]].value = a[1];
}

function getstiri(id,what){
	var val = new ajax();
	var f = id;
	val.get('newsletter.php', 'aj=1&s=1&id='+f+'&what='+what+'', change_asdf_callback);
}

function dopoz(id,p){
	var val = new ajax();
	val.get("top_filme.php","aj=1&id_ajfilm="+id+"&poz="+p,dopoz_callback);
}

function dopoz_callback(text){

	document.getElementById("asd").innerHTML = text;

}

function ics(s){
	var n = s.match("[0-9]+");

	return n;
}

function salveaza_ftf(){
	var e = document.form_filme.elements;
	var f='';
	for( i=0;i<e.length;i++){
		if( e[i].type=="checkbox" && e[i].checked == true ){
			f += ics(e[i].name)+ ",";
		}
	}
	var ajx = new ajax();
	ajx.post("top_filme.php","ajx=1&sel_filme="+f,salveaza_ftf_callback)

}

function salveaza_ftf_callback(text){
	document.getElementById("asd1").innerHTML = text;
}