var Lst;
function CngClass(obj){
 if (Lst) Lst.className='';
 obj.className='current';
 Lst=obj;
}

function show(divID)
{
	document.getElementById(divID).style.display='block';
}

function hide(divID)
{
	document.getElementById(divID).style.display='none';
}

function showHide(divID) 
{
	document.getElementById(divID).style.display == 'none' ? document.getElementById(divID).style.display = 'block' : document.getElementById(divID).style.display = 'none';
}

function stripPath(loc)
{
	return loc.replace(/^(((.+)\/)+)?(([\w\-_]+\.)+\w{3})$/, '$4');
}

// Change the picture
function changePic(newSrc,nr)
{
	document.getElementById('bigPic').src=mainWebsiteURL+'custom_images/produse/'+stripPath(newSrc);
}

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 closeWindow(Id)
{
	document.getElementById(Id).style.display = "none";
}

// 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 == "" )
	{
		obj.value = value;
	}
	
	return false;
}

// Clears an input's content
function clearField( obj, value )
{
	if( obj.value == value )
	{
		obj.value = "";
	}
	
	return false;
}