function expand(what)
{
	var item=document.getElementById(what);
	var over=item.getElementsByTagName('SPAN')[0];
	over.style.visibility='visible';
	over.style.position='relative';
	var link=item.getElementsByTagName('A')[0];
	link.style.visibility='hidden';
	link.style.position='absolute';
}

function toggleVisible(what)
{
	var item=document.getElementById(what);
	var title=item.getElementsByTagName('SPAN')[0];
	var form=item.getElementsByTagName('FIELDSET')[0];
	
	if(title.style.visibility!='hidden')
	{
		title.style.visibility='hidden';
		title.style.position='absolute';
		form.style.visibility='visible';
		form.style.position='relative';
	}
	else
	{
		title.style.visibility='visible';
		title.style.position='relative';
		form.style.visibility='hidden';
		form.style.position='absolute';
	}
}

function splitText(elementID, linkText)
{
	var item = document.getElementById(elementID);
	
	if(!item) return;
	
	item.customCompleteText = item.innerHTML;
	
	item.restoreCompleteText = function()
	{
		this.innerHTML = this.customCompleteText;
	}
	
	var text = item.innerHTML;
	
	for(i = 2000; i > -1; --i)
	{
		if(text.charAt(i) != ' ') 
		  continue;
		
		item.innerHTML = text.substr(0, i);
		break;
	}
	
	var link = document.createElement('A');
	link.href = 'javascript:document.getElementById(\'' + elementID + '\').restoreCompleteText();';
	link.className = 'ExpandLink';
	link.appendChild(document.createTextNode(linkText));
	item.appendChild(link);
}

function splitTextPlot(elementID, linkText)
{
	var item = document.getElementById(elementID);
	
	if(!item) return;
	
	item.customCompleteText = item.innerHTML;
	
	item.restoreCompleteText = function(){
		this.innerHTML = this.customCompleteText;
	}
	
	var text = item.innerHTML;
	
	for(i = 600; i > -1; --i)
	{
		if(text.charAt(i) != ' ') 
		  continue;
		
		item.innerHTML = text.substr(0, i);
		break;
	}
	
	var link = document.createElement('A');
	link.href = 'javascript:document.getElementById(\'' + elementID + '\').restoreCompleteText();';
	link.className = 'ExpandLink';
	link.appendChild(document.createTextNode(linkText));
	item.appendChild(link);
}

function hideAdvancedForms(sectionsToShow)
{
	var all = document.getElementById('AdvancedSearchForms');
	
	if(!all) 
	  return;
	
	if(!sectionsToShow || sectionsToShow.length == 0) 
	  sectionsToShow = '';
	else 
	  sectionsToShow = sectionsToShow.join(',');
	
	var divs = all.getElementsByTagName('DIV');
	
	var div   = null;
	var id = null;
	var title = null;
	var legend = null;
	var fieldset = null;
	var openLink = null;
	var closeLink = null;
	
	for(i = 0; i < divs.length; ++i)
	{
		div = divs[i];
		id = div.id;
		
		if(!id) 
		  continue;
		
		fieldset = div.getElementsByTagName('FIELDSET')[0];
		legend = fieldset.getElementsByTagName('LEGEND')[0];
		title = legend.firstChild.nodeValue;
		
		
		
		openLink = document.createElement('A');
		openLink.href = 'javascript: document.getElementById(\'' + id + '\').openSection();';
		openLink.appendChild(document.createTextNode(title));
		
		
		closeLink = document.createElement('A');
		closeLink.href = 'javascript: document.getElementById(\'' + id + '\').closeSection();';
		closeLink.appendChild(document.createTextNode(title));
		
		
		legend.removeChild(legend.firstChild);
		legend.appendChild(closeLink);
		
		div.insertBefore(openLink, fieldset);
		
		openLink.className = 'SetVisibleLink';
		closeLink.className = 'SetHiddenLink';
		
		div.customOpenLink = openLink;
		div.customFieldset = fieldset;
		div.openSection = function()
		{
			this.customOpenLink.style.display = 'none';
			this.customFieldset.style.display = 'block';
		}
		div.closeSection = function()
		{
			this.customOpenLink.style.display = 'inline';
			this.customFieldset.style.display = 'none';
		}
		
		if(sectionsToShow.indexOf(id) == -1)
		{
			openLink.style.display = 'inline';
			fieldset.style.display = 'none';
		}
		else
		{
			openLink.style.display = 'none';
			fieldset.style.display = 'block';
		}
	}
}

myRequest = null;

xmlhttp   = null;



var req;

function add2Cart( url, data ) 
{
	req = false;
  // branch for native XMLHttpRequest object
  if( window.XMLHttpRequest && !( window.ActiveXObject ) ) 
  {
  	try 
  	{
			req = new XMLHttpRequest();
    } 
    catch( e ) 
    {
			req = false;
    }
    // branch for IE/Windows ActiveX version
  } 
  else if( window.ActiveXObject ) 
  {
   	try 
   	{
     	req = new ActiveXObject( "Msxml2.XMLHTTP" );
    } 
    catch( e ) 
    {
     	try 
     	{
      		req = new ActiveXObject( "Microsoft.XMLHTTP" );
     	} 
     	catch( e ) 
     	{
     		req = false;
     	}
		}
   }
   if( req ) 
   {
		 req.onreadystatechange = processReqChange;
		 req.open("GET", url + "?dati=" + data, true);
		 req.send( null );
   }
}

