
function openDivPopup(title, myurl, mydata, label)
{
	$.ajax({
		method: "get", url: myurl, data: mydata,
		beforeSend: function() {
			var pos = f_scrollTop();
			
			$("#fullscreen").show(500);
			
			$("#popup_container").css("top", pos + f_clientHeight() / 2 - 300);
			$("#popup_container").show(500);
			$("#popup_title").html(title);
			$("#popup_content").html("<img src='images/busy.gif' /> Incarcare date...<br/><br/><a href='#inchide' onclick='closePopup(\"" + label + "\"); return false;' class='button2'>Inchide</a>"); 
		}, 
		complete: function() {}, 
		success: function(html) {
			$("#popup_title").html(title);
			$("#popup_content").html(html);
			$("#close_popup").html("<a href='#inchide' onclick='closePopup(\"" + label + "\"); return false;' class='button2'>Inchide</a>");
		}
	});
}


function openPopup(x, y, adress, name) {
	
	var newopenPopup = window.open(adress, name, 'width=' + x + ', height=' + y + 'resizable=no, scrollbars=yes, menubar=no, location=no, status=no, screenX=1, screenY=1');
	newopenPopup.focus();
}

function openPopup1(x, y, adress, name) {
	
	var newopenPopup = window.open(adress, name, 'width=' + x + ', height=' + y + 'resizable=no, scrollbars=no, menubar=no, location=no, status=no, screenX=1, screenY=1');
	newopenPopup.focus();
}

function openPopup2(x, y, adress, name) {
	
	var newopenPopup = window.open(adress, name, 'width=' + x + ', height=' + y + 'resizable=yes, scrollbars=no, menubar=no, location=no, status=no, screenX=1, screenY=1');
	newopenPopup.focus();
}


function getBrowser()
{
	var browserName = navigator.appName; 
	if (browserName == "Netscape")
		return "mozilla";
	else 
	if (browserName == "Microsoft Internet Explorer")
		return "ie";
	else
		return "other";
}

function closePage(page)
{
	win=window.opener;
	win.document.location.href = page;
	window.close();
	win.focus();
}

function doFormFocus(obj) {
	if (obj.value == obj.defaultValue) 
		obj.value = '';
}

function doFormBlur(obj) {
	if (obj.value == '') obj.value = obj.defaultValue;
}



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 verifyEmailMsg(form, message)
{
	if (!checkEmail(form.email.value)) {
		alert(message);
		return false;
	}
}


// shopping kart
function checkAll(form, kartCnt)
{
	for (i = 0; i < kartCnt; i++) {
		var x = document.getElementById('id' + i);
		x.checked = form.selall.checked;
	}
}


function doTotalPrice(form, kartCnt)
{
	var total = 0;
	
	/*for (i = 0; i < kartCnt; i++) {
		var price = eval('form.price' + i);
		var qty = eval('form.qty' + i);
		var totalPrice = eval('form.total_price' + i);
		//alert(price.value);
		totalPrice.value = parseFloat(qty.value) * parseInt(price.value);
		total += parseInt(qty.value) * parseInt(price.value);
	}
	
	form.total.value = total;*/
}


function jumpToAnchor(anchor)
{
	//if (location.hash == '') 
	location.hash = anchor;
}



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 : '');
}


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;
}