/* FUNCTIONS
 *
 * writeSectionOne, writeSectionTwo, writeSectionThree
 * writeSectionFour, writeSectionFive, writeSectionSix
 * writeSectionSeven, writeSectionEight, writeSectionNoImage
 * writeSectionImage
 *
 * DESCRIPTION
 *
 * These functions contain page specific code. This code
 * and these functions are not reusable and will only
 * generate code to display specific window contents.
 *
 */
 
var global_text_ParentTextField = null;
var global_window_ThisWindow = null;
var global_strParentHyperlink = null;

function writeSectionOne(window_ThisWindow)
{
  var str='';

  str+='<TABLE cellSpacing=0 cellPadding=0 width=505 align=center border=0>';
  str+='<TBODY>';
  str+='<TR>';
  str+='<TD vAlign=top height=344>';

  window_ThisWindow.document.write(str);
}

function writeSectionTwo(window_ThisWindow)
{
  var str='';

  str+='<\/TD><\/TR>';
  str+='<TR class=lineTop><TD height=1><\/TD><\/TR>';
  str+='<TR>';
  str+='<TD vAlign=top>';
  str+='<TABLE cellSpacing=0 cellPadding=0 width=505 border=0>';
  str+='<TBODY>';
  str+='<TR>';
  str+='<TD height=17 colspan=5>';
  str+='<TABLE cellSpacing=0 cellPadding=0 width=505 border=0 class=bar1background>';
  str+='<TR>';
  str+='<TD width=8 height=17> <\/TD>';
  str+="<TD class=toBarTitle vAlign=middle width=329>Tickets information<\/TD>";
  str+='<TD class=toBarTitle vAlign=middle align=left width=64>Price<\/TD>';
  str+='<TD class=toBarTitle vAlign=middle align=center width=51>Qty.<\/TD>';
  str+='<TD vAlign=center width=53> <\/TD><\/TR>';
  str+='<\/TABLE><\/TD><\/TR>';
  str+='<TR class=bar1bottombackground><TD height=1 colspan=5><\/TD><\/TR>';
  str+='<TR>';
  str+='<TD colspan=5 class=ticketrowbackground>';
  str+='<TABLE cellSpacing=0 cellPadding=0 width=505 border=0>';
  str+='<TR>';
  str+='<TD height=27 width=8> <\/TD>';
  str+='<TD vAlign=middle width=329 class=toBarTitle>';

  window_ThisWindow.document.write(str);
}

function writeSectionThree(window_ThisWindow)
{
  var str='';

  str+='<\/TD>';
  str+='<TD vAlign=middle width=64 class=toBarTitle align=left>';

  window_ThisWindow.document.write(str);
}

function writeSectionFour(window_ThisWindow)
{
  var str='';

  str+='<\/TD>';
  str+='<TD vAlign=middle width=51 align=center align=left>';

  window_ThisWindow.document.write(str);
}

function writeSectionFour1(window_ThisWindow)
{
  var str='';

  str+='<\/TD>';
  str+='<TD vAlign=middle width=115 align=center align=left colspan=2 class="text_soldout">SOLD OUT';

  window_ThisWindow.document.write(str);
}

function writeSectionFive(window_ThisWindow)
{
  var str='';

  str+='<\/TD>';
  str+='<TD vAlign=middle align=center align=left>';

  window_ThisWindow.document.write(str);
}

function writeSectionSix(window_ThisWindow)
{
  var str='';

  str+='<\/TD><\/TR>';
  str+='<\/TABLE><\/TD><\/TR>';
  str+='<TR class=grandstand_Top><TD height=1 colspan=5><\/TD><\/TR>';
  str+='<TR class=bar1background>';
  str+='<TD vAlign=middle><TABLE><TR><TD width=1><\/TD><TD class=toBarTitle>Grandstand information<\/TD><\/TR><\/TABLE><\/TD>';
  str+='<\/TR>';
  str+='<TR><TD height=1 colspan=5 class=grandstand_bottom><\/TD><\/TR>';
  str+='<TR vAlign=middle class=greenbarBackground>';
  str+='<TD colSpan=5 height=25>';
  str+='<TABLE height=25 cellSpacing=0 cellPadding=0 border=0>';
  str+='<TBODY>';
  str+='<TR>';
  str+='<TD width=8 valign=top>';

  window_ThisWindow.document.write(str);
}

