var anzahl = -1;
product_id = new Array();
deeplink = new Array();
txt_product = new Array();
txt_price = new Array();
txt_price_old = new Array();
img_source = new Array();

img_path = "";
txt_company = "Hagebau.de";
img_alt = "Hagebau.de - Größter Online Baumarkt!";


var zufallszahl, aktuelle_zufallszahl, multiplikator, url_product;

// *******************************************************************************
// *** Produkt festlegen (zyklisch wechselnd)                                  ***
// *******************************************************************************


function ermittle_zufallszahl()
{	
	multiplikator = anzahl - 1;
	zufallszahl=Math.round((Math.random()*multiplikator));
	if ( (zufallszahl>0) && (zufallszahl==aktuelle_zufallszahl) )
	{
		ermittle_zufallszahl();
	}
	aktuelle_zufallszahl = zufallszahl;
}

// *******************************************************************************
// *** Aufrufteil:                                                             ***
// *** Hinweis: Ändern Sie den Namen der Funktion (auch im HTML-Code) !!!      ***
// *******************************************************************************

function Hagebau_RotationProducts_Table(link)
{
	ermittle_zufallszahl();	
		
	var loc_uri = unescape(link);
	loc_uri_par = loc_uri.split("&");
	if (loc_uri_par[0] != "")
	{ var link = loc_uri_par[0] + "&ULP="; }
	else
	{ var link = ""; }
	loc_uri_tbpar = loc_uri_par[1].split("=");
	loc_uri_val = loc_uri_tbpar[1].split(",");
	if (loc_uri_val[0] != "")
	{ var tb_row = loc_uri_val[0]; }
	else
	{ var tb_row = 2; }
	if (loc_uri_val[1] != "")
	{ var tb_col = loc_uri_val[1]; }
	else
	{ var tb_col = 3; }
	if (loc_uri_val[2] != "")
	{ var tb_bgcolor = loc_uri_val[2]; }
	else
	{ var tb_bgcolor = "ffffff"; }
	
	
	document.writeln('<TABLE CELLSPACING=0 BORDER=0 WIDTH="120"><TR><TD WIDTH="120" VALIGN="TOP">');
	
	var tb_count = zufallszahl;
	document.writeln(' <TR><TD COLSPAN="' + tb_col + '" STYLE="border-width:1px;border-style:solid;border-color:000000;"><img src="http://www.onmacon.de/kunden/hagebau/banner/logos/120x40_logo.gif" width="120" height="40"></TD></TR>');
	
	for (var i = 1; i <= tb_row; i = i + 1)
	{
	  document.writeln(' <TR>');
	  
	  for (var j = 1; j <= tb_col; j = j + 1)
	  {
	  	if (tb_count >= anzahl)
	  	{ tb_count = 0; }
	  	else
	  	{ tb_count = tb_count + 1; }
	    
	    url_product = link + deeplink[tb_count];
	    var tab_style = '  <TD valign="top" STYLE="border-left-width:1px;border-left-style:solid;border-left-color:000000;';
	    if ((i > 0))
	    { tab_style = tab_style + 'border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:000000;'; }
	    if (j == tb_col)
	    { tab_style = tab_style + 'border-right-width:1px;border-right-style:solid;border-right-color:000000;'; }
	    tab_style = tab_style + '">';
	    document.writeln('  ' + tab_style);
	    
	    document.writeln('   <TABLE CELLSPACING=0 BORDER=0 WIDTH="120" HEIGHT="175"><TR><TD WIDTH="120" VALIGN="TOP">');
	    document.writeln('    <FONT SIZE="1" FACE="Arial,Helvetica,sans-serif"><CENTER>');
	    document.writeln('    <A HREF="' + url_product + '" TARGET="_blank">');
	    document.writeln('    <IMG SRC="' + img_path + img_source[tb_count] + '" ALT="' + img_alt + '" BORDER="0" height="80">');
	    document.writeln('    <BR><FONT COLOR="red"><B>' + txt_price[tb_count] + '</B></FONT><BR><FONT COLOR="black" style="text-decoration:line-through;">' + txt_price_old[tb_count] + '</FONT><BR><B>' + txt_product[tb_count] + '</B></A></CENTER></FONT>');
	    document.writeln('   </TD></TR></TABLE>');
	    
	    document.writeln('  </TD>');
	  }
	  
	  document.writeln(' </TR>');
	}
	document.writeln('</TD></TR></TABLE>');
}

