function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

    function click0() {
        document.getElementById('boxTxt').innerHTML="Duis neque magna, dapibus dapibus, pretium et, semper vitae, mauris. Curabitur eget dui. Praesent nec quam vitae tortor posuere rutrum...";
    }

    function click1() {
        document.getElementById('boxTxt').innerHTML="text 1&nbsp;text 1&nbsp;text 1&nbsp;text 1&nbsp;text 1&nbsp;text 1&nbsp;text 1&nbsp;text 1&nbsp;text 1&nbsp;text 1&nbsp;text 1";
    }
	
    function click2() {
        document.getElementById('boxTxt').innerHTML="text 2&nbsp;text 2&nbsp;text 2&nbsp;text 2&nbsp;text 2&nbsp;text 2&nbsp;text 2&nbsp;text 2&nbsp;text 2&nbsp;text 2&nbsp;text 2";
    }	
	
    function click3() {
        document.getElementById('boxTxt').innerHTML="text 3&nbsp;text 3&nbsp;text 3&nbsp;text 3&nbsp;text 3&nbsp;text 3&nbsp;text 3&nbsp;text 3&nbsp;text 3&nbsp;text 3&nbsp;text 3";
    }		

function openWin(urlPath){ 
	newWin = window.open(urlPath,"","resizable=1,height=310,width=430,scrollbars=no")
} 

function urlPop(quale){
	if (quale.value != '' && quale.value != '#'){
		window.open(quale.value);
	}
}

function openNews(urlPath){ 
	window.open(urlPath,"","resizable=false,height=510,width=550,scrollbars=yes")
} 

function sendfriend(){
	tmpUrl = "/en/send/sendtofriend.do?refurl=" + location.href;
	tmpdWidth = 310;
	tmpHeight = 350;
	tmpLeft = (screen.width - tmpdWidth) / 2;
	tmpTop = (screen.height - tmpHeight) / 2;
	window.open(tmpUrl,"","height=" + tmpHeight +",width=" + tmpdWidth + ",scrollbars=yes,resizable=no,top=" + tmpTop + ",left=" + tmpLeft)
}


function setComboIndex(formName, fieldName, indexValue)
{
		var comboObj = document[formName].elements[fieldName];
		if(comboObj != undefined) 
		{
			var found = 0;
		  for(i=1;i<comboObj.length;i++) 
			{
			      if (comboObj.options[i].value == indexValue) 
						{
			         found =i;
			         break;
			      }
			}
			comboObj.options[found].selected = true;
		}
}


function getYearParam()			
{
	 var param = "";
   var value = document['search'].elements['year'].value;
   if(value != "")
   	param = " AND airbus:\"ndateyy_"+value+"\"";
	return param;
}

function getMonthParam()			
{
	 var param = "";
   var value = document['search'].elements['month'].value;
   if(value != "")
   	param = " AND airbus:\"ndatemm_"+value+"\"";
	return param;
}


function getYearPrefixParam(prefix)			
{
	 var param = "";
   var value = document['search'].elements['year'].value;
   if(value != "")
   	param = " AND airbus:\""+prefix+"dateyy_"+value+"\"";
	return param;
}

function getMonthPrefixParam(prefix)			
{
	 var param = "";
   var value = document['search'].elements['month'].value;
   if(value != "")
   	param = " AND airbus:\""+prefix+"datemm_"+value+"\"";
	return param;
}



function checkFormPress()
{
	var templatetype=" AND airbus:\"templatetype_pressrelease\"";
	
	document['search'].elements['words'].value = document['search'].elements['keyword'].value + getYearPrefixParam('n')  + getMonthPrefixParam('n');
	if(document['search'].elements['words'].value != "")
		document['search'].elements['words'].value = document['search'].elements['words'].value + templatetype;
	
	//alert("words: " +document['search'].elements['words'].value);
	return true;
}


function getCategory()			
{
 	var param = "";
  var value = document['search'].elements['category'].value;
  if(value != "")
  	param = " AND airbus:\"mmcategory_"+value+"\"";
	return param;
}