function processReqChange() 
{
  // only if req shows "loaded"
  if( req.readyState == 4 ) 
  {
    // only if "OK"
    if( req.status == 200 ) 
    {
      // ...processing statements go here...
    } 
    else 
    {
      alert("There was a problem retrieving the XML data:\n" + req.statusText);
    }
  }
}


/*
function add2Cart( url, data ) 
{

  if (window.XMLHttpRequest)
  {
    myRequest = CreateXmlHttpReq( myHandler );
    myRequest.open( "GET", url + "?dati=" + data );

    myRequest.send( null );
  }
  else if( window.ActiveXObject )
  {
    xmlhttp = new ActiveXObject( "MSXML2.XMLHTTP.3.0" )
    xmlhttp.open( "GET", url + "?dati=" + data );
    xmlhttp.send();
    alert( xmlhttp.statusText );
  }

  if( xmlhttp )
  {
    xmlhttp.onreadystatechange = xmlhttpChange;
    xmlhttp.open( "GET", url + "?dati=" + data );
    xmlhttp.send( null );
  }
}

*/

function CreateXmlHttpReq( handler ) 

{

  xmlhttp                    = new XMLHttpRequest();

  xmlhttp.onreadystatechange = handler;

  return xmlhttp;

}


function xmlhttpChange()
{
// if xmlhttp shows "loaded"
  if (xmlhttp.readyState==4)
  {
    if (xmlhttp.status==200)
    {
    // ...il vostro codice...
    }
  }
}


function myHandler() 

{

  if( myRequest.readyState == 4 && myRequest.status == 200 ) 

	{

/*
    e           = document.getElementById('BuyPanel');
    e.innerHTML = '<A href="#"CLASS="ShoppingCart" REL="nofollow" style="background-image: url(/img/dvdmusica_buypanelfull_left.png);" onclick="add2Cart( \'[domain]/add2Cart.php\', \'[ProductID]|[SessionId]\' );">[BuyProductLabel]:</A>\n' +

		              '<DIV CLASS="AvailabilityStatus">[ProductAvailabilityStatus]</DIV>\n' +

		              '<DIV CLASS="ProductPrice">[ProductPrice]</DIV>\n' + 

		              '<DIV CLASS="floatBreaker">&nbsp;</DIV>\n';
*/
  }

}

/*
function openwin( url, sid )
{
  
  myWin = window.open ( url + "/LoginRegistration.php?session_id="+sid,"Login / Registrazione","status=1,toolbar=0,scrollbars=0,location=0,directories=0,resizable=0,width=600,height=400");
	myWin = myWin.moveTo(100,100);
}
*/
function openwin( url )
{
  
  javascript:winopen2(url,'popup600x400','WIDTH=600,HEIGHT=400,RESIZABLE=NO,SCROLLBARS=YES,TOOLBAR=NO,STATUS=NO,MENU=NO,LEFT=0,TOP=0');
}
function winopen2(url,stuff,morestuff)
{
	var popwin = window.open(url,stuff,morestuff);
	if( typeof(popwin) != "undefined" && popwin )
	{
		popwin.focus();
	}
}

function flvFPW1(){
var v1=arguments,v2=v1[2].split(","),v3=(v1.length>3)?v1[3]:false,v4=(v1.length>4)?parseInt(v1[4]):0,v5=(v1.length>5)?parseInt(v1[5]):0,v6,v7=0,v8,v9,v10,v11,v12,v13,v14,v15,v16;
	v11=new Array("width,left,"+v4,"height,top,"+v5);
	for (i=0;i<v11.length;i++){
		v12=v11[i].split(",");
		l_iTarget=parseInt(v12[2]);
		if (l_iTarget>1||v1[2].indexOf("%")>-1){
			v13=eval("screen."+v12[0]);
			for (v6=0;v6<v2.length;v6++){
				v10=v2[v6].split("=");
				if (v10[0]==v12[0]){
					v14=parseInt(v10[1]);
					if (v10[1].indexOf("%")>-1){
						v14=(v14/100)*v13;
						v2[v6]=v12[0]+"="+v14;
					}
				}
				if (v10[0]==v12[1]){
					v16=parseInt(v10[1]);
					v15=v6;
				}
			}
			if (l_iTarget==2){
				v7=(v13-v14)/2;
				v15=v2.length;
			} else if (l_iTarget==3){
				v7=v13-v14-v16;
			}
			v2[v15]=v12[1]+"="+v7;
		}
	}
	v8=v2.join(",");
	v9=window.open(v1[0],v1[1],v8);
	if (v3){
		v9.focus();
	}
	document.MM_returnValue=false;
	return v9;
}




