var ListViewTableClone;





function ChangeToView1()
{
	var windowWidth;
	var innerPadding;
	var innerPaddingBottom;
	var outerPadding;
	var pictureWidth;
	
	if (TView!="1")
	{
		 
		var ListViewCell=document.getElementById('ListViewCell');
		var ListViewTable=document.getElementById('ListViewTable');			    			
		var ProductFamilyInnerTable;
		var ProductFamilyNodeName;
		var ProductFamilyPicture;
		var ListViewPictures;		
	  
	  ListViewTable.style.visibility="visible"; 
	  
		try
		{
		  windowWidth=window.frameElement.scrollWidth;
		}
		catch(E)
		{
			windowWidth=1024;
		}  
		
		if (windowWidth<800)
		{
			innerPadding=0;
			innerPaddingBottom=0;
			outerPadding=2;
			pictureWidth=140;
		}
	  else
	  {
	  	innerPadding=0;
	  	innerPaddingBottom=0;
			outerPadding=8;	
			pictureWidth=170;
	  }			
		ListViewTableClone=ListViewTable.cloneNode(true);					
	
		ListViewTable1=document.createElement("TABLE");
    ListViewTable1.id="ListViewTable";
    ListViewTable1.cellSpacing=0;
    ListViewTable1.cellPadding=0;
		ListViewTBody1=document.createElement("TBODY");
		ListViewTable1.appendChild(ListViewTBody1);
		ListViewTHead1=document.createElement("THEAD");
		ListViewTable1.appendChild(ListViewTHead1);
		
		for (i=0;i<ListViewTable.rows.length;i++)
		{		
		
			ProductFamilyInnerTable=document.getElementById("ProductFamilyInnerTable"+(i+1));			
			ProductFamilyNodeName=ProductFamilyInnerTable.rows[0];						
			ProductFamilyNodeName.cells[0].align="left";			
			ProductFamilyNodeName.cells[0].style.fontWeight="normal";				
			ProductFamilyNodeName.cells[0].style.paddingTop="10px";						
			ProductFamilyNodeName.cells[0].style.paddingLeft=innerPadding+5+"px";		
			ProductFamilyNodeName.cells[0].style.paddingRight=innerPadding+"px";			
			ProductFamilyNodeName.style.height="65px";				
			ProductFamilyPicture=ProductFamilyInnerTable.rows[1].cells[0];									
			ProductFamilyPicture.align="center";						
			ProductFamilyPicture.style.paddingTop="0px";			
			ProductFamilyPicture.style.paddingBottom=innerPaddingBottom+"px";			
			ProductFamilyPicture.style.paddingLeft=innerPadding+"px";			
			ProductFamilyPicture.style.paddingRight=innerPadding+"px";				
	
			if ((i%4)==0) 
			{
				 newRow=document.createElement("TR");
				 ListViewTBody1.appendChild(newRow);
			}	 
			
			newCell=document.createElement("TD");
			
			newCell.style.paddingTop=outerPadding+"px";			
			
			if ((i%4)!=3)newCell.style.paddingRight=outerPadding+"px";
			
			newRow.appendChild(newCell);		
			
			ListViewInnerTable=document.createElement("TABLE");			
			ListViewInnerTable.style.border="1px solid";
			ListViewInnerTable.style.borderColor="rgb(170,170,170)";			
			newCell.appendChild(ListViewInnerTable);
      ListViewInnerTable.id="ListViewInnerTable";
      ListViewInnerTable.cellSpacing=0;
      ListViewInnerTable.cellPadding=0;
      ListViewInnerTable.style.width=pictureWidth+"px";
			ListViewInnerTBody=document.createElement("TBODY");
			ListViewInnerTable.appendChild(ListViewInnerTBody);		
			newInnerRow=document.createElement("TR");
			ListViewInnerTBody.appendChild(newInnerRow);
			ListViewInnerTHead=document.createElement("THEAD");			
			ListViewInnerTable.appendChild(ListViewInnerTHead);
			ListViewInnerTHead.appendChild(ProductFamilyNodeName);
			newInnerRow.appendChild(ProductFamilyPicture);			
		}	
			  
		ListViewCell.removeChild(ListViewTable);			
		ListViewCell.appendChild(ListViewTable1);		
		
		TView="1"; 
	}	
	
	adjustHeightinPortal();	
}

