<!-- Beginning of JavaScript -

/**************/
/* PARAMETERS */
/**************/
var moduleId = 'mdm';
var titleCellSeparations=3; //in pixels

/************/
/* VARIABLE */
/************/
var activeTitleBox='none';
var mdmMaxQtyMaterials=0;

var mdmLanguage = getParameterValue('language', window.location.href);

if(mdmLanguage == ''){
	mdmLanguage = 'en';
}

initMclLanguage(mdmLanguage);

//Load images. This part must be after initMpa02Language(mpa02Language) because inside that function mpa02ListedByGroups is initialized
if(document.images){
	var contGroups, contProducts;
	for(contGroups=0; contGroups<eval(moduleId +'ListedByGroups.length'); contGroups++){
		for(contProducts=1; contProducts<eval(moduleId +'ListedByGroups['+contGroups+'].length'); contProducts++){
			eval(  formatName(eval(moduleId+'ListedByGroups['+contGroups+']['+contProducts+']')) +'=new Image'  );
			eval(  formatName(eval(moduleId+'ListedByGroups['+contGroups+']['+contProducts+']'))+'.src=\'images/'+eval(moduleId+'ListedByGroups['+contGroups+']['+contProducts+']')+'.jpg\''  );
		}
	}
}else{
	for(contGroups=0; contGroups<eval(moduleId +'ListedByGroups.length'); contGroups++){
		for(contProducts=1; contProducts<eval(moduleId +'ListedByGroups['+contGroups+'].length'); contProducts++){
			eval(  formatName(eval(moduleId+'ListedByGroups['+contGroups+']['+contProducts+']'))+'.src=\'\''  );
		}
	}
}

function changeLanguage (language, where){
	var i;
	
	if(language == ''){
		var box = where.getAttribute("id");
		box = box.charAt(4);
		if(mdmLanguage == 'en'){
			mdmLanguage = (box == 0)? 'fr': 'es';
		}else if(mdmLanguage == 'fr'){
			mdmLanguage = (box == 0)? 'en': 'es';
		}else{
			mdmLanguage = (box == 0)? 'en': 'fr';
		}
	}else{
		mdmLanguage = language;
	}
	
	initMclLanguage(mdmLanguage);
	
	var tabs = new Array();
	
	tabs = returnTabsName(mdmLanguage);
	
	for(i in tabs){
		if(i==0){
			document.getElementById('tab'+i+'x').innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + tabs[i];
		}else{
			document.getElementById('tab'+i+'x').innerHTML = tabs[i];
		}
	}
	
	for(i=0; i<eval(moduleId +'ListedByGroups.length'); i++){
		document.getElementById(moduleId+'Supplier'+i).innerHTML = eval(moduleId +'ListedByGroups['+i+'][0]');
	}
	
	document.getElementById('partNumberTitleCell').innerHTML = eval('DetailedPart_Number.' + mdmLanguage);
	document.getElementById('CvCell').innerHTML = eval('Hold_Over_PN.' + mdmLanguage);
	//document.getElementById('datasheetTitleCell').innerHTML = eval('Datasheet.' + mdmLanguage);
	//when I removed the actuator datasheet link document.getElementById('actuatorTitleCell').innerHTML = eval('Actuator.' + mpa02Language);
	//document.getElementById('valveTitleCell').innerHTML = eval('Valve.' + mdmLanguage);
	
	if(mdmLanguage == 'es'){
		document.getElementById('flag0Image').src = flag_en.src;
		document.getElementById('flag1Image').src = flag_fr.src;
		
		document.getElementById('flag0Text').innerHTML = 'English';
		document.getElementById('flag1Text').innerHTML = 'Français';
		
		document.getElementById('phonesAndFaxBox').innerHTML = '<p>Sin costo</p><p>teléfono</p><p>Fax</p>';
		document.getElementById('contactHanbayText').innerHTML = 'Contacte HANBAY';
	}else if(mdmLanguage == 'fr'){
		document.getElementById('flag0Image').src = flag_en.src;
		document.getElementById('flag1Image').src = flag_es.src;
		
		document.getElementById('flag0Text').innerHTML = 'English';
		document.getElementById('flag1Text').innerHTML = 'Español';
		
		document.getElementById('phonesAndFaxBox').innerHTML = '<p>Sans frais</p><p>téléphone</p><p>Fax</p>';
		document.getElementById('contactHanbayText').innerHTML = 'Contactez HANBAY';
	}else{
		document.getElementById('flag0Image').src = flag_fr.src;
		document.getElementById('flag1Image').src = flag_es.src;
		
		document.getElementById('flag0Text').innerHTML = 'Français';
		document.getElementById('flag1Text').innerHTML = 'Español';
		
		document.getElementById('phonesAndFaxBox').innerHTML = '<p>Toll Free</p><p>Phone</p><p>Fax</p>';
		document.getElementById('contactHanbayText').innerHTML = 'Contact HANBAY';
	}
}

