// display decision alert box
function decision(message, url){
	if(confirm(message)) location.href = url;
}

// open browser window
function openPopUp(url, windowName, w, h, scrollbar) {

           var winl = (screen.width - w) / 2;
           var wint = (screen.height - h) / 2;
           winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar ;
		   win = window.open(url, windowName, winprops);
           if (parseInt(navigator.appVersion) >= 4) {
              	win.window.focus();
           }
}

function jumpMenu(target,object,restore){
  eval(target+".location='"+object.options[object.selectedIndex].value+"'");
  if (restore) object.selectedIndex=0;
}

function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function getImage(imageName)
{
		findObj('img').src = imageName;
}

function submitDoc(formName) {
  var obj;

	if (obj=findObj(formName)!=null)
	{
		findObj(formName).submit();
	}
	else
	{
		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
	}
}

function GetXmlHttpObject()
{
	var xmlHttp = null;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function delete_cart_prod(prod_id)
{
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{
			var res = xmlHttp.responseText;
			window.location.reload();
		}
	}

	xmlHttp.open ("GET", base_href +"_cart_delete.php?prod=" + prod_id, true);
	xmlHttp.send (null);
}

function show_div(which)
{
	switch (which)
	{
		case "info_prod" : document.getElementById("info_prod").style.display = "block";
						document.getElementById("prod_info_btn").className = "selected";
						document.getElementById("review_prod").style.display = "none";
						document.getElementById("prod_review_btn").className = "";
						document.getElementById("tell_friend").style.display = "none";
						document.getElementById("prod_taf_btn").className = "";
						break;
		case "review_prod" : document.getElementById("info_prod").style.display = "none";
						document.getElementById("prod_info_btn").className = "";
						document.getElementById("review_prod").style.display = "block";
						document.getElementById("prod_review_btn").className = "selected";
						document.getElementById("tell_friend").style.display = "none";
						document.getElementById("prod_taf_btn").className = "";
						break;
		case "tell_friend" : document.getElementById("info_prod").style.display = "none";
						document.getElementById("prod_info_btn").className = "";
						document.getElementById("review_prod").style.display = "none";
						document.getElementById("prod_review_btn").className = "";
						document.getElementById("tell_friend").style.display = "block";
						document.getElementById("prod_taf_btn").className = "selected";
	}
}

function cus_activ(ind)
{
	var oldie = document.getElementById("cus_rat_" + cus_sel_ind);
	if (oldie)
	{
		oldie.src = oldie.src.replace("_on", "_off");
		oldie.alt = "";
	}
	cus_sel_ind = ind;
	var newbie = document.getElementById("cus_rat_" + cus_sel_ind);
	if (newbie)
	{
		newbie.src = newbie.src.replace("_off", "_on");
		newbie.alt = "on";
	}
	document.form1.stars.value = ind;
}

function check_tc(form)
{
	if (document.getElementById('id_reg_optIn1st').value == "1")
	{
		form.submit();
	}
	else
	{
		alert("Trebuie sa fiti de acord cu Termenii si conditiile de utilizare");
		return false;
	}
}

function change_check_state(el)
{
	/*var el = document.getElementById(the_el);
	if (el)
	{*/
		if (el.src.indexOf('_un.gif') >= 0)
			el.src = el.src.replace("_un.gif", ".gif");
		else
			el.src = el.src.replace(".gif", "_un.gif");
	//}
}


function checkMultiProds(formName) {

  	document.multi_prods.submit();
}


function tbSwitch(idx) {
	if(idx==1){
		document.getElementById("tab1").className="hide";
		document.getElementById("tab2").className="show";
	}
	if(idx==2){
		document.getElementById("tab1").className="show";
		document.getElementById("tab2").className="hide";
	}
}