function writeSectionSix_1(window_ThisWindow)
{
  var str='';

 str+='<\/TD><\/TR>';
  str+='<\/TABLE><\/TD><\/TR>';
  str+='<TR class=grandstand_Top><TD height=1 colspan=5><\/TD><\/TR>';
  str+='<TR class=bar1background>';
  str+='<TD vAlign=middle><TABLE><TR><TD width=1><\/TD><TD class=toBarTitle height=15><\/TD><\/TR><\/TABLE><\/TD>';
  str+='<\/TR>';
  str+='<TR><TD height=1 colspan=5 class=grandstand_bottom><\/TD><\/TR>';
  str+='<TR vAlign=middle class=greenbarBackground>';
  str+='<TD colSpan=5 height=25>';
  str+='<TABLE height=25 cellSpacing=0 cellPadding=0 border=0>';
  str+='<TBODY>';
  str+='<TR>';
  str+='<TD width=8 valign=top>';

  window_ThisWindow.document.write(str);
}

function writeSectionSeven(window_ThisWindow)
{
  var str='';

  str+='<\/TD><\/TR>';
  str+='<\/TBODY><\/TABLE><\/TD><\/TR><\/TBODY><\/TABLE><\/TD><\/TR>';
  str+='<TR>';
  str+='<TD vAlign=top height=10 class=greenbar_shadow>';
  str+='<\/TD><\/TR>';
  str+='<TR>';
  str+='<TD vAlign=top>';
  str+='<TABLE height=25 cellSpacing=0 cellPadding=0 width=505 border=0 class=infobackground>';
  str+='<TBODY>';
  str+='<TR>';
  str+='<TD width=8> <\/TD>';
  str+='<TD>';

  window_ThisWindow.document.write(str);
}

function writeSectionEight(window_ThisWindow)
{
  var str='';

  str+='<BR><BR><BR><BR><BR><BR><BR><BR><BR><\/TD>';
  str+='<TD width=8> <\/TD><\/TR>';
  str+='<TR>';
  str+='<TD colSpan=3><IMG height=10 src="images\/leeg.gif" width=10>';
  str+='<\/TD><\/TR><\/TBODY><\/TABLE><\/TD><\/TR>';
  str+='<\/TBODY>';
  str+='<\/TABLE>';

  window_ThisWindow.document.write(str);
}

function writeSectionImage(window_ThisWindow, strDetails, strImage)
{
  var str='';

  str+='<\/TD>';
  str+='<TD vAlign=middle width=14>';
  str+='<IMG height=10 src="';
  str+='' + strImage + '"';
  str+='width=14 align=absMiddle><\/TD><TD width=5><\/TD><TD vAlign=middle width=131 class=greenfont> ';
  str+='' + strDetails;

  window_ThisWindow.document.write(str);
}

function writeSectionNoImage(window_ThisWindow)
{
  var str='';

  str+='<\/TD>';
  str+='<TD vAlign=center width=0>';
  str+='<IMG height=17 src="images\/leeg.gif" width=18 align=absMiddle> ';

  window_ThisWindow.document.write(str);
}


/* FUNCTION:
 *
 * runUpdateFunction
 *
 * DEPENDENCIES:
 *
 * [global] var global_text_ParentTextField
 * [global] var global_window_ThisWindow
 * [global] var global_strParentHyperlink
 * [function] showProductWindow (functional dependency)
 *
 * DESCRIPTION:
 *
 * This function is called by showProductWindow and
 * closes the window created in showProductWindow it then also
 * updates a textfield value passed through showProductWindow
 * and a hyperlink passed through showProductwindow.
 *
 * NOTE:
 *
 * This function should NOT be used without showProductWindow.
 *
 *
 */