function MaterialTablePropertys(price, cellText, altCellText, altCellPosition) {
	this.price= price;
	this.cellText=cellText;
	this.altCellText=altCellText;
	this.altCellPosition=altCellPosition;
}


var contSuppliers, contProducts, contMaterials;
for(contSuppliers=0; contSuppliers<eval(moduleId +'ListedByGroups.length'); contSuppliers++){				//recorro los proveedores de valvulas
	for(contProducts=1; contProducts<eval(moduleId +'ListedByGroups['+contSuppliers+'].length'); contProducts++){		//recorro los productos de cada proveedor
		//S0P0material = new Object();
		var arrayName='S'+contSuppliers+'P'+contProducts+'material';
		eval(arrayName+'=new Object();');
		
		for(contMaterials=0; contMaterials<eval( formatName(eval(moduleId +'ListedByGroups['+contSuppliers+']['+contProducts+']'))+'_MATERIAL.length'); contMaterials++){		//recorro los materiales
			//S0P0material[0] = new MaterialTablePropertys("1.200","MPA02-3-SS-MB6R","MPA2 Actuator<br>Needle valve Cv=0.08<br>Stainless Steel","10");
			eval( arrayName+ '[' + contMaterials + ']= new MaterialTablePropertys(' + 1200 + ',' + formatName(eval(moduleId +'ListedByGroups['+contSuppliers+']['+contProducts+']')) + '_MATERIAL[' + contMaterials + '][0]' + ',' + '\'MCL Actuator<br>Needle valve Cv=0.08<br>Stainless Steel\'' + ',' + 10 + ');');																																																																 
		}
	}	
}

for(contSuppliers=0; contSuppliers<eval(moduleId +'ListedByGroups.length'); contSuppliers++){
	for(contProducts=1; contProducts<eval(moduleId +'ListedByGroups['+contSuppliers+'].length'); contProducts++){
		mdmMaxQtyMaterials=Math.max(mdmMaxQtyMaterials, eval( formatName(eval(moduleId +'ListedByGroups['+contSuppliers+']['+contProducts+']'))+'_MATERIAL.length'));
	}	
}

//eval(typeActuator+'activeBox'+"=boxId");
var cont1, cont2;
for(cont1=0; cont1<eval(moduleId +'ListedByGroups.length'); cont1++){
	for(cont2=1; cont2<eval(moduleId +'ListedByGroups['+cont1+'].length'); cont2++){
		eval(formatName(eval(moduleId +'ListedByGroups['+cont1+']['+cont2+']')) + '=new Image;');
		eval(formatName(eval(moduleId +'ListedByGroups['+cont1+']['+cont2+']')) + '.src="images/' + eval(moduleId +'ListedByGroups['+cont1+']['+cont2+']') + '.jpg";');
	}	
}

//MPA02_3_XX_MB6T = new Image
//eval('MPA02_3_XX_MB6T' + '=new Image;');
//eval(formatName(mpa02ListedByGroups[1][3]) + '=new Image;');

//MPA02_3_XX_MB6T.src="images/MPA02-3-XX-MB6T.jpg"
//eval(formatName(mpa02ListedByGroups[1][3]) + '.src="images/' + mpa02ListedByGroups[1][3] + '.jpg";');

/*
						
						
<td width="200" valign="top">
	<table width="200" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="194" height="22" bgcolor="#808EB5" class="H18VerdanaBold"><div align="center">MPA02 with<br>BonnetNeedleValves&copy; valves</div></td>
		</tr>
		<tr>
			<td width="194" height="22" bgcolor="#808EB5" class="H18VerdanaBold" align="center">MPA02 with<br>BonnetNeedleValves&copy; valves</td>
		</tr>
	</table>
</td>
				
<td width="195" valign="top">
	<table border="0" cellspacing="0" cellpadding="2">
		<tr><td width="191" id="offsetCell"></td></tr>
		<tr><td id="MPA02_SS_ORS2" height="10" bgcolor="#B3C0E2" class="H16VerdanaBold" align="justify" onMouseOver="doBoxAction('MPA02_SS_ORS2')" onMouseOut="" onClick="">&nbsp;MPA02-3-XX-ORS2</td></tr>
		<tr><td id="MPA02_SS_1RS4" height="10" bgcolor="#B3C0E2" class="H16VerdanaBold" align="justify" onMouseOver="doBoxAction('MPA02_SS_1RS4')" onMouseOut="" onClick="">&nbsp;MPA02-XX-1RS4</td></tr>
		<tr><td id="MPA02_SS_1RS6" height="10" bgcolor="#B3C0E2" class="H16VerdanaBold" align="justify" onMouseOver="doBoxAction('MPA02_SS_1RS6')" onMouseOut="" onClick="">&nbsp;MPA02-XX-1RS6</td></tr>
	</table>
</td>
*/