function checkFormMM()
{
	var templatetype=" AND airbus:\"templatetype_mmlib\"";
	
	if (document.search.category_2.value != ''){
    document.search.category.value = document.search.category_2.value;
  } else {
  	document.search.category.value = document.search.category_1.value;
  }
	
	var tempkey="";
	
	
	if(document['search'].elements['keyword'].value != "")
	{
		tmpKeywordArray = document['search'].elements['keyword'].value.split(' ');
		
		for (contKeyword = 0; contKeyword < tmpKeywordArray.length; contKeyword++){
			
			tempkey += " airbus:\"" + tmpKeywordArray[contKeyword] + "\" ";
		}
		tempkey = " airbus:\"mmlib_keywords\"" + tempkey ;
	}
 	
 	document['search'].elements['words'].value = tempkey + getYearPrefixParam('mm')  + getMonthPrefixParam('mm') + getCategory(); 
	
	//document['search'].elements['words'].value = document['search'].elements['keyword'].value + getYearPrefixParam('mm')  + getMonthPrefixParam('mm') + getCategory();
	
	if(document['search'].elements['words'].value != "")
		document['search'].elements['words'].value = document['search'].elements['words'].value + templatetype;

	
	if(document['search'].elements['category_1'].value != ''){
		document['search'].elements['searchType'].value = document['search'].elements['category_1'].value.split('*')[0];
		
		//alert(document['search'].elements['category_1'].value.split('*')[0])
		if(document['search'].elements['category_1'].value.split('*')[0] == "PHOTOGRAPHY") document['search'].elements['menuFlashIndex'].value = 1;
		if(document['search'].elements['category_1'].value.split('*')[0] == "VIDEO") document['search'].elements['menuFlashIndex'].value = 2;
		if(document['search'].elements['category_1'].value.split('*')[0] == "ADVERTISING#TV") document['search'].elements['menuFlashIndex'].value = 3;
		if(document['search'].elements['category_1'].value.split('*')[0] == "ADVERTISING#PRESS") document['search'].elements['menuFlashIndex'].value = 4;
		if(document['search'].elements['category_1'].value.split('*')[0] == "VIRTUAL#VIEWS") document['search'].elements['menuFlashIndex'].value = 5;
		if(document['search'].elements['category_1'].value.split('*')[0] == "AIRCRAFT#DRAVINGS") document['search'].elements['menuFlashIndex'].value = 6;
		if(document['search'].elements['category_1'].value.split('*')[0] == "OTHER") document['search'].elements['menuFlashIndex'].value = 0;
		
	}
  return true;
}


	function searchMM(idTemplate){
		var tmp = '';
		switch(idTemplate){
        case 1:   tmp='PHOTOGRAPHY'; break
				case 2:   tmp='VIDEO'; break
				case 3:   tmp='ADVERTISING#TV'; break
				case 4:   tmp='ADVERTISING#PRESS'; break
				case 5:   tmp='VIRTUAL#VIEWS'; break
				case 6:   tmp='AIRCRAFT#DRAVINGS'; break
    }
		
		
    
		document.search.searchType.value = tmp;
		document.search.words.value = 'airbus:mmcategory_' + tmp +'*" AND airbus:"templatetype_mmlib"';
		document.search.submit();
	}
	
function checkFormFeatures()
{
	var templatetype=" AND airbus:\"templatetype_features\"";
	
	document['search'].elements['words'].value = document['search'].elements['keyword'].value + getYearPrefixParam('fe')  + getMonthPrefixParam('fe');
	
	if(document['search'].elements['words'].value != "")
		document['search'].elements['words'].value = document['search'].elements['words'].value + templatetype;
		
	
	//alert("words: " +document['search'].elements['words'].value);
	return true;
}

//disattiva il css di stampa
try{
	document.styleSheets[3].disabled = true;
}
catch(e){
	//empty
} 	
//abilita il css di stampa se e solo se è premuto il tasto 'print'	
function printPage(){
	document.styleSheets[2].disabled = false; 
	window.print();
	if (navigator.userAgent.indexOf("MSIE")!=-1){
		document.styleSheets[2].disabled = true;	
	}
}

function quickPop(quickURL){
	window.open(quickURL,"","menubar=yes,location=no,width=400,height=300")	
}


