
var popUpWin = null;

isDOM=(document.getElementById);
isMac = (navigator.appVersion.indexOf("Mac")!=-1);
isOpera=(window.opera && isDOM);
isIE= (document.all && document.all.item && !isOpera);
isIEMac = (document.all && isMac);
isFirefox = (navigator.userAgent.indexOf('Firefox') != -1);

function comenziWindow(sess_id, lang){
	var url = 'situatia_comenzilor.html?SESSION_ID=' + sess_id;
	if(lang != 'ro') {
		url = '/' + lang + '/' + url;
	}
	
	var w = 1200, h = 400;

	//pt. IE: trebe mai inalt:
	//if(isIE)	h = 162;
	//pt. Opera, trebe mai mic... ce naspa faza asta...
	//if(isOpera)	h = 150;

	var xPos = Math.round((screen.width -  w) / 2);
	var yPos = Math.round((screen.height - h) / 2);
	var config = 'hotkeys=no , menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no';
	win = self.open(url, 'comenzi', 'height=' + h + ',width=' + w + ',screenX=' + xPos + ',screenY=' + yPos +
										',left=' + xPos + ',top=' + yPos + config);
	win.focus();
	win.opener = self;

	return win;	//in caz ca...
}

function loginWindow(sess_id, lang){
	
	var url = 'login.html?SESSION_ID=' + sess_id;
	if(lang != 'ro') {
		url = '/' + lang + '/' + url;
	}
	
	var w = 290, h = 155;

	//pt. IE: trebe mai inalt:
	if(isIE)	h = 162;
	//pt. Opera, trebe mai mic... ce naspa faza asta...
	if(isOpera)	h = 150;
	
	var xPos = Math.round((screen.width -  w) / 2);
	var yPos = Math.round((screen.height - h) / 2);
	var config = 'hotkeys=no , menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no';

	win = open(url, 'login', 'height=' + h + ',width=' + w + ',screenX=' + xPos + ',screenY=' + yPos +
										',left=' + xPos + ',top=' + yPos + config);
	win.focus();
	win.opener = self;

	return win;	//in caz ca...
}

function search_help(){
	var url = 'catalog%20help/cautare.htm';
	var w = 350, h = 310;

	var xPos = Math.round((screen.width -  w) / 2);
	var yPos = Math.round((screen.height - h) / 2);
	var config = 'hotkeys=no , menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no';
	win = self.open(url, 'login', 'height=' + h + ',width=' + w + ',screenX=' + xPos + ',screenY=' + yPos +
										',left=' + xPos + ',top=' + yPos + config);
	win.focus();
	win.opener = self;

	return false;
}

function grupe_help(){
	var url = 'catalog%20help/grupe.htm';
	var w = 350, h = 210;

	var xPos = Math.round((screen.width -  w) / 2);
	var yPos = Math.round((screen.height - h) / 2);
	var config = 'hotkeys=no , menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no';
	win = self.open(url, 'login', 'height=' + h + ',width=' + w + ',screenX=' + xPos + ',screenY=' + yPos +
										',left=' + xPos + ',top=' + yPos + config);
	win.focus();
	win.opener = self;

	return false;
}

function articole_help(){
	var url = 'catalog%20help/articole.htm';
	var w = 800, h = 600;

	var xPos = Math.round((screen.width -  w) / 2);
	var yPos = Math.round((screen.height - h) / 2);
	var config = 'hotkeys=no, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no';
	win = self.open(url, 'login', 'height=' + h + ',width=' + w + ',screenX=' + xPos + ',screenY=' + yPos +
										',left=' + xPos + ',top=' + yPos + config);
	win.focus();
	win.opener = self;

	return false;
}

function looseRadio(){
	var arr = document.forms[0].domeniu_activitate;
	arr[0].checked = false;
	arr[1].checked = false;
	arr[2].checked = false;
	arr[3].checked = false;
	arr[4].checked = false;
	arr[5].checked = false;
	arr[6].checked = false;

	return true;
}

function openPicture(i, lang){
	var url = 'poza_' + i + '.html';
	if(lang != 'ro') {
		url = '/' + lang + '/' + url;
	}

	l	= window.screen.width/2 - 320;
	t		= window.screen.height/2 - 265;
	w	= 640;
	h	= 530;

	addons = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width=' 
					+ w + ',height=' + h + ',left=' + l + ',top=' + t + ',screenX=' + l + ',screenY=' + t;
	window.popUpWin = window.open(url, 'popUpWin', addons);

	if(!window.popUpWin.opener)
		window.popUpWin.opener = self;

	return true;
}

function set_cookie(name, value){
	var expire = new Date();
	expire.setTime(new Date().getTime() + (3600000 * 24 * 90));		//3 luni de zile ajung...

	document.cookie = name + '=' + value + ';expires=' + expire.toGMTString() + ';path=/';
}

function del_cookie(name){
	var expire = new Date();
	expire.setTime(new Date().getTime() - (3600000 * 24));	//setam data 'in spate'

	document.cookie = name + '=;expires=' + expire.toGMTString() + ';path=/';
}

function reset_cats(){
	var elem = self.parent.frame_categorii.last_option;

	if(!elem)	return true;

	elem.style.color = '';
	return true;
}

function reload_cats(obj){
	if(!obj.checked)	return;
	url = 'frame_categorii_abc.html?where=' + obj.value;
	self.parent.frame_categorii.location.href = url;
}
