﻿var _wp_filesadded;
var _wp_widget_js_array;

if (typeof _wp_filesadded == "undefined")
	_wp_filesadded = "";
if (typeof _wp_widget_js_array == "undefined")
	_wp_widget_js_array = new Array();

function isnull(obj) { return typeof obj == "undefined" || obj == null || obj == ""; }

function cp_load_widget(fid, id, host) {

	if (location.href.indexOf("cpdebug=stopall") > -1) {
		alert("stopall");
		return;
	}

	getElement(id).innerHTML = '<img src="http://www.cincopa.com/wpplugin/runtime/loading.gif" style="border:0;"/>';

//	var url = "http://www" + ((Math.random() * 10) | 0) + ".cincopa.com/wpplugin/runtime/widgetasync.aspx?fid=" + fid + "&id=" + id;
	var url = "http://www.cincopa.com/wpplugin/runtime/widgetasync.aspx?fid=" + fid + "&id=" + id;

	if (navigator.userAgent.indexOf("IE") > -1)
		document.write("<script type=\"text/javascript\" src=\"" + url + "\"> </script>");
//	else if (navigator.userAgent.indexOf("Firefox") > -1)
//		loadJSFile(url);
	else
		loadJSFile(url);
}

function loadJSFile(filename) {
	if (filename.toLowerCase().indexOf("http://") == -1)
		filename = _cincopa_url + filename;

	if (_wp_filesadded.indexOf("[" + filename + "]") == -1) {
		var fileref = document.createElement('script');
		fileref.setAttribute("type", "text/javascript");
		fileref.setAttribute("src", filename);

		document.getElementsByTagName("head")[0].appendChild(fileref);

		_wp_filesadded += "[" + filename + "]";
	}
}

function loadCSSFile(filename) {
	if (filename.toLowerCase().indexOf("http://") == -1)
		filename = _cincopa_url + filename;

	if (_wp_filesadded.indexOf("[" + filename + "]") == -1) {
		var fileref = document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href", filename);

		document.getElementsByTagName("head")[0].appendChild(fileref);
		_wp_filesadded += "[" + filename + "]";
	}
}

function merge_json(o1, o2, o3) {
	var o = {};

	for (var z in o1)
		o[z] = o1[z];
	for (var z in o2)
		o[z] = o2[z];
	for (var z in o3)
		o[z] = o3[z];

	return o;
}

var _cp_params_arr = {

	base: {
		w: { p: "w", type: "num", name: "Width", desc: "Width of the gallery" },
		h: { p: "h", type: "num", name: "Height", desc: "Height of the gallery" },

		cooliris: { p: "cooliris", name: "Cooliris", type: "list:no,yes", desc: "Add a [View with Cooliris] link. Cooliris is the fastest and most stunning way to browse photos and videos.", permit: 1 },
		allow_download: { p: "allow_download", name: "Allow Download", type: "list:no,original,resized", desc: "Allow user to download and save all files.<br>* Resized zip contains photos resized to 600x450, videos in flv format and music in original sampling.", permit: 1 },
		//			password: {},
		//			grab_this : {},
		//			right-click save as protection
		//			override_css
		domain_lock: { p: "domain_lock", type: "text", name: "Domain Lock", desc: "Allow this gallery to appear only in the domains on this list. This will prevent others from grabbing your gallery to their site. <br>Type a list of domains separated by comma or leave empty to allow all domains.", permit: 1 },

		remove_branding: { p: "remove_branding", type: "bool", name: "Remove Cincopa Branding", desc: "Remove the Cincopa icon and the 'Powered By Cincopa' text.", permit: 1 }
	},

	belt: {
		iframe: { p: "iframe", type: "bool", name: "iframe", desc: "Enable this option if the gallery is not working properly inside a page and the gallery will be placed in a HTML iframe." },
		thumb_size: { p: "thumb_size", type: "list:small,medium", name: "Thumbnail Size", desc: "Thumbnail Size", permit: 1 },
		content_size: { p: "content_size", type: "list:large,xlarge", name: "Content Size", desc: "Content Size :<br>large = up to 600x450<br>xlarge = up to 1024x768", permit: 1 }
	},

	imagelist: {
		pagination: { p: "pagination", type: "num", name: "Images per page", desc: "Count of images dysplayed per page. 0(zero) means unlimited images.", permit: 1 },
		addcaptionthumb: { p: "addcaptionthumb", type: "bool", name: "Display caption for thumb", desc: "Add image caption below thumb.", permit: 1 },
		loaddefaultcss: { p: "loaddefaultcss", type: "bool", name: "Load Default CSS", desc: "Whether to load the default CSS. When unchecked it allows to override the look of the player using CSS.", permit: 1 }
	},

	cooliris: {
		thumb_size: { p: "thumb_size", type: "list:small,medium", name: "Thumbnail Size", desc: "Thumbnail Size", permit: 1 }
	},

	player311: {
		dw: { p: "dw", type: "num", name: "Display Width", desc: "Width of the display area. The menu width is equal to the player width - display width." },

		content_size: { p: "content_size", type: "list:large,xlarge", name: "Content Size", desc: "Content Size" },

		autostart: { p: "autostart", type: "bool", name: "Auto Start", desc: "Automatically start the player on load.", permit: 1 },
		rotatetime: { p: "rotatetime", type: "num", name: "Rotate Time", desc: "Pause time between two items.", permit: 1 }
	},

	player4160: {
		//			dw: { p:"dw", type:"num", name:"Display Width", desc:"Width of the display area. The playlist width is equal to the player width - display width."},
		//			dh: { p:"dh", type:"num", name:"Display Height", desc:"Height of the display area. The playlist height is equal to the player height - display height."},
		plw: { p: "plw", type: "num", name: "Playlist Height", desc: "Height of the playlist" },

		overridealbumart: { p: "overridealbumart", type: "bool", name: "Override Album Art", desc: "Set your own CD art. <br>* To set your CD art just add the photo to your gallery when you select the music tracks.", permit: 1 },
		repeat: { p: "repeat", type: "list:none,list,always,single", name: "Repeat", desc: "Set to list to play the entire playlist once, to always to continously play the song/video/playlist and to single to continue repeating the selected file in a playlist.", permit: 1 },
		autostart: { p: "autostart", type: "bool", name: "Auto Start", desc: "Automatically start the player on load.", permit: 1 }
	},

	player44: {
		backcolor: { p: "backcolor", type: "color", name: "Back Color", desc: "Background color of the controlbar and playlist.", permit: 1 },
		frontcolor: { p: "frontcolor", type: "color", name: "Front Color", desc: "Color of all icons and texts in the controlbar and playlist.", permit: 1 },
		lightcolor: { p: "lightcolor", type: "color", name: "Light Color", desc: "Color of an icon or text when you rollover it with the mouse.", permit: 1 },
		screencolor: { p: "screencolor", type: "color", name: "Screen Color", desc: "Background color of the display.", permit: 1 },

		controlbar: { p: "controlbar", type: "list:bottom,none,over", name: "Control Bar", desc: "Position of the controlbar. Can be set to bottom, over and none." },
		icons: { p: "icons", type: "bool", name: "Icons", desc: "Set this to false to hide the play button and buffering icon in the middle of the video." },
		playlist: { p: "playlist", type: "list:none,bottom,over,right", name: "Playlist", desc: "Position of the playlist. Can be set to bottom, over, right or none." },
		playlistsize: { p: "playlistsize", type: "num", name: "Playlist Size", desc: "When Playlist=bottom this refers to the height, when right this refers to the width of the playlist. " },
		autostart: { p: "autostart", type: "bool", name: "Auto Start", desc: "Automatically start the player on load." },
		displayclick: { p: "displayclick", type: "list:play,link,fullscreen,none,mute,next", name: "Display Click", desc: "What to do when one clicks the display. Can be play, link, fullscreen, none, mute, next. When set to none, the handcursor is also not shown.", permit: 1 },
		item: { p: "item", type: "num", name: "Start Item", desc: "Item that should start to play. Use this to set a specific start-item." },
		linktarget: { p: "linktarget", type: "list:_blank,_self", name: "Link Target", desc: "browserframe where link from the display are opened in. Can be '_self' (same frame) or '_blank' (new browserwindow)." },
		logo: { p: "logo", type: "text", name: "Watermark Logo", desc: "Location of an external jpg, png or gif image to show in a corner of the display.", permit: 1 },
		mute: { p: "mute", type: "bool", name: "Mute", desc: "Mute all sounds on startup.", permit: 1 },
		repeat: { p: "repeat", type: "list:none,list,always,single", name: "Repeat", desc: "Set to list to play the entire playlist once, to always to continously play the song/video/playlist and to single to continue repeating the selected file in a playlist." },
		//			shuffle: { p:"shuffle", type:"bool", name:"Shuffle", desc:"Shuffle playback of playlist items."},
		stretching: { p: "stretching", type: "list:uniform,none,exactfit,fill", name: "Stretching", desc: "Defines how to resize images in the display. Can be none (no stretching), exactfit (disproportionate), uniform (stretch with black borders) or fill (uniform, but completely fill the display)." },
		volume: { p: "volume", type: "num", name: "Volume", desc: "Startup volume of the player. Can be 0 to 100. Is saved in a cookie.", permit: 1 },
		bufferlength: { p: "bufferlength", type: "num", name: "Buffer Length ", desc: "Number of seconds of the file that has to be loaded before starting. Set this to a low value to enable instant-start and to a high value to get less mid-stream buffering.<br><br>Default is 1", permit: 1 },
		grab_this: { p: "grab_this", type: "bool", name: "Allow Grab", desc: "Enable this feature to allow your viewer to grab this gallery and embed it in their site, blog or profile.", permit: 1 }
	},

	audioplayer: {
		allowdownload: { p: "allowdownload", type: "bool", name: "Allow Download", desc: "Add a Download button and allow to download the original music file.<br><br>* Make sure your music is legal - we don't like piracy.", permit: 1 },
		albumcoverart: { p: "albumcoverart", type: "list:auto,hide", name: "Album Cover Art", desc: "What image to show. Auto:Find the image from album database.", permit: 1 },
		loaddefaultcss: { p: "loaddefaultcss", type: "bool", name: "Load Default CSS", desc: "Whether to load the default CSS. When unchecked it allows to override the look of the player using CSS.", permit: 1 },

		pw: { p: "pw", type: "num", name: "Player Width", desc: "Width of the player itself", permit: 1 },
		ph: { p: "ph", type: "num", name: "Player Height", desc: "Height of the player itself", permit: 1 },

		bg: { p: "bg", type: "color", name: "Background color", desc: "Background color of the player.", permit: 1 },
		leftbg: { p: "leftbg", type: "color", name: "Left background color", desc: "Left background color of the player.", permit: 1 },
		rightbg: { p: "rightbg", type: "color", name: "Right background color", desc: "Right background color of the player.", permit: 1 },
		rightbghover: { p: "rightbghover", type: "color", name: "Right hover background color", desc: "Right hover background color of the player.", permit: 1 },
		lefticon: { p: "lefticon", type: "color", name: "Left icon color", desc: "Left icon color.", permit: 1 },
		righticon: { p: "righticon", type: "color", name: "Right icon color", desc: "Right icon color.", permit: 1 },
		righticonhover: { p: "righticonhover", type: "color", name: "Right icon hover color", desc: "Right icon hover color.", permit: 1 },
		text: { p: "text", type: "color", name: "Text color", desc: "Text color.", permit: 1 },
		slider: { p: "slider", type: "color", name: "Slider color", desc: "Slider color.", permit: 1 },
		track: { p: "track", type: "color", name: "Track color", desc: "Track color.", permit: 1 },
		border: { p: "border", type: "color", name: "Border color", desc: "Border color.", permit: 1 },
		loader: { p: "loader", type: "color", name: "Loader color", desc: "Loader color.", permit: 1 }
	}
};

