//Electriduct JS FILE

function more_rub(src)
{
	var temp = null;
	if (src.match("Cable Protectors") != null)
		temp = 1;
	if (src.match("Wire Management") != null)
		temp = 1;
	if (src.match("Rack Cabinets") != null)
		temp = 1;
	if (src.match("Traffic Safety") != null)
		temp = 1;
	if (src.match("Wheel Chocks") != null)
		temp = 1;
	if (temp != null)
		document.write('<img src="assets/templates/layout8/images/style/puce.gif" border="0" style="float:left; margin-top: 9px;">&nbsp;');
}

function myreplace(src)
{
	var temp = null;
	
	temp = src;
	temp = src.replace("(f)", "<br><font size ='1'>(feet)</font></b>");
	temp = temp.replace("(i)", "<br><font size ='1'>(inches)</font></b>");
	temp = temp.replace("(y)", "<br><font size ='1'>(yards)</font></b>");
	temp = temp.replace("(l)", "<br><font size ='1'>(lbs)</font></b>");
	return temp;
}

function head(data)
{
	var theinfo
	var temp;
	
	if (data == null) return false;
	temp = data.split(':');
	if (temp[0] == null) return false;	
	return (temp[0]);	
}

function info(data)
{
	var theinfo
	var temp;
	
	if (data == null) return false;
	temp = data.split(':');
	if (temp[1] == null) return false;	
	return (temp[1]);	
}


function displayData(vHead, vData, vItem)
{
	var i;
	var j;
	var temp;
	var color = "#FFFFFF";
	
	if (vItem % 2 != 0) color = "#FEF3E2";
	document.write('<tr bgcolor="' + color +'" align="center">');
	for (i = 0;i < vHead.length; i++)
		{
			//alert(temp);
			temp = vData[i].split(',');
		//	for (j = 0; j < vData.length; j++)
			document.write('<td>' + temp[vItem] + '</td>');
		}
	document.write('</tr>');
}

function Display(vHead, vData)
{
	var i;
	var temp;
	var percent = 100 / vHead.length;
	
	//Tab Creation
	document.write('<table border="0" width="100%" cellspacing="0" cellpadding="0" class="ProdTable" align="center">');
	
	//Header Creation
	document.write('<tr class="Toptable" align="center">');
	for (i = 0; i < vHead.length; i++)
		document.write('<th width="' + percent + '%" >' + myreplace(vHead[i]) + '</th>');
	document.write('</tr>');
	
	//Data Creation
//	alert(vData);
	temp = vData[0].split(',');
	for (i = 0; i < temp.length; i++)
	{
		//temp = vData[i].split(',');
	//	alert(vData[i]);
		displayData(vHead, vData, i);		
	}
//	for (i = 0; i < temp.length; i++) displayData(vHead, vData, i);
	
	//Tab End
	document.write(' </table>');
}

function make_tab(data)
{
//Creating the ElectriductTAb
//Format : DESCRIPTION1:DATA1,DATA2,DATA3;DESCRIPTION2:DATA1,DATA2,DATA3;DESCRIPTION3:DATA1,DATA2,DATA3
	if (data.length <= 2)
	{
		//document.write(data);
		return false;
	}

	totaltab = data.split(';');
	var vHead = new Array;
	var vData = new Array;
	var temp;
	var i;
	for (i = 0; i < totaltab.length; i++)
		{
			//Get header
			temp = head(totaltab[i]);
			if (temp != false) vHead.push(temp);
			
			//Get Data
			temp = info(totaltab[i]);
			if (temp != false) vData.push(temp);		
		}
	Display(vHead, vData);
	return true;
}