function runUpdateFunction()
{
   //fill the parent textfield
   if (global_text_ParentTextField != null
       && global_window_ThisWindow.document.form_ProductForm.text_ProductAmount != null)
   {
     global_text_ParentTextField.value = global_window_ThisWindow.document.form_ProductForm.text_ProductAmount.value;
   }

   //visit the parent hyperlink
   if (global_strParentHyperlink != '')
   {
     global_window_ThisWindow.opener.location.href = "" + global_strParentHyperlink;
   }

   //close the child window
   if (global_window_ThisWindow != null)
   {
     global_window_ThisWindow.close();
   }
}

/* FUNCTION:
 *
 * showProductWindow
 *
 * DEPENDENCIES:
 *
 * [global] var global_text_ParentTextField
 * [global] var global_window_ThisWindow
 * [global] var global_strParentHyperlink
 * [function] function runUpdateFunction()
 *
 * DESCRIPTION:
 *
 * This function displays a specific window with a product from a shopping cart.
 * The number of products to be ordered can be chosen or typed into a field
 * and upon pressing a button the caller can be redirected to a new
 * shopping cart function that adds to cart or buy or any other function.
 *
 * VARIABLES:
 *
 * [in/out] text_ParentTextfield:  A textfield that is included in this window and allows changes to the passed parent textfield
 * [in]     strParentHyperlink:    A hyperlink position that redirects the calling parent to the hyperlink position
 * [in]     strProductImage:       A main product image or window image
 * [in]     strFirstIcon:          A first icon that depicts a product specific attribute
 * [in]     strSecondIcon:         A second icon that depicts a product specific attribute
 * [in]     strThirdIcon:          A third icon that depics a product specific attribute
 * [in]     strPrice:              A price indicator for the product
 * [in]     strCurrency:           A string that represents the currency
 * [in]     bProductAvailable:     A product availability indicator either 'true' or 'false'
 * [in]     strProductText:        A product descriptionary  text
 * [in]     strProductName:        A product representative name
 *
 * EVENTS:
 *
 * [trigger] runUpdateFunction():   A function that closes window and updates parent
 *                                  text_ParentTextfield value and redirects to strParentHyperlink
 */
