var length;
		
var adNames = new Array();
var adTypes = new Array();
var adClients = new Array();
var adDescriptions = new Array();
var adDirectories = new Array();
var currentType = -1;


adDirectories[0] = "hello world"

	
	$.ajax({
		type: "GET",
		url: "/adgallery/adgallery.xml",
		dataType: "xml",
		success: function(xml) {
		
	    var i =0;
		
		
		 $(xml).find('adgallery').find('item').each(function(){
				//alert ($(this).find('directory').text());
				
				
				adDirectories[i] = $(this).find('directory').text();
				adClients[i] = $(this).find('client').text();
				adNames[i] = $(this).find('name').text();
				adTypes[i] = $(this).find('type').text();
				adDescriptions[i] = $(this).find('description').text();
				
				i++;
			});
		 length = i;
		 
		 try {
		 	swfobject.embedSWF("/adgallery/carousel.swf", "adgallery_carousel", "985", "211", "9.0.0","expressInstall.swf", adgallery_flashvars, adgallery_params, adgallery_attributes);
		 } catch (e){}
		 
		}
											
		
														
	});
	



	

//example: 
//writePlayer('superoverlay_versa', '4.3', '3'); //overlay
//writePlayer('preroll_axe', '4.2', '3', true); //preroll
function doDemoLoad(snapshotVersion, asType, isPreroll, adDirectory){
	$("#videoBox").css("visibility", "visible");
	
	for (var i=0; i<adDirectories.length; i++){
		//alert("adDirectories[" + i +"]: " +adDirectories[i] );
		if (adDirectories[i] == adDirectory){
			$("#demoCampaign").html(adClients[i] + " - " + adNames[i]);
			$("#demoDescription").html(adDescriptions[i]);
			if (currentType!=i){
				$("#demoType").html(adTypes[i]);
				currentType = i;
				$("#demoType").removeClass("sIFR-replaced");
			}
		}
	}
	
	$("#videoPlayerContainer").html('<div id="videoPlayerComponent"></div>');
	writePlayer(adDirectory, snapshotVersion, asType, isPreroll);
	//sIFR.redraw();
	
	sIFR.replace(memphis_med, {
  selector: 'h1.bluedot',
  css: '.sIFR-root {  color: #208eb4; font-weight:bold; font-size:21px; cursor:arrow;}',
   ratios: [8, 1.43, 11, 1.38, 13, 1.33, 17, 1.32, 21, 1.3, 29, 1.29, 30, 1.28, 43, 1.27, 46, 1.26, 47, 1.27, 60, 1.26, 63, 1.25, 64, 1.26, 97, 1.25, 98, 1.24, 101, 1.25, 102, 1.24, 105, 1.25, 106, 1.24, 109, 1.25, 110, 1.24, 112, 1.25, 115, 1.24, 116, 1.25, 119, 1.24, 120, 1.25, 123, 1.24, 124, 1.25, 1.24]
});
	
}

function writePlayer(adDirectory, snapshotVersion, asType, isPreroll){

	var player_flashvars = {
	  file: adDirectory + "/video.flv",
	  width: "448",
	  height: "356",
	  ss_bugPlacement: "left",
	  frontcolor: '0x999999',
	  backcolor: '0x000000',
	  lightcolor: '0xFF0000',
	  showdigits: 'total',
	  volume: '100',
	  ss_partnerId: "567",
	  ss_pageURL: "http://www.scanscout.com",
	  ss_mediaId: "123",
	  ss_adDataFile: "http://www.scanscout.com/adgallery/" + adDirectory + "/adschedule.xml",
	  ss_noLog: "true"	
	};
	var player_params = {
	  allowfullscreen: 'false',
	  allowScriptAccess: "always"
	};
	var player_attributes = {
	  id: "theVideoPlayer",
	  name: "theVideoPlayer"
	};

	if (isPreroll == "true"){
		player_flashvars.ss_usePreroll  ="true";
		player_flashvars.ss_companionId = "compId";
		player_flashvars.ss_companionWidth = "300";
		player_flashvars.ss_companionHeight="250";
		player_flashvars.autostart = false;
	} else {
		player_flashvars.autostart = true;
	}
	


	if (asType == '3'){
		player_flashvars.ss_shellURL = "http://media.scanscout.com/ads/FLASH_SNAPSHOTS/" + snapshotVersion + "/ss_ads3.swf?ss_areURLOverride=http://media.scanscout.com/ads/FLASH_SNAPSHOTS/" + snapshotVersion + "/are3.swf";
		swfobject.embedSWF("as3Player.swf", "videoPlayerComponent", "448", "356", "9.0.0","expressInstall.swf", player_flashvars, player_params, player_attributes);
		
	} else {
		player_flashvars.ss_shellURL ="http://media.scanscout.com/ads/FLASH_SNAPSHOTS/" + snapshotVersion + "/ss_ads2.swf";	
		player_flashvars.ss_areURLOverride ="http://media.scanscout.com/ads/FLASH_SNAPSHOTS/" + snapshotVersion + "/are2.swf";
		swfobject.embedSWF("as2Player.swf", "videoPlayerComponent", "448", "356", "9.0.0","expressInstall.swf", player_flashvars, player_params, player_attributes);

	}
	

}