var _wp_widget_arr = {

	styleplayer44: { visible: false, pm: "j1", w: 600, h: 450, grp: "Player44", t: "Video Player (600x450)", ex: "10474999", nojson: true,
		js_inc: ["player44/player44.js"], flash_fallback: true,
		func: "cp_js_widget_code_player44", playlist: "none", autostart: true, stretching: "fill", icons: true,
		params: merge_json(_cp_params_arr.base, _cp_params_arr.player44)
	},

	stylebelt2: { pm: "j1", w: 200, h: 150, grp: "Simple slideshow", t: "Plain rotation - Small (200x180)", ex: "10464405",
		js_inc: ["belt/belt.js"],
		css_inc: ["belt/jq.css", "belt/jquery.lightbox-0.5.css"],
		serial_js_inc: [
			{ func: "jQuery", inc: "belt/jquery-1.2.6.pack.js" },
			{ func: "jQuery.fn.cycle", inc: "belt/jquery.cycle.all.js" },
			{ func: "jQuery.fn.lightBox05", inc: "belt/jquery.lightbox-0.5.js"}],
		func: "wp_js_widget_code_belt_plain_photo", thumb_size: "medium", content_size: "large", img_thumb: "img/belt2.gif",
		params: merge_json(_cp_params_arr.base, _cp_params_arr.belt, {
			rotatetime: { p: "rotatetime", type: "num", name: "Rotate Time", desc: "Rotate time in seconds", permit: 1 }
		})
	},

	stylebelt4: { pm: "j1", w: 200, h: 150, grp: "Simple slideshow", t: "Shuffle rotation - Small (200x180)", ex: "10464405",
		js_inc: ["belt/belt.js"],
		css_inc: ["belt/jq.css", "belt/jquery.lightbox-0.5.css"],
		serial_js_inc: [
			{ func: "jQuery", inc: "belt/jquery-1.2.6.pack.js" },
			{ func: "jQuery.fn.cycle", inc: "belt/jquery.cycle.all.js" },
			{ func: "jQuery.fn.lightBox05", inc: "belt/jquery.lightbox-0.5.js"}],
		func: "wp_js_widget_code_belt_shuffle_photo", thumb_size: "medium", content_size: "large", img_thumb: "img/belt4.gif",
		params: merge_json(_cp_params_arr.base, _cp_params_arr.belt, {
			rotatetime: { p: "rotatetime", type: "num", name: "Rotate Time", desc: "Rotate time in seconds", permit: 1 }
		})
	},

	styleimagelist: { pm: "j1", w: "100%", h: "100%", grp: "Simple slideshow", t: "Image list", ex: "10464405",
		js_inc: ["belt/belt.js"],
		css_inc: ["belt/jq.css", "belt/jquery.lightbox-0.5.css"],
		serial_js_inc: [
			{ func: "jQuery", inc: "belt/jquery-1.2.6.pack.js" },
			{ func: "jQuery.fn.lightBox05", inc: "belt/jquery.lightbox-0.5.js"}],
		func: "cp_js_widget_code_imagelist", thumb_size: "small", content_size: "large", img_thumb: "img/imagelist.gif",
		params: merge_json(_cp_params_arr.base, _cp_params_arr.belt)
	},

	styleimagelistv2: { visible: false, pm: "j1", w: "100%", h: "100%", grp: "Simple slideshow", t: "Image list Version 2", ex: "10464405",
		js_inc: ["imagelist/lytebox.js", "imagelist/imagelist.js"],
		css_inc: ["imagelist/lytebox.css"],
		func: "cp_js_widget_code_imagelistv2", thumb_size: "small", content_size: "large", img_thumb: "img/imagelist.gif",
		params: merge_json(_cp_params_arr.base, _cp_params_arr.belt, _cp_params_arr.imagelist),
		pagination: 0,
		addcaptionthumb: false,
		loaddefaultcss: true
	},

	styleslideshowpro: { visible: false, pm: "j1", w: 400, h: 300, grp: "Slideshows", t: "Slideshow with background music (400x300)", ex: "10464405", nojson: true,
		js_inc: ["slideshowpro/swfobject.js", "slideshowpro/slideshowpro.js"], flash_fallback: true,
		func: "cp_js_widget_code_slideshowpro",
		params: merge_json(_cp_params_arr.base, {
			bgmusic: { p: "bgmusic", type: "bool", name: "Background Music", desc: "Enable background music. <br>* To select a music track just add it to your gallery when you select the photos.", permit: 0 },
			showtitle: { p: "showtitle", type: "bool", name: "Show Title", desc: "Show the image title", permit: 1 },
			titlecolor: { p: "titlecolor", type: "color", name: "Title Color", desc: "Title text color", permit: 1 },
			rotatetime: { p: "rotatetime", type: "num", name: "Rotate Time", desc: "Rotate time in seconds", permit: 1 },
			transition: { p: "transition", type: "list:none,dissolve,fade_to_black,fade_to_white,drop,spin,zoom,push_right,push_left,push_up,push_down,cover_right,cover_left,cover_up,cover_down,reveal_right,reveal_left,reveal_up,reveal_down,squeeze_right,squeeze_left,squeeze_up,squeeze_down,pivot_left_top_up, pivot_left_top_down, pivot_right_top_up, pivot_right_top_down, pivot_left_bottom_up,pivot_left_bottom_down,pivot_right_bottom_up,pivot_right_bottom_down", name: "Visual Transition ", desc: "Sets the visual transition between the previous slide and the current slide.", permit: 1 },
			bg: { p: "bg", type: "color", name: "Background color", desc: "Background color of the player.", permit: 1 }
		})
	},


	/*
	stylebelt1: { pm:"j1", w:600, h:175, grp:"Simple slideshow", t:"Belt - large (600x180)", ex:"10464405", 
	js_inc: ["belt/jquery-1.2.6.pack.js", "belt/belt.js"],
	css_inc: ["belt/jq.css", "belt/jquery.lightbox-0.5.css"],
	serial_js_inc: [
	{ func:"$.fn.jCarouselLite", inc:"belt/jcarousellite_1.0.1.js"}, 
	{ func:"$.fn.lightBox05", inc:"belt/jquery.lightbox-0.5.js" }],
	func:"wp_js_widget_code_belt_step_photo"
	},
	*/
	stylebelt3: { pm: "j1", w: 200, h: 150, grp: "Simple slideshow", t: "Cover rotation - Small (200x180)", ex: "10464405",
		js_inc: ["belt/belt.js"],
		css_inc: ["belt/jq.css", "belt/jquery.lightbox-0.5.css"],
		serial_js_inc: [
			{ func: "jQuery", inc: "belt/jquery-1.2.6.pack.js" },
			{ func: "jQuery.fn.cycle", inc: "belt/jquery.cycle.all.js" },
			{ func: "jQuery.fn.lightBox05", inc: "belt/jquery.lightbox-0.5.js"}],
		func: "wp_js_widget_code_belt_cover_photo", thumb_size: "medium", content_size: "large", img_thumb: "img/belt3.gif",
		params: merge_json(_cp_params_arr.base, _cp_params_arr.belt, {
			rotatetime: { p: "rotatetime", type: "num", name: "Rotate Time", desc: "Rotate time in seconds", permit: 1 }
		})
	},

	stylep1: {
		pm: "j1", w: 200, h: 150, grp: "Simple slideshow", t: "Plain rotation only thumbs - Small (200x180)", ex: "10464405", content_size: "large,v:3gp_lowres,a:original", type: "plain",
		thumb_link: "thumbnail_url",
		func: wp_js_widget_code_rotating_photo, thumb_size: "medium", content_size: "large", img_thumb: "img/p1.gif",
		params: merge_json(_cp_params_arr.base, {
			iframe: { p: "iframe", type: "bool", name: "iframe", desc: "Enable this option if the gallery is not working properly inside a page and the gallery will be placed in a HTML iframe." },
			thumb_size: { p: "thumb_size", type: "list:small,medium,large", name: "Image Size", desc: "Image Size", permit: 1 },
			rotatetime: { p: "rotatetime", type: "num", name: "Rotate Time", desc: "Rotate time in seconds", permit: 1 }
		})
	},

	stylep3: { pm: "j1", w: 600, h: 450, grp: "Simple slideshow", t: "Plain rotation - Large (600x450)", ex: "10464405", popup_large: "false", thumb_link: "content_url",
		js_inc: ["belt/belt.js"],
		css_inc: ["belt/jq.css", "belt/jquery.lightbox-0.5.css"],
		serial_js_inc: [
			{ func: "jQuery", inc: "belt/jquery-1.2.6.pack.js" },
			{ func: "jQuery.fn.cycle", inc: "belt/jquery.cycle.all.js" },
			{ func: "jQuery.fn.lightBox05", inc: "belt/jquery.lightbox-0.5.js"}],
		func: "wp_js_widget_code_belt_plain_photo", rotatetime: 5, thumb_size: "medium", content_size: "large", img_thumb: "img/p3.gif",
		params: merge_json(_cp_params_arr.base, _cp_params_arr.belt, {
			rotatetime: { p: "rotatetime", type: "num", name: "Rotate Time", desc: "Rotate time in seconds", permit: 1 }
		})
	},
/*
	stylesmoothgallery: { pm: "j1", w: 620, h: 470, grp: "Simple slideshow", t: "Smooth Gallery - Large (600x450)", ex: "10473009",
		js_inc: ["smoothgallery/scripts/all.js"],
		css_inc: ["smoothgallery/css/jd.gallery.css"], iframe: "true",
		func: "wp_js_widget_code_smoothgallery", thumb_size: "small", content_size: "large", img_thumb: "img/smoothgallery.gif",
		params: merge_json(_cp_params_arr.base, _cp_params_arr.belt)
	},
*/
	stylesmoothgallery: { pm: "j1", w: 600, h: 450, grp: "Simple slideshow", t: "Smooth Gallery - Large (600x450)", ex: "10473009",
		js_inc: ["smoothgallery/scripts/all.js"],
		css_inc: ["smoothgallery/css/jd.gallery.css"],
		showarrows: true, showcarousel: true, showinfopane: true, autorotate: true, carouseltext: "Pictures", loadingtext: "Loading...", rotatetime: "9",
		thumbspacing: "10", thumbopacity: "2", wipeinfopane: true, infopaneopacity: "7", carouselcloseopacity: "4", carouselopenopacity: "9", transitiontime: 500,
		func: "wp_js_widget_code_smoothgalleryv2", thumb_size: "small", content_size: "large", img_thumb: "img/smoothgallery.gif",
		params: merge_json(_cp_params_arr.base, _cp_params_arr.belt, {
			loadingtext: { p: "loadingtext", type: "text", name: "Loading Text", desc: "This text will appear while gallery is loading." },
			carouseltext: { p: "carouseltext", type: "text", name: "Carousel Text", desc: "The text of the open carousel button." },

			showarrows: { p: "showarrows", type: "bool", name: "Show Arrows", desc: "Show or hide the left and right arrows.", permit: 1 },
			showcarousel: { p: "showcarousel", type: "bool", name: "Show Carousel", desc: "Show or hide the carousel.", permit: 1 },
			showinfopane: { p: "showinfopane", type: "bool", name: "Show Info Pane", desc: "Show or hide the bottom info pane.", permit: 1 },
			wipeinfopane: { p: "wipeinfopane", type: "bool", name: "Wipe Info Pane", desc: "Info pane should wipe-in or fade-in.", permit: 1 },
			infopaneopacity: { p: "infopaneopacity", type: "num", name: "Info Pane opacity", desc: "How transparent is the info pane, number between 0-10 (default is 7).", permit: 1 },

			carouselcloseopacity: { p: "carouselcloseopacity", type: "num", name: "Carousel Close Opacity", desc: "How transparent is the carousel when closed, number between 0-10 (default is 4).", permit: 1 },
			carouselopenopacity: { p: "carouselopenopacity", type: "num", name: "Carousel Open Opacity", desc: "How transparent is the carousel when open, number between 0-10 (default is 9).", permit: 1 },

			thumbspacing: { p: "thumbspacing", type: "num", name: "Thumb Spacing", desc: "Space between the thumbs.", permit: 1 },
			thumbopacity: { p: "thumbopacity", type: "num", name: "Thumb opacity", desc: "How transparent are the thumbs, number between 0-10 (default is 2).", permit: 1 },

			transitiontime: { p: "transitiontime", type: "num", name: "Transition Time", desc: "How fast is the transition between items in 1/1000 of a second (default is 500)", permit: 1 },

			autorotate: { p: "autorotate", type: "bool", name: "Auto Rotate", desc: "Automatically rotate between items.", permit: 1 },
			rotatetime: { p: "rotatetime", type: "num", name: "Rotate Time", desc: "Rotate time in seconds", permit: 1 }
		})
	},

	stylecooliris: {
		pm: "j1", w: 200, h: 150, grp: "Simple slideshow", t: "Cooliris on click, Plain rotation - Small (200x180)", ex: "10464405", content_size: "xlarge,v:flv_lowres,a:original", type: "cooliris",
		thumb_link: "thumbnail_url",
		func: wp_js_widget_code_rotating_photo, thumb_size: "medium", img_thumb: "img/cooliris.gif",
		params: merge_json(_cp_params_arr.base, _cp_params_arr.cooliris, {
			rotatetime: { p: "rotatetime", type: "num", name: "Rotate Time", desc: "Rotate time in seconds", permit: 1 }
		})
	},

	stylesimpleviewer: {
		pm: "j1", w: 800, h: 400, grp: "Flash Photo Gallery", t: "SimpleViewer - (800x400)", ex: "10464405", nojson: true,
		js_inc: ["airtightinteractive/airtigh.js"], flash_fallback: true,
		func: "cp_js_widget_code_airtigh_simpleviewer", img_thumb: "img/simpleviewer.gif",
		maximagewidth: 480, maximageheight: 480, textcolor: "0xFFFFFF", framecolor: "0xFFFFFF", framewidth: 20, stagepadding: 40, navpadding: 40, thumbnailcolumns: 3, thumbnailrows: 3, navposition: "left", valign: "center", halign: "center", title: "Gallery", enablerightclickopen: true,
		params: merge_json(_cp_params_arr.base, {
			maximagewidth: { p: "maximagewidth", type: "num", name: "Max Image Width", desc: "Width of the widest image in the gallery. Used to determine the best layout for your gallery (pixels)." },
			maximageheight: { p: "maximageheight", type: "num", name: "Max Image Height", desc: "Height of tallest image in the gallery. Used to determine the best layout for your gallery (pixels)." },
			textcolor: { p: "textcolor", type: "color", name: "Text Color", desc: "Color of title and caption text (hexidecimal color value).", permit: 1 },
			framecolor: { p: "framecolor", type: "color", name: "Frame Color", desc: "Color of image frame, navigation buttons and thumbnail frame (hexidecimal color value).", permit: 1 },
			framewidth: { p: "framewidth", type: "num", name: "Frame Width", desc: "Width of image frame (pixels).", permit: 1 },
			stagepadding: { p: "stagepadding", type: "num", name: "Stage Padding", desc: "Width of padding around gallery edge (pixels). To have the image flush to the edge of the widget, set this to 0.", permit: 1 },
			navpadding: { p: "navpadding", type: "num", name: "Nav Padding", desc: "Distance between image and thumbnails (pixels). ", permit: 1 },
			thumbnailcolumns: { p: "thumbnailcolumns", type: "num", name: "Thumbnail Columns", desc: "Number of thumbnail columns. To disable thumbnails completely set this value to 0", permit: 1 },
			thumbnailrows: { p: "thumbnailrows", type: "num", name: "Thumbnail Rows", desc: "Number of thumbnail rows. To disable thumbnails completely set this value to 0.", permit: 1 },
			navposition: { p: "navposition", type: "list:top,bottom,left,right", name: "Nav Position", desc: "Position of thumbnails relative to image. Can be 'top', 'bottom','left' or 'right'.", permit: 1 },
			valign: { p: "valign", type: "list:center,top,bottom", name: "V Align", desc: "Vertical placment of the image and thumbnails within the widget. Can be 'center', 'top' or 'bottom'.<br>For large format galleries this is best set to 'center'. For small format galleries setting this to 'top' or 'bottom' can help get the image flush to the edge of the widget.", permit: 1 },
			halign: { p: "halign", type: "list:center,left,right", name: "H Align", desc: "Horizontal placement of the image and thumbnails within the widget. Can be 'center', 'left' or 'right'.<br>For large format galleries this is best set to 'center'. For small format galleries setting this to 'left' or 'right' can help get the image flush to the edge of the widget.", permit: 1 },
			title: { p: "title", type: "text", name: "Title", desc: "Text to display as gallery Title", permit: 1 },
			enablerightclickopen: { p: "enablerightclickopen", type: "bool", name: "Enable Right Click Open", desc: "Whether to display a 'Open In new Window...' dialog when right-clicking on an image. Can be 'true' or 'false'", permit: 1 }
		})
	},

	styletiltviewer: {
		pm: "j1", w: 800, h: 400, grp: "Flash Photo Gallery", t: "TiltViewer - (800x400)", ex: "10464405", nojson: true,
		js_inc: ["airtightinteractive/airtigh.js"], flash_fallback: true,
		func: "cp_js_widget_code_airtigh_tiltviewer", img_thumb: "img/tiltviewer.gif",
		cols: 8, rows: 4, fullscreen: true, framecolor: "0xFFFFFF", backcolor: "0xFFCB47", bkgndinnercolor: "0x555555", bkgndoutercolor: "0x000000", showflipbutton: true, showlinkbutton: true,
		params: merge_json(_cp_params_arr.base, {
			cols: { p: "cols", type: "num", name: "Columns", desc: "Number of columns of images to display.", permit: 1 },
			rows: { p: "rows", type: "num", name: "Rows", desc: "Number of rows of images to display. ", permit: 1 },
			fullscreen: { p: "fullscreen", type: "bool", name: "Allow Fullscreen", desc: "Whether to allow the 'Go Fullscreen' right-click menu option. ", permit: 1 },

			showflipbutton: { p: "showflipbutton", type: "bool", name: "Show Flip Button", desc: "Whether to display the 'flip' button at the bottom-right of a zoomed in image. Affects all images.", permit: 1 },
			showlinkbutton: { p: "showlinkbutton", type: "bool", name: "Show Link Button", desc: "Whether to display the 'Read More...' button on the image flipside. <br><br>Set the link to the page later at the set text page by adding the following text at the end of each item's caption : [...]http://www.yoururl.com/subpage", permit: 1 },

			framecolor: { p: "framecolor", type: "color", name: "Frame Color", desc: "Hexadecimal color value of the image frame.", permit: 1 },
			backcolor: { p: "backcolor", type: "color", name: "Back Color", desc: "Hexadecimal color value of the flipside background. ", permit: 1 },
			bkgndinnercolor: { p: "bkgndinnercolor", type: "color", name: "Background Inner Color", desc: "Hexadecimal color value of the stage background gradient center.", permit: 1 },
			bkgndoutercolor: { p: "bkgndoutercolor", type: "color", name: "Background Outer Color", desc: "Hexadecimal color value of the stage background gradient edge.", permit: 1 }
		})
	},

	styleautoviewer: {
		pm: "j1", w: 800, h: 400, grp: "Flash Photo Gallery", t: "AutoViewer - (800x400)", ex: "10464405", nojson: true,
		js_inc: ["airtightinteractive/airtigh.js"], flash_fallback: true,
		func: "cp_js_widget_code_airtigh_autoviewer", img_thumb: "img/autoviewer.gif",
		params: _cp_params_arr.base
	},

	stylepostcardviewer: {
		pm: "j1", w: 800, h: 400, grp: "Flash Photo Gallery", t: "Postcard Viewer - (800x400)", ex: "10464405", nojson: true,
		js_inc: ["airtightinteractive/airtigh.js"], flash_fallback: true,
		func: "cp_js_widget_code_airtigh_postcardviewer", img_thumb: "img/postcardviewer.gif",
		params: _cp_params_arr.base
	},

	styleplayer44_7: { pm: "j1", w: 320, h: 570, grp: "Video Players", t: "Video Player with Bottom Playlist (320x570)", ex: "10474999", nojson: true,
		js_inc: ["player44/player44.js"], flash_fallback: true, img_thumb: "img/player44_7.png",
		func: "cp_js_widget_code_player44", playlist: "bottom", autostart: false, stretching: "fill", icons: true, playlistsize: 284,
		params: merge_json(_cp_params_arr.base, _cp_params_arr.player44)
	},

	styleplayer44_8: { pm: "j1", w: 512, h: 430, grp: "Video Players", t: "Video Player Single Video (512x430)", ex: "10474999", nojson: true,
		js_inc: ["player44/player44.js"], flash_fallback: true, img_thumb: "img/player44_8.png",
		func: "cp_js_widget_code_player44", playlist: "none", autostart: false, stretching: "fill", icons: true,
		params: merge_json(_cp_params_arr.base, _cp_params_arr.player44)
	},

	styleplayer44_8w: { pm: "j1", w: 512, h: 334, grp: "Video Players", t: "Widescreen Single Video (512x334)", ex: "10474999", nojson: true,
		js_inc: ["player44/player44.js"], flash_fallback: true, img_thumb: "img/player44_8w.png",
		func: "cp_js_widget_code_player44", playlist: "none", autostart: false, stretching: "exactfit", icons: true,
		params: merge_json(_cp_params_arr.base, _cp_params_arr.player44)
	},

	styleplayer44_9: { pm: "j1", w: 1012, h: 430, grp: "Video Players", t: "Video Player with Right Playlist (1012x430)", ex: "10474999", nojson: true,
		js_inc: ["player44/player44.js"], flash_fallback: true, img_thumb: "img/player44_9.png",
		func: "cp_js_widget_code_player44", playlist: "right", autostart: false, stretching: "fill", icons: true, playlistsize: 500,
		params: merge_json(_cp_params_arr.base, _cp_params_arr.player44)
	},

	styleplayer44_2: { pm: "j1", w: 660, h: 334, grp: "Video Players", t: "Widescreen with Vertical Video List (660x334)", ex: "10474999", nojson: true,
		js_inc: ["player44/player44.js"], flash_fallback: true, img_thumb: "img/player44_2.png",
		func: "cp_js_widget_code_player44", playlist: "right", autostart: false, stretching: "exactfit", icons: true, playlistsize: 145, disabletext: true,
		params: merge_json(_cp_params_arr.base, _cp_params_arr.player44)
	},
	style1: { pm: "p3", w: 350, h: 140, dw: 180, grp: "Simple Video player", t: "Video player 16:9 with menu  - Small (350x140)", ex: "10474999", content_size: "xlarge", stretch: true, img_thumb: "img/jwmenuwide.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style2: { pm: "p3", w: 450, h: 200, dw: 260, grp: "Simple Video player", t: "Video player 16:9 with menu  - Medium (450x200)", ex: "10474999", content_size: "xlarge", stretch: true, img_thumb: "img/jwmenuwide.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style3: { pm: "p3", w: 600, h: 300, dw: 440, grp: "Simple Video player", t: "Video player 16:9 with menu  - Large (600x300)", ex: "10474999", content_size: "xlarge", stretch: true, img_thumb: "img/jwmenuwide.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },

	style4: { pm: "p3", w: 350, h: 210, dw: 350, grp: "Simple Video player", t: "Video player 16:9 without menu  - Small (350x210)", ex: "10474999", content_size: "xlarge", stretch: true, img_thumb: "img/jwwide.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style5: { pm: "p3", w: 450, h: 260, dw: 450, grp: "Simple Video player", t: "Video player 16:9 without menu  - Medium (450x260)", ex: "10474999", content_size: "xlarge", stretch: true, img_thumb: "img/jwwide.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style6: { pm: "p3", w: 600, h: 350, dw: 600, grp: "Simple Video player", t: "Video player 16:9 without menu  - Large (600x350)", ex: "10474999", content_size: "xlarge", stretch: true, img_thumb: "img/jwwide.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },

	style2s: { pm: "p3", w: 430, h: 200, dw: 240, grp: "Simple Video player", t: "Video player 4:3 with menu  - Medium (430x200)", ex: "10474999", content_size: "xlarge", img_thumb: "img/jwmenu.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style3s: { pm: "p3", w: 540, h: 300, dw: 374, grp: "Simple Video player", t: "Video player 4:3 with menu  - Large (540x300)", ex: "10474999", content_size: "xlarge", img_thumb: "img/jwmenu.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style5s: { pm: "p3", w: 320, h: 260, dw: 320, grp: "Simple Video player", t: "Video player 4:3 without menu  - Medium (320x260)", ex: "10474999", content_size: "xlarge", img_thumb: "img/jw.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style6s: { pm: "p3", w: 440, h: 350, dw: 440, grp: "Simple Video player", t: "Video player 4:3 without menu  - Large (440x350)", ex: "10474999", content_size: "xlarge", img_thumb: "img/jw.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },

	stylemaani: { pm: "j1", w: 400, h: 300, grp: "Slideshows", t: "Slideshow with background music (400x300)", ex: "10496739", nojson: true,
		js_inc: ["maani/maani.js"], flash_fallback: true,
		func: "cp_js_widget_code_maani", transition: "zoom", bgmusic: "true", img_thumb: "img/stylemaani.gif",
		params: merge_json(_cp_params_arr.base, {
			bgmusic: { p: "bgmusic", type: "bool", name: "Background Music", desc: "Enable background music. <br>* To select a music track just add it to your gallery when you select the photos.", permit: 0 },
			showtitle: { p: "showtitle", type: "bool", name: "Show Title", desc: "Show the image title", permit: 1 },
			titlecolor: { p: "titlecolor", type: "color", name: "Title Color", desc: "Title text color", permit: 1 },
			rotatetime: { p: "rotatetime", type: "num", name: "Rotate Time", desc: "Rotate time in seconds", permit: 1 },
			transition: { p: "transition", type: "list:none,dissolve,fade_to_black,fade_to_white,drop,spin,zoom,push_right,push_left,push_up,push_down,cover_right,cover_left,cover_up,cover_down,reveal_right,reveal_left,reveal_up,reveal_down,squeeze_right,squeeze_left,squeeze_up,squeeze_down,pivot_left_top_up, pivot_left_top_down, pivot_right_top_up, pivot_right_top_down, pivot_left_bottom_up,pivot_left_bottom_down,pivot_right_bottom_up,pivot_right_bottom_down", name: "Visual Transition ", desc: "Sets the visual transition between the previous slide and the current slide.", permit: 1 },
			bg: { p: "bg", type: "color", name: "Background color", desc: "Background color of the player.", permit: 1 }
		})
	},

	stylepla24: { pm: "p4", w: 492, h: 400, dw: 0, dh: 0, plw: 0, grp: "Slideshows", t: "Tutorial player - Large (492x400)", ex: "10474999", playlist: "over", skin: "stijl.swf", repeat: "always", thumb_size: "medium", img_thumb: "img/styletutorial.gif" },

	style7: { pm: "p3", w: 350, h: 282, dw: 350, grp: "Slideshows", t: "Slideshow - Small (350x282)", ex: "10464405", content_size: "xlarge", img_thumb: "img/styleslideshow.gif", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style8: { pm: "p3", w: 450, h: 357, dw: 450, grp: "Slideshows", t: "Slideshow - Medium (450x357)", ex: "10464405", content_size: "xlarge", img_thumb: "img/styleslideshow.gif", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style9: { pm: "p3", w: 600, h: 470, dw: 600, grp: "Slideshows", t: "Slideshow - Large (600x470)", ex: "10464405", content_size: "xlarge", img_thumb: "img/styleslideshow.gif", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style10: { pm: "p3", w: 350, h: 140, dw: 160, grp: "Slideshows", t: "Slideshow with menu - Small (350x140)", ex: "10464405", content_size: "xlarge", img_thumb: "img/styleslideshow.gif", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style11: { pm: "p3", w: 450, h: 200, dw: 240, grp: "Slideshows", t: "Slideshow with menu - Medium (450x200)", ex: "10464405", content_size: "xlarge", img_thumb: "img/styleslideshow.gif", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },
	style12: { pm: "p3", w: 600, h: 320, dw: 400, grp: "Slideshows", t: "Slideshow with menu - Large (600x320)", ex: "10464405", content_size: "xlarge", img_thumb: "img/styleslideshow.gif", params: merge_json(_cp_params_arr.base, _cp_params_arr.player311) },

	styleaudioplayer: { pm: "j1", w: 600, h: 500, grp: "Podcast and Music", t: "Podcast - Big (600x500)", ex: "10465673", nojson: true,
		js_inc: ["audioplayer/audioplayer.js"], flash_fallback: true, img_thumb: "img/audioplayer.gif",
		func: "cp_js_widget_code_audioplayer", pw: 290, ph: 25, allowdownload: true, albumcoverart: true, albumcoverart: "auto", loaddefaultcss: true,
		params: merge_json(_cp_params_arr.base, _cp_params_arr.audioplayer)
	},

	style20: { pm: "p4", w: 300, h: 20, dw: 0, dh: 0, plw: 0, grp: "Podcast and Music", t: "Music player without menu - Tiny (300x20)", ex: "10465673", playlist: "bottom", repeat: "always", img_thumb: "img/jwaudio.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player4160) },
	style21: { pm: "p4", w: 300, h: 82, dw: 0, dh: 0, plw: 62, grp: "Podcast and Music", t: "Music player with menu - Small (300x82)", ex: "10465673", playlist: "bottom", repeat: "always", img_thumb: "img/jwaudio1.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player4160) },
	style22: { pm: "p4", w: 300, h: 141, dw: 0, dh: 0, plw: 121, grp: "Podcast and Music", t: "Music player with menu - Small (300x142)", ex: "10465673", playlist: "bottom", repeat: "always", img_thumb: "img/jwaudio2.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player4160) },
	style23: { pm: "p4", w: 400, h: 300, dw: 0, dh: 0, plw: 280, grp: "Podcast and Music", t: "Music player with menu - Medium (400x300)", ex: "10465673", playlist: "bottom", repeat: "always", img_thumb: "img/jwaudio3.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player4160) },
	style24: { pm: "p4", w: 400, h: 400, dw: 0, dh: 0, plw: 380, grp: "Podcast and Music", t: "Music player with menu - Large (400x400)", ex: "10465673", playlist: "bottom", repeat: "always", img_thumb: "img/jwaudio5.png", params: merge_json(_cp_params_arr.base, _cp_params_arr.player4160) },
	style20a: { pm: "p4", w: 300, h: 20, dw: 0, dh: 0, plw: 0, grp: "Podcast and Music", t: "Music player auto start - Tiny (300x20)", ex: "10465673", playlist: "bottom", autostart: true, img_thumb: "img/jwaudio.png", repeat: "always", params: merge_json(_cp_params_arr.base, _cp_params_arr.player4160) },

	stylepushbox: { visible: false, pm: "j1", w: 900, h: 300, grp: "Menus", t: "Pushbox (900x300)", ex: "10531270", nojson: true,
		js_inc: ["pushbox/swfobject.js", "pushbox/pushbox.js"], flash_fallback: true,
		func: "cp_js_widget_code_pushbox", bg: "0xf1f3f5",
		params: _cp_params_arr.base
	}
};

function getElement(aID) {
	return (document.getElementById) ? document.getElementById(aID) : document.all[aID];
}

function wp_get_items(id, obj) {



	if (obj != null)
		_wp_widget_js_array[id].items = obj;

	if (typeof _wp_widget_js_array[id].func == "string") {
		try {
			_wp_widget_js_array[id].func = eval(_wp_widget_js_array[id].func);
		}
		catch (ex) {
		}

		if (typeof _wp_widget_js_array[id].func == "string") {
			setTimeout("wp_get_items('" + id + "')", 100);
			return;
		}
	}

	// check 
	if (typeof _wp_widget_js_array[id].serial_js_inc != "undefined") {
		for (var i = 0; i < _wp_widget_js_array[id].serial_js_inc.length; i++) {

			var fnc = null;
			try {
				fnc = eval(_wp_widget_js_array[id].serial_js_inc[i].func);
			}
			catch (ex) {
				fnc = null;
			}

			if (fnc == null) {
				var file = _wp_widget_js_array[id].serial_js_inc[i].inc;

				loadJSFile(file);

				setTimeout("wp_get_items('" + id + "')", 100);

				return;
			}
		}
	}
//	if (location.href.indexOf("patagoniapubliclibrary") > -1 && navigator.userAgent.indexOf("IE") > -1)
//		alert("debug");
	_wp_widget_js_array[id].func(id);
}

function isiPhone() {
	return navigator.userAgent.indexOf('iPod; U; CPU') > -1 || navigator.userAgent.indexOf('iPhone; U; CPU') > -1 || navigator.userAgent.indexOf('iPad; U; CPU') > -1;
}

function gotFlash(major, minor, build) {
	if (major == null) major = 0;
	if (minor == null) minor = 0;
	if (build == null) build = 0;

	function getFlashVersion(desc) {
		var matches = desc.match(/[\d]+/g);
		matches.length = 3;  // To standardize IE vs FF
		return matches; //.join('.');
	}

	var hasFlash = false;
	var flashVersion;

	if (navigator.plugins && navigator.plugins.length) {
		var plugin = navigator.plugins['Shockwave Flash'];
		if (plugin) {
			hasFlash = true;
			if (plugin.description) {
				flashVersion = getFlashVersion(plugin.description);
			}
		}

		if (navigator.plugins['Shockwave Flash 2.0']) {
			hasFlash = true;
			flashVersion = '2.0.0.11';
		}

	} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
		var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
		hasFlash = mimeType && mimeType.enabledPlugin;
		if (hasFlash) {
			flashVersion = getFlashVersion(mimeType.enabledPlugin.description);
		}

	} else {
		try {
			// Try 7 first, since we know we can use GetVariable with it
			var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
			hasFlash = true;
			flashVersion = getFlashVersion(ax.GetVariable('$version'));
		} catch (e) {
			// Try 6 next, some versions are known to crash with GetVariable calls
			try {
				var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
				hasFlash = true;
				flashVersion = '6.0.21';  // First public version of Flash 6
			} catch (e) {
				try {
					// Try the default activeX
					var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
					hasFlash = true;
					flashVersion = getFlashVersion(ax.GetVariable('$version'));
				} catch (e) {
					// No flash
				}
			}
		}
	}

	if (major == null || !hasFlash)
		return hasFlash;

	if (major < flashVersion[0] ||
				(major == flashVersion[0] && minor < flashVersion[1]) ||
				(major == flashVersion[0] && minor == flashVersion[1] && build <= flashVersion[2]))
		return true;

	return false;
}

function wp_js_widget_code_rotating_photo(id) {
	var items = _wp_widget_js_array[id].items;
	var theobj = getElement(_wp_widget_js_array[id].obj);
	if (theobj == null)
		return;

	var htm = "<img border=0 style='margin:0px;padding:0px;border:0px solid white;' src='" + items.items[_wp_widget_js_array[id].curr_items][_wp_widget_js_array[id].thumb_link] + "' />";

	if (isiPhone()) {
		if (items.items.length == 1 &&
			(items.items[0].content_type == "video/3gpp" || items.items[0].content_type == "audio/mp3")) {
			htm = "<embed src='" + items.items[0].thumbnail_url + "' href='" + items.items[0].content_url + "&range=yes' width='200' height='150' type='video/x-m4v' target='myself' scale='1'></embed>";
		}
		else {
			htm = "<a href='http://www.cincopa.com/wpplugin/runtime/view.aspx?fid=" + _wp_widget_js_array[id].fid + "'>";
			htm += "<img border=0 style='margin:0px;padding:0px;border:0px solid white;' src='" + items.items[_wp_widget_js_array[id].curr_items][_wp_widget_js_array[id].thumb_link] + "' />";
			htm += "</a>";
		}
	}
	else if (_wp_widget_js_array[id].type == "cooliris") {
		loadJSFile("http://lite.piclens.com/current/piclens.js");

		var url = "javascript:PicLensLite.start({feedUrl:\"" + _cincopa_url + "coolirisrss.aspx?fid=" + _wp_widget_js_array[id].fid + "\"});";

		htm = "<a href='" + url + "'>";
		htm += "<img border=0 style='margin:0px;padding:0px;border:0px solid white;' src='" + items.items[_wp_widget_js_array[id].curr_items][_wp_widget_js_array[id].thumb_link] + "' />";
		htm += "</a>";
	}

	_wp_widget_js_array[id].curr_items++;
	if (_wp_widget_js_array[id].curr_items == items.items.length)
		_wp_widget_js_array[id].curr_items = 0;

	// preload next img
	htm += "<img style='display:none;width:1px;height:1px;' src='" + items.items[_wp_widget_js_array[id].curr_items][_wp_widget_js_array[id].thumb_link] + "' />";

	theobj.innerHTML = htm;

	var timeout = 5000;
	if (!isnull(_wp_widget_js_array[id].rotatetime))
		timeout = eval(_wp_widget_js_array[id].rotatetime) * 1000;

	if (items.items.length > 1)
		setTimeout("wp_js_widget_code_rotating_photo('" + id + "')", timeout);
}

function wp_widget_show(cjd) {
	//	var params = eval("_wp_widget_arr.style" + cjd.style);  // this will not work because it sets by ref and not by val

	var baseparams = eval("_wp_widget_arr.style" + cjd.style);
	var params = {};

	// base params - copy all the defaults
	for (var n in baseparams)
		params[n] = baseparams[n];

	// override with params from db and inline
	for (var n in cjd) {
		var par_permit = 0;
		try {
			par_permit = eval(params.params[n].permit);
		}
		catch (ex)
		{ }

		if (typeof par_permit == "undefined")
			par_permit = 0;

		//		alert(n+","+_widget_data[n]);
		//		alert(par_permit +","+ _widget_data["permit"]);

		if (par_permit <= _widget_data["permit"])
			params[n] = _widget_data[n];
	}

	var fid = params.fid;

	if (!gotFlash(9) && (params.pm == "p3" || params.pm == "p4" || params.flash_fallback == true)) {
		cjd.style = "p1";
		cjd.w = _wp_widget_arr.stylep1.w;
		cjd.h = _wp_widget_arr.stylep1.h;

		wp_widget_show(cjd);
		return;
	}

	var cpwidget = "";

	if (params.cooliris == "yes") {
		loadJSFile("http://lite.piclens.com/current/piclens.js");

		var url = "javascript:PicLensLite.start({feedUrl:\"" + _cincopa_url + "coolirisrss.aspx?fid=" + params.fid + "\"});";
		cpwidget += "[<a class='cincopa-cooliris-link' href='" + url + "'>View with Cooliris</a>] ";
		//		params.h = eval(params.h) + 20;
	}

	if (params.allow_download == "original" || params.allow_download == "resized") {
		var url = _cincopa_url + "download.aspx?fid=" + params.fid;
		cpwidget += "[<a class='cincopa-download-all-link' href='" + url + "'>Download All</a>] ";
	}

	if (cpwidget != "")
		cpwidget += "<br>";

	if (params.pm == "p3") {
		var xmllink = _cincopa_url + "rss200.aspx?fid=" + fid;

		if (params.thumb_size != null)
			xmllink += "&thumb=" + params.thumb_size;

		if (params.content_size != null)
			xmllink += "&content=" + params.content_size;

		xmllink = encodeURIComponent(xmllink);

		var playervars = "";
		playervars += "&file=" + xmllink;

		if (params.autostart == true || params.autostart == "true")
			playervars += "&autostart=true";
		else
			playervars += "&autostart=false";

		playervars += "&width=" + params.w;
		playervars += "&height=" + params.h;
		playervars += "&thumbsinplaylist=true";
		playervars += "&autoscroll=false";
		playervars += "&displaywidth=" + params.dw;
		playervars += "&repeat=list";

		if (params.shuffle == true || params.shuffle == "true")
			playervars += "&shuffle=true";
		else
			playervars += "&shuffle=false";

		if (params.rotatetime == null || params.rotatetime == "")
			playervars += "&rotatetime=5";
		else
			playervars += "&rotatetime=" + params.rotatetime;

		if (params.stretch == true || params.stretch == "true")
			playervars += "&overstretch=true";
		else
			playervars += "&overstretch=false";

		//caption

		if (params.player == null)
			player = _cincopa_url + "player3/mediaplayer.swf";
		else
			player = _cincopa_url + "player3/" + params.player + ".swf";

		cpwidget += '<embed src="' + player + '" width="' + params.w + '" height="' + params.h + '" wmode="transparent" bgcolor="#C0C0C0" allowfullscreen="true" allowscriptaccess="always" flashvars="' + playervars + '" ></ embed>';
	}
	else if (params.pm == "p4") {
		//		var xmllink = _cincopa_url + "player4/rssjw.aspx?fid="+fid;
		var xmllink = _cincopa_url + "xspf.aspx?fid=" + fid;

		if (params.thumb_size != null)
			xmllink += "&thumb=" + params.thumb_size;

		if (params.content_size != null)
			xmllink += "&content=" + params.content_size;

		if (params.overridealbumart == true || params.overridealbumart == "true")
			xmllink += "&overridealbumart=true";

		xmllink = encodeURIComponent(xmllink);

		var playervars = "";
		playervars += "&backcolor=000000";
		playervars += "&frontcolor=ffffff";
		playervars += "&playlistsize=" + params.plw;
		playervars += "&height=" + params.dh;
		playervars += "&width=" + params.dw;

		//playervars += "&controlbar=over";

		if (typeof params.playlist != "undefined")
			playervars += "&playlist=" + params.playlist;

		if (params.autostart == true || params.autostart == "true")
			playervars += "&autostart=true";

		if (params.shuffle == true || params.shuffle == "true")
			playervars += "&shuffle=true";
		else
			playervars += "&shuffle=false";

		if (typeof params.skin != "undefined")
			playervars += "&skin=" + _cincopa_url + "player4/" + params.skin;

		if (typeof params.repeat != "undefined")
			playervars += "&repeat=" + params.repeat;

		playervars += "&bufferlength=2";
		//playervars += "&skin=styles/stijl.swf";
		//playervars += "&stretching=fill";
		//playervars += "&skin=styles/cometSkin.swf";
		//playervars += "&skin=styles/pixelizeSkin.swf";
		//playervars += "&skin=styles/controlpanelSkin.swf";
		//playervars += "&skin=styles/kleurSkin.swf";
		//playervars += "&skin=styles/playcassoSkin.swf";

		if (params.player == null)
			player = _cincopa_url + "player4/player4.swf";
		else
			player = _cincopa_url + "player4/" + params.player + ".swf";

		cpwidget += '<embed src="' + player + '" width="' + params.w + '" height="' + params.h + '" wmode="transparent" allowfullscreen="true" bgcolor="#C0C0C0" type="application/x-shockwave-flash" flashvars="file=' + xmllink + playervars + '" ></ embed>';
	}
	else if (params.pm == "j1") {
		var uniqueid = (((1 + Math.random()) * 0x10000000) | 0).toString(16).substring(1);
		//		alert(uniqueid + " " + params.skin);
		_wp_widget_js_array[uniqueid] = params;
		_wp_widget_js_array[uniqueid].obj = "inner" + uniqueid;
		_wp_widget_js_array[uniqueid].fid = fid;
		_wp_widget_js_array[uniqueid].curr_items = 0;

		cpwidget += "<div style='width:" + _wp_widget_js_array[uniqueid].w + "px;height:" + _wp_widget_js_array[uniqueid].h + "px;' id='inner" + uniqueid + "'></div>";

		if (_wp_widget_js_array[uniqueid].css_inc != null) {
			for (var i = 0; i < _wp_widget_js_array[uniqueid].css_inc.length; i++) {
				var file = _wp_widget_js_array[uniqueid].css_inc[i];

				loadCSSFile(file);
			}
		}

		if (_wp_widget_js_array[uniqueid].js_inc != null) {
			for (var i = 0; i < _wp_widget_js_array[uniqueid].js_inc.length; i++) {
				var file = _wp_widget_js_array[uniqueid].js_inc[i];

				loadJSFile(file);
			}
		}

		if (_wp_widget_js_array[uniqueid].nojson == undefined) {
			var jsonlink = _cincopa_url + "json.aspx?callback=wp_get_items&wid=" + uniqueid + "&fid=" + fid;

			if (params.thumb_size != null)
				jsonlink += "&thumb=" + params.thumb_size;

			if (params.content_size != null)
				jsonlink += "&content=" + params.content_size;

			//			jsonlink += "&debug=" + _wp_widget_js_array[uniqueid].fid;

			loadJSFile(jsonlink);
		}
		else {
			setTimeout("wp_get_items('" + uniqueid + "')", 100);
		}
	}

	var panel = '<div style="clear:both;">&nbsp;</div>';

	var hide_panel = (params.panel == "none" || eval(params.remove_branding));

	if (!hide_panel)
		panel = '<div style="clear:both;"><a href="http://www.cincopa.com/wpplugin/wordpress-plugin.aspx"><img style="padding:0px;margin:0px;border:0px;" border=0 alt="Powered By Cincopa" src="' + _cincopa_url + 'bycincopa.gif" /></a></div>';

	var obj = getElement(params.id);
	var bobj = null;

	// we are using this try/catch because it could throw Permission denied (in case this is a frame/iframe inside other site
	try {
		bobj = window.parent.document.getElementById("branding" + params.id);
	}
	catch (ex)
	{ }

	if (bobj == null)
		cpwidget += panel;
	else
		bobj.innerHTML = panel;

	if (obj == null)
		document.write(cpwidget);
	else {
		obj.innerHTML = cpwidget;
		var cincopaLoadCompletedAttribute = obj.getAttribute('cincopaLoadCompleted');
		if (cincopaLoadCompletedAttribute != undefined) {
			eval(cincopaLoadCompletedAttribute);
		}
	}
}

if (typeof _cincopa_install_skin != "undefined") {
	for (var n in _cincopa_install_skin)
		_wp_widget_arr[n] = _cincopa_install_skin[n];
}