function showProductWindow(text_ParentTextfield, strParentHyperlink, strProductImage, strFirstIcon, strSecondIcon, strThirdIcon, strPrice, strCurrency, bProductAvailable, strProductName, strProductText, iLocationX, iLocationY)
{
    //set the window title
    var strPriceText = 'Price: ';
    var strSoldOutText = 'product sold out';
    var strProductDescriptionText = 'Description: ';
    var strProductNameText = 'Name: '
    var strWindowTitle = 'circuit product window';
    
    if (strProductText == '')
    {
      var window_ThisWindow = newWindow('window', 505, 436, false);
    }
    else 
    {
      var window_ThisWindow = newWindow('window', 505, 535, false);      
    }
    
    //var window_ThisWindow = newWindow('window', 505, 535, false);

    if (strProductName == '')
    {
      strProductName = "No Name Available";
    }

    //when there is get an empty like one
    if (strProductText == '')
    {
      strProductText = "No additional information";
    }

    //when there is no image get the empty one
    if (strProductImage == '')
    {
      strProductImage = "./images/leeg.jpg";
    }

    //there is no price set zero
    if (strPrice == '')
    {
      strPrice = "0";
    }

    //there is no currency set to euros
    if (strCurrency == '')
    {
      strCurrency = "EUR";
    }

    //point global window to this window
    if (window_ThisWindow != null)
    {
      global_window_ThisWindow = window_ThisWindow;
    }

    //point global textfield to parent texfield
    if (text_ParentTextfield != null)
    {
      global_text_ParentTextField = text_ParentTextfield;
    }

    //point global hyperlink to parent hyperlink
    if (strParentHyperlink != '')
    {
      global_strParentHyperlink = strParentHyperlink;
    }

    beginWindowHeader(window_ThisWindow, strWindowTitle, './images/popupstyle.css');
    beginWindowInput(window_ThisWindow, 'form_ProductForm');

    writeSectionOne(window_ThisWindow);

	var strOverlay = "./images/circle.gif";
	var str='';
	str+='<img src="' + strProductImage + '" border=0>';	
	/*
    if (isJavaCompatible(window_ThisWindow) == false)
    {
      placeWindowImage(window_ThisWindow, strOverlay, "pointer", 19, 19);
      placeWindowImage(window_ThisWindow, strProductImage, "image", 505, 344);
      setWindowObjectPosition(window_ThisWindow, 'form_ProductForm', 'pointer', iLocationX, iLocationY);
    }

    if (isJavaCompatible(window_ThisWindow) == true)
    {
      placeWindowAppletHeader(window_ThisWindow, "GrandPrixAppletCustom.class", 505, 344);
      placeWindowAppletParameter(window_ThisWindow, "locationx", iLocationX);
      placeWindowAppletParameter(window_ThisWindow, "locationy", iLocationY);
      placeWindowAppletParameter(window_ThisWindow, "mode", "display");
      placeWindowAppletParameter(window_ThisWindow, "track", strProductImage);
      placeWindowAppletParameter(window_ThisWindow, "overlay",strOverlay);
      placeWindowAppletFooter(window_ThisWindow);
    }
*/
	window_ThisWindow.document.write(str);
	  writeSectionTwo(window_ThisWindow);
    window_ThisWindow.document.write(strProductName);

    writeSectionThree(window_ThisWindow);
    window_ThisWindow.document.write(strCurrency + " " + strPrice);

    
    if (bProductAvailable == "true")
    {
	  writeSectionFour(window_ThisWindow);
      placeWindowInputText(window_ThisWindow, 'text_ProductAmount', 2, 0, 2, 'inputhoeveelheid');
      writeSectionFive(window_ThisWindow);

      if (text_ParentTextfield != null)
      {
        window_ThisWindow.document.form_ProductForm.text_ProductAmount.value = text_ParentTextfield.value;
      }

      placeWindowInputButton(window_ThisWindow, 'button_ProductFunction', 'runUpdateFunction()', 'images/button_add.gif', 46, 17, '');
	    if (strFirstIcon == './images/leeg.gif' && strSecondIcon == './images/leeg.gif' && strThirdIcon == './images/leeg.gif')
		{
			writeSectionSix_1(window_ThisWindow);
		}else{
	    writeSectionSix(window_ThisWindow);
		}
	  }
	  else if (bProductAvailable == "false")
	  {
		writeSectionFour1(window_ThisWindow);
	    writeSectionFive(window_ThisWindow);
		if (strFirstIcon == './images/leeg.gif' && strSecondIcon == './images/leeg.gif' && strThirdIcon == './images/leeg.gif')
		{
			writeSectionSix_1(window_ThisWindow);
		}else{
	    writeSectionSix(window_ThisWindow);
		}
	  }

   //TODO: check ordering of numbered, tv and covered, then fit to code
   if (strFirstIcon == './images/leeg.gif')
   {
     writeSectionNoImage(window_ThisWindow);
   } else {
     writeSectionImage(window_ThisWindow, 'Numbered Seats', strFirstIcon);
   }

   if (strSecondIcon == './images/leeg.gif')
   {
     writeSectionNoImage(window_ThisWindow);
   } else {
     writeSectionImage(window_ThisWindow, 'TV Screen', strSecondIcon);
   }

   if (strThirdIcon == './images/leeg.gif')
   {
     writeSectionNoImage(window_ThisWindow);
   } else {
     writeSectionImage(window_ThisWindow, 'Covered', strThirdIcon);
   }

   writeSectionSeven(window_ThisWindow);
   
   
   window_ThisWindow.document.write('<div id="scrollbar" valign=top>');
   window_ThisWindow.document.write('<p>' + strProductText + '</p></div>');
//scrollable text
   window_ThisWindow.document.write('<style type="text/css">');
   window_ThisWindow.document.write('#scrollbar');
   window_ThisWindow.document.write('{');
   window_ThisWindow.document.write('  width: 490px;');
   window_ThisWindow.document.write('  height: 85px;');
   window_ThisWindow.document.write('  overflow: auto;');
   window_ThisWindow.document.write('  margin: 0px;');
   window_ThisWindow.document.write('  padding: 0px;');
   window_ThisWindow.document.write('  scrollbar-3dlight-color:99CE9A;');
   window_ThisWindow.document.write('  scrollbar-arrow-color:#FFFFFF;');
   window_ThisWindow.document.write('  scrollbar-base-color:#003366;');
   window_ThisWindow.document.write('  scrollbar-darkshadow-color:#083D09;');
   window_ThisWindow.document.write('  scrollbar-face-color:0E7A10;');
   window_ThisWindow.document.write('  scrollbar-highlight-color:#99CE9A;');
   window_ThisWindow.document.write('  scrollbar-track-color:#CBDECB;');
   window_ThisWindow.document.write('  scrollbar-shadow-color:#083D09');
   window_ThisWindow.document.write('}');
   window_ThisWindow.document.write('</style>');
   writeSectionEight(window_ThisWindow);
   endWindowInput(window_ThisWindow);
   endWindowHeader(window_ThisWindow);
}