function showAltText (boxId, action){
	var whitchMaterial;
	var i;
	
	var boxId=boxId.getAttribute("id");
	
	
	var activeCell = boxId.charAt(boxId.length-1);
	
	if(activeCell == 0){
		document.getElementById(moduleId + 'AltTextTable').style.height = '160px';
		document.getElementById(moduleId + 'AltTextInformationTable').style.display = '';
	}else{
		document.getElementById(moduleId + 'AltTextTable').style.height = '50px';
		document.getElementById(moduleId + 'AltTextInformationTable').style.display = 'none';
	}
		
	if(action == 'hide'){
		document.getElementById(moduleId + 'AltTextTable').style.display = 'none';
	}else{
		whitchMaterial = boxId.charAt(boxId.length-2);
		
		//altTextfields.title = '<b>' + stringSplited[0] + '</b>';
		//altTextfields.type = '<b>' + eval('Type.'+language) + ':</b> ' +  stringSplited[1];
		//altTextfields.material = '<b>' + eval('Material.'+language) + ':</b> ' + stringSplited[2];
		//altTextfields.connected = '<b>' + eval('Connected.'+language) + ':</b> ' + stringSplited[3];
		//altTextfields.cv = '<b>C<sub>v</sub></b> = ' + stringSplited[4];
		//altTextfields.price = '<b>' + eval('Price.'+language) + ':</b> USD ' + price + ' (' + eval('Basic_model.'+language) + ')';
		
		
		//finalStringPartNumber = altTextfields.title + '|';
		//finalStringPartNumber += altTextfields.type + '|';
		//finalStringPartNumber += altTextfields.material + '|';
		//finalStringPartNumber += altTextfields.connection + '|';
		//finalStringPartNumber += altTextfields.cv + '|';
		
		document.getElementById(moduleId + 'AltTextDescription').innerHTML = allInformationForMaterialAndDataSheetTable[whitchMaterial].altBoxText[activeCell].split('|')[0];
		
		document.getElementById(moduleId + 'AltTextTypeTitle').innerHTML = eval('Type.' + eval(moduleId+'Language')) + ':';
		document.getElementById(moduleId + 'AltTextTypeText').innerHTML = allInformationForMaterialAndDataSheetTable[whitchMaterial].altBoxText[activeCell].split('|')[1];
		
		document.getElementById(moduleId + 'AltTextMaterialTitle').innerHTML = eval('Material.' + eval(moduleId+'Language')) + ':';
		document.getElementById(moduleId + 'AltTextMaterialText').innerHTML = allInformationForMaterialAndDataSheetTable[whitchMaterial].altBoxText[activeCell].split('|')[2];
		
		document.getElementById(moduleId + 'AltTextConnectionTitle').innerHTML = eval('Connection.' + eval(moduleId+'Language')) + ':';
		document.getElementById(moduleId + 'AltTextConnectionText').innerHTML = allInformationForMaterialAndDataSheetTable[whitchMaterial].altBoxText[activeCell].split('|')[3];
		
		document.getElementById(moduleId + 'AltTextCvTitle').innerHTML = 'C<sub>v</sub> =';
		document.getElementById(moduleId + 'AltTextCvText').innerHTML = allInformationForMaterialAndDataSheetTable[whitchMaterial].altBoxText[activeCell].split('|')[4];
		
		document.getElementById(moduleId + 'AltTextClickForText').innerHTML = '<span class="H12ArialRed">' + allInformationForMaterialAndDataSheetTable[whitchMaterial].altBoxText[activeCell].split('|')[5] + '</span>';
		
		
		//document.getElementById(moduleId + 'AltText').style.backgroundColor=altTextBoxBackColor;
		//document.getElementById(moduleId + 'AltText').innerHTML = allInformationForMaterialAndDataSheetTable[whitchMaterial].altBoxText[activeCell];
		document.getElementById(moduleId + 'AltTextTable').style.display = '';
	}	
}


var cursor = {x:0, y:0};
function get_mouse_pointer_coordinates(e) {
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) {
		cursor.x = e.pageX;
		cursor.y = e.pageY;
	}else if (e.clientX || e.clientY) {
		cursor.x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		cursor.y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	//document.getElementById('mouse_x').innerHTML=cursor.x;
	//document.getElementById('mouse_y').innerHTML=cursor.y;
	//document.getElementById(moduleId + 'AltTextTable').style.left=(cursor.x+20)+'px';
	var actualWidth = document.getElementById(moduleId + 'AltTextTable').style.width.split('px');
	var actualHeight = document.getElementById(moduleId + 'AltTextTable').style.height.split('px');
	document.getElementById(moduleId + 'AltTextTable').style.left=( cursor.x - (eval(actualWidth[0]) + 20) )+'px';
	document.getElementById(moduleId + 'AltTextTable').style.top=(cursor.y - eval(actualHeight[0]) - 20)+'px';
}
document.body.onmousemove = get_mouse_pointer_coordinates;


// - End of JavaScript - -->