// JavaScript Document
var CampFocusBG = "#66CCFF";
var CampBlurBG = "#FFFFFF";

function toBlur(obj){
	obj.style.backgroundColor = CampBlurBG;
}

function toFocus(obj){
	obj.style.backgroundColor = CampFocusBG;
}

function GetObj(gobj){ // determina obiectul dupa ID
	var obj=document.getElementById(gobj);
	return obj;
}

function GetGrupa(selObj){
	//alert(selObj.selectedIndex);
	var grupa = selObj.options[selObj.selectedIndex].grupa;
	GetObj('NR').value = grupa;
}

var copie = new Array();
var dispWindow = null;
/*
function getPoza(obj){
	nr = GetObj(obj).value;
	alert(nr);
	dispWindow = window.open('upload.php?NR='+nr,'U','scrollbars=no,menubar=no,height=450,width=650,resizable=yes,toolbar=no,location=no,status=no');
}
*/

function getPoza(obj){
	dispWindow = window.open('upload.php?ob='+obj,'U','scrollbars=no,menubar=no,height=250,width=250,resizable=yes,toolbar=no,location=no,status=no');
}

function openImg(zoomUrl, imageUrl, width, height) {
    var int_windowLeft = (screen.width - width) / 2;
    var int_windowTop = (screen.height - height) / 2;
    var newWindow = window.open(
            zoomUrl + '&imgUrl=' + imageUrl,
            'ZOOM',
            'scrollbars=auto,left=' + int_windowLeft + ',top=' + int_windowTop + ',width=' + width + ',height=' + height + ',resizable=1,toolbar=0,location=0,directories=0,status=0,menubar=0,copyhistory=0'
            );
    if (document.images) {
        newWindow.focus();
    }
}

function cautBlur(camp){
	if(camp.value =="")
		camp.value = "Cautare..."
}

function cautFocus(camp){
	//if( camp.value=="Cautare...")
		camp.value = "";
	
}


function getObjCode(objID){
	var d = new Date();
	var t = d.getTime();
	var zz = d.getDate();
	var ll = d.getMonth()+1;
	var aa = d.getFullYear();
	var hh = d.getHours();
	var mm = d.getMinutes() + "";
	var ss = d.getSeconds() + "";
	ll = ll+"";
	if(ll.length == 1)
		ll = "0"+ll;
	if(mm.length == 1)
		mm = "0"+mm;
	if(ss.length == 1)
		ss = "0"+ss;		
		
	GetObj(objID).value = t;
	GetObj('data').value = aa + "-" + ll + "-" + zz + " " + hh + ":" + mm + ":" + ss;
	//alert(GetObj('data').value);
}

function addComment(a, b){
	var width = 460;
	var height = 540;
	var CommUrl = 'http://ziar.bistriteanu.ro/comentariu.php?a=' + a + '&b=' + b;
	var int_windowLeft = (screen.width - width) / 2;
    var int_windowTop = (screen.height - height) / 2;
    var newWindow = window.open(
            CommUrl,
            'Comentarii',
            'scrollbars=auto,left=' + int_windowLeft + ',top=' + int_windowTop + ',width=' + width + ',height=' + height + ',resizable=0,toolbar=0,location=0,directories=0,status=0,menubar=0,copyhistory=0'
            );
    if (document.images) {
        newWindow.focus();
    }
}

function renuntaForm(){

	window.close();
}

function chkForm(formID){
	var nume = GetObj('nume');
	var email = GetObj('email');
	var subiect = GetObj('subiect');
	var comentariu = GetObj('comentariu');
	var errmsg ='Urmatoarele campuri sunt Obligatorii:\n';
	if(nume.value.length == 0 || nume.value == ' ')
		errmsg +="   NUME - este gol.\n";
		
	if(!(email.value.indexOf(".") > 2) && !(email.value.indexOf("@") > 0))
		errmsg +="   EMAIL - format incorect.\n";
	if(subiect.value.length == 0 || subiect.value == ' ')
		errmsg +="   SUBIECT - este gol.\n";
	if(comentariu.value.length == 0 || comentariu.value == ' ')
		errmsg +="   COMENTARIU - este gol.\n";
	
	if(errmsg == 'Urmatoarele campuri sunt Obligatorii:\n')
		document.comment.submit()
	else
		alert(errmsg);

}

// ------------------------------------------ [ ANUTURI ] -------------------------------------------------
 
function addAnunt(a){ // a - cod Categorie
	var width = 400;
	var height = 340;
	var CommUrl = 'http://ziar.bistriteanu.ro/anunturi_intro.php?a=' + a;
	var int_windowLeft = (screen.width - width) / 2;
    var int_windowTop = (screen.height - height) / 2;
    var newWindow = window.open(
            CommUrl,
            'Anunturi',
            'scrollbars=auto,left=' + int_windowLeft + ',top=' + int_windowTop + ',width=' + width + ',height=' + height + ',resizable=0,toolbar=0,location=0,directories=0,status=0,menubar=0,copyhistory=0'
            );
    if (document.images) {
        newWindow.focus();
    }
}

function btnAdaugAnunt(formID){
	var txtAnunt = GetObj('txtanunt');
	var subForm = GetObj(formID);
	var errmsg = ''
	if(txtAnunt.value.length == 0 || txtAnunt.value == ' ')
		errmsg ="   Text Anut - este gol.\n";
	
	if(errmsg == ''){
		subForm.action = 'anunturi_insert.php';
		subForm.submit();
	}
	else
		alert(errmsg);
}

function cautaAnunt(formID, codCat){
	var subForm = GetObj(formID);
	subForm.action = 'anunturi.php?id='+codCat;
	subForm.submit();
}

// ------------------------------------------ [  GATA _ - _ ANUTURI ] -------------------------------------------------



function updateChar(elemSizebox, textarea, size) {
    if (size > 500) {
        alert("EROARE! Comentariul contine " + size + " caractere si depaseste dimensiunea maxima de 500 de caractere!");
        textarea.value = textarea.value.substr(0, 500);
        return;
    }
    var sizebox = GetObj(elemSizebox);
    if (sizebox) {
        sizebox.value = 500-size + ' caractere ramase';
    }
}




function goArhiva(){
	var arhivaPage = "http://www.bistriteanu.ro/arhiva/";
	document.location = arhivaPage

}