/**
 * Funzioni per la gestione del rollover dei bottoni...
 *
 *
 */

function buttonUP(what)
{
	OldImage = what.src;
	NewImage = OldImage.replace("UP","DOWN");
	what.src = NewImage;
}

function buttonDOWN(what){
	OldImage = what.src;
	NewImage = OldImage.replace("DOWN","UP");
	what.src = NewImage;
}

function buttonDOWNfile(what, MyFile)
{
	what.src = MyFile;
}

function askDuplicateRowBasket(IdBasket)
{
	var answer = confirm ("Are you sure to duplicate the row ?")
  if (answer)
	{
	javascript:document.BasketForm.Row.value=  IdBasket;
	document.BasketForm.Action.value='duplicateRow';
	document.BasketForm.submit();
	}
}

function askDeleteRowBasket(IdBasket)
{
	var answer = confirm ("Are you sure to delete the row ?")
  if (answer)
	{
	 javascript:document.BasketForm.Row.value= IdBasket;
	 document.BasketForm.Action.value='deleteRow';
	 document.BasketForm.submit();
	}
}

function askDeleteRowLightBox(IdLightBox)
{
	var answer = confirm ("Are you sure to delete the row ?")
  if (answer)
	{
	 javascript:document.LightBoxForm.Row.value= IdLightBox;
	 document.LightBoxForm.Action.value='deleteRow';
	 document.LightBoxForm.submit();
	}
}

function Recovery_Password()
{
    
	MyPage = ""
	MyPage = MyPage + "<div id='Recover'>"
	MyPage = MyPage + "<form name='RecoverPasswordForm' id='RecoverPasswordForm' action='/services/mail-password-send.asp' method='post'>"
	MyPage = MyPage + "<div id='Title'>Recover your password</div>"
	MyPage = MyPage + "<p>Write your email address used for registration in the field below. An email will be sent to this address with all your registration details.</p>"
	MyPage = MyPage + "<img class='imgLabel' src='/css/images/home/username.jpg' alt='Username' />"
	MyPage = MyPage + "<input type='text' name='Username' id='Username' /><br />"
	MyPage = MyPage + "<a id='Recover' href='javascript:check_login();'><img style='margin-left: 13px;' src='css/images/home/SignInButton.jpg' alt='Sign In' /></a>"
	MyPage = MyPage + "</form>"
	MyPage = MyPage + "</div>"


	document.getElementById('Panel-1-1-C').innerHTML = MyPage
}

function Recovery_Password_Archive()
{
    
	MyPage = ""
	MyPage = MyPage + "<div id='Recover'>"
	MyPage = MyPage + "<form name='RecoverPasswordForm' id='RecoverPasswordForm' action='/services/mail-password-send.asp' method='post'>"
	MyPage = MyPage + "<div id='Title'>Recover your password</div>"
	MyPage = MyPage + "<p>Write your email address used for registration in the field below. An email will be sent to this address with all your registration details.</p>"
	MyPage = MyPage + "<img class='imgLabel' src='/css/images/home/username.jpg' alt='Username' />"
	MyPage = MyPage + "<input type='text' name='Username' id='Username' /><br />"
	MyPage = MyPage + "<a id='Recover' href='javascript:check_login();'><img style='margin-left: 13px;' src='css/images/home/SignInButton.jpg' alt='Sign In' /></a>"
	MyPage = MyPage + "</form>"
	MyPage = MyPage + "</div>"


	document.getElementById('AlphaSignInPanel').innerHTML = MyPage
}

function PrivacyAgreement()
{
  document.getElementById("PrivacyAgreement").style.visibility = "visible";
}

function ClosePrivacyAgreement()
{
  document.getElementById("PrivacyAgreement").style.visibility = "hidden";
}

function Guide_Button(Selected, Lingua)
{
  if (Selected == 1) {document.getElementById("Guide-Button1").src = '/css/images/aboutus/guide slices/Find_UP_' + Lingua + '.gif' } else {document.getElementById("Guide-Button1").src = '/css/images/aboutus/guide slices/Find_DOWN_' + Lingua + '.gif' }
  if (Selected == 2) {document.getElementById("Guide-Button2").src = '/css/images/aboutus/guide slices/Crop_UP_' + Lingua + '.gif' } else {document.getElementById("Guide-Button2").src = '/css/images/aboutus/guide slices/Crop_DOWN_' + Lingua + '.gif' }
  if (Selected == 3) {document.getElementById("Guide-Button3").src = '/css/images/aboutus/guide slices/Images_UP_' + Lingua + '.gif' } else {document.getElementById("Guide-Button3").src = '/css/images/aboutus/guide slices/Images_DOWN_' + Lingua + '.gif' }
  if (Selected == 4) {document.getElementById("Guide-Button4").src = '/css/images/aboutus/guide slices/Prices_UP_' + Lingua + '.gif' } else {document.getElementById("Guide-Button4").src = '/css/images/aboutus/guide slices/Prices_DOWN_' + Lingua + '.gif' }
  
  if (Selected == 1) { getGuidePreview('/inc/guide-find.asp?L='+ Lingua); }
  if (Selected == 2) { getGuidePreview('/inc/guide-crop.asp?L='+ Lingua); }
  if (Selected == 3) { getGuidePreview('/inc/guide-images.asp?L='+ Lingua); }
  if (Selected == 4) { getGuidePreview('/inc/guide-prices.asp?L='+ Lingua); }
}


function Chiudi_Tutti_Nodi(currnodo)
{
 var menu = document.getElementById('Menu');
 var nodi = getElementsByAttribute(menu, 'a', 'idnodopadre', currnodo.getAttribute('idnodo'));
  for(var i=0; i<nodi.length; i++){
	nodo = nodi[i];
	Chiudi_Tutti_Nodi (nodo);
    nodo.style.display = 'none';
  }
}

function Show_Nodes_2 (padre)
{
  padre.parentNode.innerHTML = padre.parentNode.innerHTML + "<div id='Pippo' class='Node'><a  href='#' onClick='Show_Nodes_2(this);'>Test</a></div>";
}
function Show_Nodes (padre)
{
	 
	 var menu = document.getElementById('Menu');
	 var nodi = getElementsByAttribute(menu, 'a', 'idnodopadre', padre.getAttribute('idnodo'));
	 var nodo;
	 for(var i=0; i<nodi.length; i++){
		 nodo = nodi[i];
		 var livello = nodo.getAttribute('livello');
		 var livello2 = livello * 5;
		 var larghezza = 275 - livello2;
		 var padding = livello2;
		 larghezza = larghezza + 'px'
		 padding = padding + 'px'
		 if(nodo.style.display == 'block') 
		  { 
			Chiudi_Tutti_Nodi (nodo);
		    nodo.style.display = 'none';
		  } 
		 else 
		  {
		    nodo.style.display = 'block';
			nodo.style.width = larghezza;
			nodo.style.paddingLeft = padding;
			nodo.style.backgroundColor = "#cccc11";
			if (padre.getAttribute('idnodopadre') != 0) {padre.className = 'NodeOpened'};
		  };
	}
}


function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}