function ChangeToView2()
{
	if (TView!="2")
	{
		
	var ListViewCell=document.getElementById('ListViewCell');
	var ListViewTable=document.getElementById('ListViewTable');
	ListViewCell.removeChild(ListViewTable); 
	
	ListViewCell.appendChild(ListViewTableClone);
	ListViewTableClone.id="ListViewTable";
	TView="2"
	adjustHeightinPortal();
	}

}


function ChangeToPropertySearch(NodeId,xS,xL,SelectedPartNo,LastSearchString,CurrentNode,Mode)
{
	
	if (TView!="3")
	{	
	var ViewChoice=document.getElementById('ViewChoice');	
	var ListViewCell=document.getElementById('ListViewCell');
	var ListViewTable=document.getElementById('ListViewTable');
	if (TView!="2") ListViewTableClone1=ListViewTable.cloneNode(true);
	ListViewCell.removeChild(ListViewTable);
	if(ViewChoice!=null)ListViewCell.removeChild(ViewChoice);
	PSIFrame=document.createElement("IFRAME");
	PSIFrame.id="ListViewTable";
	PSIFrame.style.width="100%";
	PSIFrame.style.height="600px";
	PSIFrame.frameBorder=0;
	RandomNo=Math.random(); //is only to solve the problem with caching
	PSIFrame.src="?xL="+xL+"&xS="+xS+"&xR=DKI3WebPropertysearchV1&PropertySearchNodeId="+NodeId+"&Random="+RandomNo+"&SelectedPartNo="+SelectedPartNo+"&LastSearchString="+LastSearchString+"&CurrentNode="+CurrentNode+"&Mode="+Mode;
	ListViewCell.appendChild(PSIFrame);
	TView="3"
	adjustHeightinPortal();
	}
		
}

function printFotoView()
{	
	xDKICreatePDFReport();
}



function fillPrintWindow(PrintWindow)
{
	var ListViewTable=document.getElementById("ListViewTable");
	var ListViewTableClone=ListViewTable.cloneNode(true);//copy of the Listview

	var newDocument;
	newDocument=PrintWindow.document;
	newDocument.write("<head><link rel='stylesheet' type='text/css' href='css/festo.css'>"+
				"</head>"+
			"<body class='default'><br><br><table border=0 width=100%><tr style='height: 30mm'><td style='width: 180mm;'></td>"+
			"<td style='width: 30mm;' ></td></tr><tr style='height: 10mm'>"+
			"<td colspan=2 align='right'>www.festo.com</td></tr>"+
			"<tr style='height: 10mm'><td><div align='center' class='title' id='headline'>"+HeadLineContent+"</div></td><td></td></tr><tr><td>"+
			"<table width=500> <tbody>"+ListViewTableClone.innerHTML+
			"</tbody></table></td><td></td></tr></table></body>"+
			"<script>"+
			"function doNothing()"+
			"{"+
			"}"+
			"function delEvent(MyObjects) "+
		  "{"+
		   "for (i=0;i<MyObjects.length;i++)"+
		   "{"+
		    "MyObjects[i].onclick=doNothing;"+
		    "MyObjects[i].onmouseover=doNothing;"+
		    "MyObjects[i].onmouseout=doNothing;"+
		   "}"+
		   "}"+		
			"var PrintViewTCell=document.getElementsByTagName('TD');"+
			"delEvent(PrintViewTCell);"+
			"var PrintViewLinks=document.getElementsByTagName('A');"+
			"for (i=0;i-PrintViewLinks.length;i++)"+
			"{"+
				"PrintViewLinks[i].href='javascript:doNothing()';"+
			"}"+
			"</script>");
	newDocument.close();
 PrintWindow.print();
 PrintWindow.close();
}
	