// mainMenu script
sfHover = function() {
	var sfEls = document.getElementById("drops").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
// mainDet script
var Lst;
function CngClass(obj)
{ 
 if (Lst) Lst.className='';
 obj.className='current';
 Lst=obj;
}
// show hide mainDet content
function show(divID)
{
	if (document.getElementById(divID))	document.getElementById(divID).style.display='block';
}

function hide(divID)
{
	if (document.getElementById(divID))	document.getElementById(divID).style.display='none';
}

function changeDetail(n)
{
	for (i=1;i<=3;i++)
	{
		if (i==n)
		{
			show('con'+i);
			if (document.getElementById('acon'+i)) document.getElementById('acon'+i).className='current';
		}
		else
		{
			hide('con'+i);
			if (document.getElementById('acon'+i)) document.getElementById('acon'+i).className='';
		}
	}
}

// Checks if a field is empty, and if so, resets the input's content to the default value
function checkField( obj, value )
{
	// Match any amount of white spaces
	if( obj.value == "" )
	{
		obj.value = value;
	}
	
	return false;
}

// Clears an input's content
function clearField( obj, value )
{
	if( obj.value == value )
	{
		obj.value = "";
	}
	
	return false;
}

function showHide(divID) 
{
	document.getElementById(divID).style.display == 'none' ? document.getElementById(divID).style.display = 'block' : document.getElementById(divID).style.display = 'none';
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function reloadWindow()
{
	window.location=window.location;
	
	return;
}

function stripPath(loc)
{
	return loc.replace(/^(((.+)\/)+)?(([\w\-_]+\.)+\w{3})$/, '$4');
}

/*pop image*/

PositionX = 10;
PositionY = 10;


defaultWidth  = '';
defaultHeight = '';


var AutoClose = true;

var opt='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function pop(src,imageTitle){
imageURL=mainWebsiteURL+'custom_images/produse/pop/'+stripPath(src);
imageTitle=((imageTitle!='') ? imageTitle : 'Bio Family');
imgWin=window.open('about:blank','',opt);
with (imgWin.document){
writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
writeln('<html><head><title>Loading...</title><style type="text/css">body{margin:0; padding:0;}</style>');
writeln('<sc'+'ript type="text/javascript">');
writeln('function reSizeToImage(){');
writeln('window.resizeTo(100,100);');
writeln('width=100+document.images[0].width;');
writeln('height=100+document.images[0].height;');
writeln('window.resizeTo(width,height);}');
writeln('function doTitle(){document.title="'+imageTitle+'";document.getElementById(\'loading\').style.display="none";}');
writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor="#ffffff" onload="reSizeToImage();doTitle();self.focus()">');
writeln('<table width="100%"><tr><td align="center" valign="middle"><p id="loading">Loading...</p><img name="Bio Family" sr' + 'c='+imageURL+' style="display:block" onclick="self.close()" /></td></tr></table></body></html>');
close();		
}}

/*end pop image*/

function confirma(caz,mes,link,stoc,link2)
{
	switch (caz)
	{
		case 'sterge':
			var sterge = confirm(decodeURIComponent(mes.replace(/\+/g,  " ")));
			if (sterge) window.location = link;
			break;
		case 'adauga':
			if (stoc != null && stoc != 0)
			{
				window.location = link;
			}
			else
			{
				var adauga = confirm(decodeURIComponent(mes.replace(/\+/g,  " ")));
				if (adauga) window.location = link2;
			}
			break;
	}
}