//javascript resource

function OpenWin(new_location)
{
	window.opener.location = new_location;
}

function RefreshProdCompare(pr,ca)
{
	wi = document.getElementById('sel_prod').value;
	new_location = "comparaprodusul"+pr+"_cuprodusul"+wi+"_dincat"+ca+".htm";

	document.location = new_location;
}

function LaunchProdCompare(idprod)
{
	new_location = "comparaprodusul"+idprod+"_cuprodusul0_dincat0.htm";
	PopComparer(new_location);
}



function PopComparer(loc) {
	popWin = window.open(loc,'nav_win','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=750,height=500,left=200,top=100');
}

function IncreaseProd(idprod)
{
	new_location = "shopping_actions.php?action=add&idprod="+idprod;
	document.location = new_location;
}
function DecreaseProd(idprod)
{
	new_location = "shopping_actions.php?action=dec&idprod="+idprod;
	document.location = new_location;
}


function validateLoginForm()
{
	var allOK = true;
	var errMsg = "";
	//verifica daca userul si-a scris corect adresa de e-mail
	if(document.getElementById('uname').value.indexOf('@')<3 || document.getElementById('uname').value.indexOf('.')<5)
		{
			allOK=false;
			errMsg +='\nAdresa e-mail este incorecta';
		}
	//apoi daca parola e bagata
	if(document.getElementById('upass').value=="") 
		{
			allOK=false;
			errMsg +='\nParola trebuie completata';
		}
	//si daca confirmarea coincide cu ce a bagat
	if(document.getElementById('upass').value != document.getElementById('upaco').value) 
		{
			allOK=false;
			errMsg +='\nParola trebuie sa fie aceeasi in campul de confirmare';
		}
	//si vezi daca a bifat kestiunea
	if(document.getElementById('cond').checked == false)
		{
			allOK=false;
			errMsg +='\nTrebuie sa bifati ca sunteti de acord cu conditiile de inscriere';
		}
	
	if(allOK) 
		document.newacc.submit();
	else
		alert("NU POT CONTINUA DEOARECE:\n"+errMsg);
}

function switchCheckbox(chkName)
{
	if(document.getElementById(chkName).checked == false)	
		document.getElementById(chkName).checked = true;
	else
		document.getElementById(chkName).checked = false;
}

function switchDiv(divName)
{
	var myDiv = document.getElementById(divName);
	if(myDiv != null)
		myDiv.style.display = (myDiv.style.display=='none' ? 'block' : 'none');
}

function catchEnter()
{ 
	if(event.keyCode==13)
	{ // enter key on src text
		document.location=('rezultate_cautare.php?query='+document.getElementById('srctext').value);
	}
}


function PopWin(loc) {
	popWin = window.open(loc,'nav_win','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=600,left=200,top=100');
	//alert('pop done');
}

function switchbgr(objTD)
	{
	if(objTD.className=='btnON')
		{
		objTD.className='btnOFF';
		//and change link class
		if(typeof(objTD.firstChild.className) != 'undefined')
				objTD.firstChild.className='whitelink';
		}
	else
		{
		objTD.className='btnON';
		//and change link class
		if(typeof(objTD.firstChild.className) != 'undefined')
				objTD.firstChild.className='bluelink';
		}
	}
	
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
	{
	   var arVersion = navigator.appVersion.split("MSIE")
	   var version = parseFloat(arVersion[1])
	   if ((version >= 5.5) && (document.body.filters)) 
	   {
		  for(var i=0; i<document.images.length; i++)
		  {
			 var img = document.images[i]
			 var imgName = img.src.toUpperCase()
			 if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			 {
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText 
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				img.outerHTML = strNewHTML
				i = i-1
			 }
		  }
	   }    
	}
window.attachEvent("onload", correctPNG);


