function openTab(idshow, idhide) {
	$(idshow).style.display = "block";
	$(idhide).style.display = "none";
}

function anuntaPrieten(pid) {
	var win = window.open("/index.php?module=etc&action=alert_friend&product=" + pid, "anunta", "width=400, height=300, scrollbars=yes, resizable=yes, menubar=no, status=no, location=no");
	win.focus();
}

function printPage() {
	window.print();
}

function errorReport(pid) {
	var win = window.open("/index.php?module=etc&action=report_bug&product=" + pid, "raporteaza", "width=400, height=450, scrollbars=yes, resizable=yes, menubar=no, status=no, location=no");
	win.focus();
}

function showOrders() {
	if($("myorders").style.display == "block")
		$("myorders").style.display = "none";
	else
		$("myorders").style.display = "block";
}

function setOrderNrValue(val) {
	$("orderNr").value = val;
	$("myorders").style.display = "none";
}

/* Popup / Select */
function showSelectList(id) {
	if($(id).style.display == "block")
		$(id).style.display = "none";
	else
		$(id).style.display = "block";
}

function setSelectListKey(id, val, id2, val2) {
	$(id).value = val;
	$(id2).value = val2;
	var idlist = id.split('Key');
	$(idlist[0]).style.display = "none";
}

function redirect(pag) {
	document.location.href = pag;
}

var taxa = {
	show: function(taxa, sctotal) {
		//$("scTaxa").style.display = "block";
		$("taxa_ramburs").value = taxa;
		//$("cart_total").innerHTML = sctotal;
        $("cart_total2").innerHTML = sctotal;
        $("modalitate_de_transport").setStyle('display', 'block'); 
		//$("cart_total3").innerHTML = sctotal;
        
	},
	hide: function(sctotal) {
		//$("scTaxa").style.display = "none";
		$("taxa_ramburs").value = "";
		//$("cart_total").innerHTML = sctotal;
		$("cart_total2").innerHTML = sctotal;
        $("modalitate_de_transport").setStyle('display', 'none');
		//$("cart_total3").innerHTML = sctotal;
	}
}

function validSupportCommentForm(frm) {
	var f1 = frm.commentName.value;
	var f2 = frm.commentContent.value;
	var error = "";
	if(f1 == "") {
		error += "Campul NUME nu este completat!\n";
	}
	if(f2 == "") {
		error += "Campul MESAJUL nu este completat!\n";
	}
	if(error != "") {
		alert(error);
	}
}

// Product details
function showPDElements(elm) {
	switch(elm) {
		case "imgs":
			$("movs").style.display = "none";
			$("imgs").style.display = "block";
			break;
		case "movs":
			$("imgs").style.display = "none";
			$("movs").style.display = "block";
			break;
	}
}
function setBigImage(imgPath) {
	$("bigImage").src = imgPath;
}

function scrollmap(pos) {
	var initTop = $("map").style.marginTop.replace("px", "");
	var initLeft = $("map").style.marginLeft.replace("px", "");
	var step = 10;
	
	switch(pos) {
		case "up":
			topVal = parseInt(initTop) - step;
			$("map").style.marginTop = topVal + "px";
			break;
		case "down":
			downVal = parseInt(initTop) + step;
			$("map").style.marginTop = downVal + "px";
			break;
		case "left":
			leftVal = parseInt(initLeft) - step;
			$("map").style.marginLeft = leftVal + "px";
			break;
		case "right":
			rightVal = parseInt(initLeft) + step;
			$("map").style.marginLeft = rightVal + "px";
			break;
	}
}

/* Shopping Cart Qty +/- */
var scqty = {
	increase: function(fld) {
		var op = $(fld).value;
		$(fld).value = parseInt(op) + 1;
	},
	decrease: function(fld) {
		$(fld).value -= 1;
		if($(fld).value == 0)
			$(fld).value = 1;
	}
}

/* Overlay Alert */
function showOverlay() {
	$("overlay").style.display = "block";
}
function closeOverlay() {
	$("overlay").style.display = "none";
}
function showBody() {
    $("alertBody").style.display = "block";
}
function closealerBody() {
    $("alertBody").style.display = "none";
}

function goToHomepage() {
    window.location = "/";
}


/* Tooltip */
/*
var tooltip = {
	show: function(name, model, price) {
		$("tootipTitle").innerHTML = name;
		$("tooltipModel").innerHTML = model;
		$("tooltipPrice").innerHTML = price;
		$("tooltip").style.display = "block";
	},
	hide: function() {
		$("tootipTitle").innerHTML = "";
		$("tooltipModel").innerHTML = "";
		$("tooltipPrice").innerHTML = "";
		$("tooltip").style.display = "none";
	}
}

var tooltip2 = {
	show: function(name, description) {
		$("tooltip2Name").innerHTML = name;
		$("tooltip2Desc").innerHTML = description;
		$("tooltip2").style.display = "block";
	},
	hide: function() {
		$("tooltip2Name").innerHTML = "";
		$("tooltip2Desc").innerHTML = "";
		$("tooltip2").style.display = "none";
	}
}
*/

function put_address(i)
{
	document.getElementById('address').value = document.getElementById('address_' + i).innerHTML;
	document.getElementById('zipcode').value = document.getElementById('zipcode_' + i).innerHTML;
	document.getElementById('city').value = document.getElementById('city_' + i).innerHTML;
	document.getElementById('state').value = document.getElementById('state_' + i).innerHTML;
	
	document.getElementById('addrid').value = i;
	document.getElementById('action').value = "edit";
	document.getElementById("add_address").className = "aplica";
}


function put_firms(i)
{
	document.getElementById('name').value = document.getElementById('name_' + i).innerHTML;
	document.getElementById('code').value = document.getElementById('code_' + i).innerHTML;
	document.getElementById('registration').value = document.getElementById('registration_' + i).innerHTML;
	document.getElementById('bank_account').value = document.getElementById('bank_account_' + i).innerHTML;
	document.getElementById('bank_account').value = document.getElementById('bank_account_' + i).innerHTML;
	document.getElementById('bank_name').value = document.getElementById('bank_name_' + i).innerHTML;
	
	document.getElementById('addrid').value = i;
	document.getElementById('action').value = "edit";
	document.getElementById("add_address").className = "aplica";
}

// Little print_r function for Javascript
function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects 
		for(var item in arr) {
			var value = arr[item];
			
			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}