function showProductAddonsWindow(strProductImage, strPrice, strCurrency, strProductName, strProductText)
{
    //set the window title
    var strPriceText = 'Price: ';
    var strSoldOutText = 'product sold out';
    var strProductDescriptionText = 'Description: ';
    var strProductNameText = 'Name: '
    var strWindowTitle = 'circuit product window';
    
    if (strProductText == '')
    {
      var window_ThisWindow = newWindow('window', 505, 436, false);
    }
    else 
    {
      var window_ThisWindow = newWindow('window', 505, 535, false);      
    }
    
    //var window_ThisWindow = newWindow('window', 505, 535, false);

    if (strProductName == '')
    {
      strProductName = "No Name Available";
    }

    //when there is get an empty like one
    if (strProductText == '')
    {
      strProductText = "No additional information";
    }

    //when there is no image get the empty one
    if (strProductImage == '')
    {
      strProductImage = "./images/leeg.jpg";
    }

    //there is no price set zero
    if (strPrice == '')
    {
      strPrice = "0";
    }

    //there is no currency set to euros
    if (strCurrency == '')
    {
      strCurrency = "EUR";
    }

    //point global window to this window
    if (window_ThisWindow != null)
    {
      global_window_ThisWindow = window_ThisWindow;
    }

    beginWindowHeader(window_ThisWindow, strWindowTitle, './images/popupstyle.css');

	var str='';
   	str+='<TABLE cellSpacing=0 cellPadding=0 width=505 align=center border=0>';
	str+='<TBODY>';
	str+='<TR>';
	str+='<TD vAlign=top height=344 ><img src="' + strProductImage + '" border=0></TD></TR>';
  	str+='<TR class=lineTop><TD height=1></TD></TR>';
  	str+='<TR>';
  	str+='<TD vAlign=top>';
  	str+='<TABLE cellSpacing=0 cellPadding=0 width=505 border=0>';
  	str+='<TBODY>';
  	str+='<TR>';
  	str+='<TD height=17 colspan=5>';
  	str+='<TABLE cellSpacing=0 cellPadding=0 width=505 border=0 class=bar1background>';
  	str+='<TR>';
  	str+='<TD width=8 height=17> </TD>';
  	str+='<TD class=toBarTitle vAlign=middle width=329>Description</TD>';
  	str+='<TD class=toBarTitle vAlign=middle align=left width=64>Price</TD>';
  	str+='<TD class=toBarTitle vAlign=middle align=center width=51></TD>';
  	str+='<TD vAlign=center width=53> </TD></TR>';
  	str+='</TABLE></TD></TR>';
  	str+='<TR class=bar1bottombackground><TD height=1 colspan=5></TD></TR>';
  	str+='<TR>';
  	str+='<TD colspan=5 class=ticketrowbackground>';
  	str+='<TABLE cellSpacing=0 cellPadding=0 width=505 border=0>';
  	str+='<TR>';
  	str+='<TD height=27 width=8> </TD>';
  	str+='<TD vAlign=middle width=329 class=toBarTitle>' + strProductName + '</TD>';
    str+='<TD class=toBarTitle vAlign=middle align=left width=64>' + strCurrency + " " + strPrice + '</TD>';
	str+='<TD class=toBarTitle vAlign=middle align=center width=51></TD>';
  	str+='<TD vAlign=center width=53> </TD></TR>';
  	str+='</TABLE></TD></TR>';
  	str+='<TR class=bar1bottombackground><TD height=1 colspan=5></TD></TR>';
	str+='<TR>';
  	str+='<TD height=17 colspan=5>';
  	str+='<TABLE cellSpacing=0 cellPadding=0 width=505 border=0 class=bar1background>';
  	str+='<TR>';
  	str+='<TD width=8 height=17> </TD>';
  	str+='<TD class=toBarTitle vAlign=middle width=329>Information</TD>';
  	str+='<TD class=toBarTitle vAlign=middle align=left width=64></TD>';
  	str+='<TD class=toBarTitle vAlign=middle align=center width=51></TD>';
  	str+='<TD vAlign=center width=53> </TD></TR>';
  	str+='</TABLE></TD></TR>';
  	str+='</TBODY></TABLE></TD></TR>';
    str+='<TR>';
    str+='<TD vAlign=top height=10 class=greenbar_shadow>';
    str+='</TD></TR>';
    str+='<TR>';
    str+='<TD vAlign=top>';
    str+='<TABLE height=25 cellSpacing=0 cellPadding=0 width=505 border=0 class=infobackground>';
    str+='<TBODY>';
    str+='<TR>';
    str+='<TD width=8> </TD>';
    str+='<TD>';
	str+='<div id="scrollbar" valign=top>';
	str+='<p>' + strProductText + '</p></div>';
	str+='<style type="text/css">';
	str+='#scrollbar';
	str+='{';
	str+='width: 490px;';
	str+='height: 85px;';
	str+='overflow: auto;';
	str+='margin: 0px;';
	str+='padding: 0px;';
	str+='scrollbar-3dlight-color:99CE9A;';
	str+='scrollbar-arrow-color:#FFFFFF;';
	str+='scrollbar-base-color:#003366;';
	str+='scrollbar-darkshadow-color:#083D09;';
	str+='scrollbar-face-color:0E7A10;';
	str+='scrollbar-highlight-color:#99CE9A;';
	str+='scrollbar-track-color:#CBDECB;';
	str+='scrollbar-shadow-color:#083D09';
	str+='}';
	str+='</style>';
	str+='<BR><BR><BR><BR><BR><BR><BR><BR><BR></TD>';
    str+='<TD width=8> </TD></TR>';
    str+='<TR>';
    str+='<TD colSpan=3><IMG height=10 src="images/leeg.gif" width=10>';
    str+='</TD></TR></TBODY></TABLE></TD></TR>';
    str+='</TBODY>';
    str+='</TABLE>';
	
	window_ThisWindow.document.write(str);
    endWindowHeader(window_ThisWindow);
   
   
}