///////////////////////////////////////////////////////////////////////////////
//
//  pageGenerator.js
//
// 
// © 2007 Microsoft Corporation. All Rights Reserved.
//
// This file is licensed as part of the Silverlight 1.0 SDK, for details look here: http://go.microsoft.com/fwlink/?LinkID=89144&clcid=0x409
//
///////////////////////////////////////////////////////////////////////////////

// Controls the content for each page and the set of resources required by them
PageGenerator = function(numPages) {
    this.numPages = numPages;
    this.resourceArray = new Array();
    //this.resourceArray[this.resourceArray.length]= folder + "/logo_name.png";
    //this.resourceArray[this.resourceArray.length]= folder + "/SilverlightBackgroundLight.jpg";

    for (var i=0; i<this.numPages; i++){
        this.resourceArray[this.resourceArray.length] = _imagefolder + "/page" + getTwoDigitInt(i) + ".jpg";
    }
    //this.resourceArray[this.resourceArray.length]= folder + "/logo.png";
}

PageGenerator.prototype.getPageString = function(pageNumber, isThumbnail, vidNode)
{
  var retStr = "";
  if (pageNumber < 0 || pageNumber >= _pagenum)
  {
    return retStr;
  }
  retStr =  "<Canvas>";
  if (pageNumber == 0)
  {

    retStr += "  <Image Height='" + _height + "' Width='" + _width + "' Source='"+_imagefolder+"/page"+getTwoDigitInt(pageNumber)+".jpg'/>";
    //retStr += "  <Ellipse Height='120' Width='120' Canvas.Top='" + (_height - 130) + "' Canvas.Left='" + (_width - 137) + "' Stretch='Fill'>";
    //<Grid x:Name="LayoutRoot" Background="White" >
	//	<Ellipse HorizontalAlignment="Stretch" Margin="194.75,96.5,299.75,235.5" VerticalAlignment="Stretch" Fill="#7FFFB448" Stroke="#FF000000" StrokeThickness="3"/>
	//	<Path Height="86" HorizontalAlignment="Stretch" Margin="219.5,126.5,308.5,0" VerticalAlignment="Top" Data="M220,127 L331,176 L221,212 L237,173 z" Stretch="Fill" Stroke="#FF000000" StrokeThickness="3" Fill="#7FFFFFFF"/>
	//</Grid>
//    retStr += "    <Ellipse.Fill>";
//    retStr += "      <RadialGradientBrush >";
//    retStr += "        <GradientStop Color='#FFFFFFFF' Offset='0'/>";
//    retStr += "        <GradientStop Color='#FFFFFFFF' Offset='0.4'/>";
//    retStr += "        <GradientStop Color='#00FFFFFF' Offset='1'/>";
//    retStr += "      </RadialGradientBrush>";
//    retStr += "    </Ellipse.Fill>";
//    retStr += "  </Ellipse>";
    //retStr += "  <Image Height='80' Canvas.Top='" + (_height - 110) + "' Canvas.Left='" + (_width - 110) + "' Source='assets/logo.png' Stretch='Fill'/>";
  }
  else
  { 
    retStr += "  <Image Height='" + _height + "' Width='" + _width + "' Source='"+_imagefolder+"/page"+getTwoDigitInt(pageNumber)+".jpg'/>";
    if((pageNumber == 4) && (vidNode == 2))
    {
       retStr += " <MediaElement Height='175' Stretch='Fill' MediaEnded='PlayStop' MouseLeftButtonUp='PlayVideo' Width='310' AutoPlay='false' Cursor='Hand' x:Name='th_video_' Source='Magazine/Isu02/Video/BBVA.wmv' Canvas.Left='95' Canvas.Top='88' Opacity='0' />";
    } 
    else
    if((pageNumber == 6) && (vidNode == 12))
    {
        retStr += " <MediaElement Height='320' Stretch='Fill' MediaEnded='PlayStop' MouseLeftButtonUp='PlayVideo' Width='419' AutoPlay='false'  Cursor='Hand' x:Name='th_video_' Source='Magazine/Isu12/Video/video.wmv' Canvas.Left='48' Canvas.Top='87' Opacity='0' />";
    } 
    
  }
  
  //if ((pageNumber % 2) == 1) {
  //    retStr += "  <Path Data='M " + _width + "," + _height + " h -" + _width + " v -" + _height + " h " + _width + "' Stroke='White' StrokeThickness='15'/>";
  //} else {
  //    retStr += "  <Path Data='M 0,0 h " + _width + " v " + _height + " h -" + _width + "' Stroke='White' StrokeThickness='15'/>";
  //}
  
  retStr += "</Canvas>";
  return retStr;
}
