<?php

// Call WP Load
$wp_include = "../wp-load.php";$i = 0;
while (!file_exists($wp_include) && $i++ < 10) {$wp_include = "../$wp_include";} require($wp_include);

	$id = $_GET["id"];
	$post_id = (int) $_GET["post_id"];
	$slider_options = cloudfw_get_slider_options($id);	
	
	if ($slider_options["source"] == 'gallery' && is_numeric( $post_id ) && !empty( $post_id ))
		$slider_data = cloudfw_get_post_gallery_source( $post_id );
	else
		$slider_data = cloudfw_get_slider($id);
	
	header("Content-type: text/xml");
	echo '<?xml version="1.0" encoding="utf-8" ?>';
?>
<Piecemaker>
  <Contents>
	<?php 

	$effects = '';
	
	// loop
	foreach ($slider_data as $slider_id => $slider){
		?>			
		<?php if($slider["slider_type"] == 'video' && !empty($slider["slider_source"]) ): ?>
			<Video Source="<?php echo $slider["slider_source"];?>" Title="<?php echo $slider["slider_name"]; ?>" Width="<?php echo $slider_options["width"]; ?>" Height="<?php echo $slider_options["height"]; ?>" Autoplay="true">
		<?php elseif($slider["slider_type"] == 'flash' && !empty($slider["slider_source"]) ): ?>
			<Flash Source="<?php echo $slider["slider_source"];?>" Title="<?php echo $slider["slider_name"]; ?>">
		<?php endif ?>

    	<Image Source="<?php echo $slider["slider_image"]; ?>" Title="<?php echo $slider["slider_name"]; ?>">
    	<?php if($slider["slider_url"]): ?>
    		<Hyperlink URL="<?php echo cloudfw_get_page_link($slider["slider_url"]); ?>" Target="<?php echo _isso($slider["slider_url_target"], $slider["slider_url_target"], '_self');?>" />
	    	<?php endif; ?>
    	</Image>

		<?php if($slider["slider_type"] == 'video' && !empty($slider["slider_source"]) ): ?>
			</Video>
		<?php elseif($slider["slider_type"] == 'flash' && !empty($slider["slider_source"]) ): ?>
			</Flash>
		<?php endif ?>

		
	<?php 
		$effects .= '<Transition Pieces="'. $slider["slider_pieces"] .'" Time="'.$slider["slider_time"].'" Transition="easeInOutBack" Delay="'.$slider["slider_delay"].'" DepthOffset="'.$slider["slider_depth_offset"].'" CubeDistance="'.$slider["slider_cube_distance"].'"></Transition>';
	}
	// end of loop

	?>

  </Contents>
  <Settings ImageWidth="<?php echo $slider_options["width"]; ?>" ImageHeight="<?php echo $slider_options["height"]; ?>" LoaderColor="0xFFFFFF" InnerSideColor="0x222222" SideShadowAlpha="0.8" DropShadowAlpha="<?php echo $slider_options["dropShadowAlpha"]; ?>" DropShadowDistance="15" DropShadowScale="<?php echo $slider_options["dropShadowScale"]; ?>" DropShadowBlurX="40" DropShadowBlurY="4" MenuDistanceX="20" MenuDistanceY="30" MenuColor1="0x999999" MenuColor2="0x333333" MenuColor3="0xFFFFFF" ControlSize="100" ControlDistance="20" ControlColor1="0x<?php echo $slider_options["controlBg"]; ?>" ControlColor2="0x<?php echo $slider_options["controlText"]; ?>" ControlAlpha="<?php echo $slider_options["controlAlpha"]; ?>" ControlAlphaOver="<?php echo $slider_options["controlAlphaOver"]; ?>" ControlsX="<?php echo floor( $slider_options["width"]/2 ); ?>" ControlsY="280&#xD;&#xA;" ControlsAlign="center" TooltipHeight="30" TooltipColor="0x222222" TooltipTextY="5" TooltipTextStyle="P-Italic" TooltipTextColor="0xFFFFFF" TooltipMarginLeft="5" TooltipMarginRight="7" TooltipTextSharpness="50" TooltipTextThickness="-100" InfoWidth="<?php echo floor( $slider_options["width"]/2 ); ?>" InfoBackground="0xFFFFFF" InfoBackgroundAlpha="0.95" InfoMargin="15" InfoSharpness="0" InfoThickness="0" Autoplay="<?php if(_isOnOff($slider_options["autoplay"])) echo $slider_options["pausetime"]; ?>" FieldOfView="<?php echo $slider_options["fieldOfView"]; ?>"></Settings>
  <Transitions>
	<?php echo $effects;?>
  </Transitions>
</Piecemaker>