function openUp(x, y, adress, name) 
{	
	var newOpenUp = window.open(adress, name, 'width=' + x + ', height=' + y + 'resizable=no, scrollbars=yes, menubar=no, location=no, status=no, screenX=1, screenY=1');
	newOpenUp.focus();
}

function doFormFocus(obj) {
	if (obj.value == obj.defaultValue) obj.value = '';
}

function doFormBlur(obj) {
	if (obj.value == '') obj.value = obj.defaultValue;
}

function openMailPopup(page)
{
	mailWindow = window.open('mail.php?page=' + page,'Mail','width=400,height=300,toolbar=No,location=No,scrollbars=Yes,status=No,resizable=No,fullscreen=No');
}


function openPostPopup(category)
{
	mailWindow = window.open('question.php?category=' + category,'intrebari','width=350,height=350,toolbar=No,location=No,scrollbars=Yes,status=No,resizable=No,fullscreen=No');
}


function checkSearch(form, message, defaultValue)
{
	if (form.search.value.length < 3) {
		alert(message);
		return false;
	}
	
	if (form.search.value == defaultValue) {
		return false;
	}
	
	return true;
}


function validateSearchFieldsPage(form)
{
	if (form.search.value.length < 3) {
		alert('Va rugam sa introduceti o expresie mai lunga de 3 carcactere!');
		return false;
	}
	
	if (form.search.value == 'cauta in site') {
		alert('Va rugam sa introduceti termenii de cautati!');
		return false;
	}
	
	return true;
}

	
function checkEmail(e) {
	ok = '1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM';

	for(i = 0; i < e.length; i++){
		if(ok.indexOf(e.charAt(i)) < 0)
			return (false);
	} 

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two))
			return (-1);
	}
}


function verifyEmail(form, message)
{
	if (!checkEmail(form.email.value)) {
		alert(message);
		return false;
	}
}

function verifyEmailN(form, message)
{
	if (!checkEmail(form.email.value)) {
		alert(message);
		return false;
	}
}



function getURL(mode, page, params)
{
	if (page == "")
		return host + (!mode ? 'index.php' : '') + (params && params != '' ? (params.substr(0, 1) != '#' ? '&' : '') + params : '');
	
	return host + (!mode ? 'index.php?page=' : '') + (mode ? '' : '') + page + (mode ? '.html' : '') + (params && params != '' ? (params.substr(0, 1) != '#' ? '&' : '') + params : '');
}
