/*
	common.js - 19/09/2008
*/

//	settings
	var lightBoxCfg = {
			// Configuration related to overlay
			overlayBgColor: 		'#900D0C',		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
			overlayOpacity:			0.55,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
			// Configuration related to images
			imageLoading:			siteCfg.path + '/img/ajax_loader.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			siteCfg.path + '/img/lightBox/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
			imageBtnNext:			siteCfg.path + '/img/lightBox/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
			imageBtnClose:			siteCfg.path + '/img/lightBox/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:				siteCfg.path + '/img/lightBox/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
			// Configuration related to container image box
			containerBorderSize:	10,			// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
			containerResizeSpeed:	400,		// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
			// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
			txtImage:				'Image',	// (string) Specify text "Image"
			txtOf:					'of',		// (string) Specify text "of"
			// Configuration related to keyboard navigation
			keyToClose:				'c',		// (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
			keyToPrev:				'p',		// (string) (p = previous) Letter to show the previous image
			keyToNext:				'n',		// (string) (n = next) Letter to show the next image.
			// Donīt alter these variables in any way
			imageArray:				[],
			activeImage:			0
		};

	var blockUIDisplayBox = { width: '400px', height: '180px', top:'120px', left:'50%' };
	var blockUIOverlayCSS = { backgroundColor: '#710000', opacity: '0.30' };
	var blockUIPageMessageCSS = { color: '#000', backgroundColor: '#91000D' };


	function themeInit()	{

	// set block ui defaults
	$.extend($.blockUI.defaults.displayBox, { width: '400px', height: '180px', top:'120px', left:'50%' });
	$.extend($.blockUI.defaults.overlayCSS, { backgroundColor: '#91000D', opacity: '0.5' });
	$.extend($.blockUI.defaults.pageMessageCSS, { color: '#FFF', backgroundColor: '#91000D' });
	

	}

	// days 1 - 31, months 0 - 11
	// with settings.currentDate month = .getMonth()-1	day = .getDate()	year = .getYear() to set 1 day=
	var thohIntro = {
		swfFile: null,
		flashvars: {
			month: "10",
			day: "1",
			year: "2008",
			logoObj: "/v1/img/sva.png",
			tickerFile: "/v1/tickers.txt",
			xmlFile: "xml/intro.xml",
			radioAd: false
		}, 
		params: {
			menu: false,
			wmode: "transparent",
			scaleMode: "noScale",
			base: siteCfg.path
		},
		attributes: {
			id: "thohIntroObj",
			name: "thohIntroObj"
		}
	}

	var thohTicker = {
		swfFile: "ticker.swf",
		width: "100%",
		height: "28",
		flashvars: {
			tickerFile: "/v1/tickers.txt"
		}, 
		params: {
			menu: false,
			wmode: "transparent",
			scaleMode: "noScale",
			base: siteCfg.path
		},
		attributes: {
			id: "thohTickerObj",
			name: "thohTickerObj"
		}
	}
	// see above intro settings re date
	var thohMain = {
		swfFile: "main.swf",
		width: "390",
		height: "680",
		flashvars: {
			menu: false,
			xmlFile: 'xml/blank.xml',
			eventText: "Sunday 3rd of May 2009 @ Ministry of Sound",
			month: "4",
			day: "3",
			year: "2009",
			file: "xml/playlist.xml",
			autoscroll: "true",
			showdownload: "true",
			enablejs: "true",
			autostart: "true",
			shuffle: "false",
			javascriptid: "thohMainObj",
			width: "225",
			height: "20",
			autostart: "true",
			showstop: "true",
			showvolume: "true",
			repeat: "true",
			displayheight: "0",
			mp3swf: "swf/mp3player.swf",
			signupURL: "membership/signup",
			thisPage: thisPage
		},
		params: {
			menu: false,
			wmode: "transparent",
			scaleMode: "noScale",
			base: siteCfg.path,
			allowscriptaccess: "always",
			allowfullscreen: true,
			wmode: "transparent"
		},
		attributes: {
			id: "thohMainObj",
			name: "thohMainObj"
		}
	};

	// thoh photos
	var thohslideshowPlyr = {
		swfFile: "photos.swf",
		width: "674",
		height: "448",
		flashvars: {
			menu: false,
			xmlFile: "xml/gallery.xml",
			contentScale: "Downscale Only"
		},
		params: {
			allowscriptaccess: "always",
			allowfullscreen: true,
			menu: false,
			wmode: "transparent",
			base: siteCfg.path
		},
		attributes: {
			id: "thohSlideshowObj",
			name: "thohSlideshowObj"
		}
	};

	// thoh photos
	var thohExtraBox = {
		swfFile: "thohExtra-278x276.swf",
		width: "278",
		height: "276",
		flashvars: {
			menu: false,
			xmlFile: "xml/fadegallery.xml",
			contentScale: "Downscale Only"
		},
		params: {
			allowscriptaccess: "always",
			allowfullscreen: true,
			menu: false,
			wmode: "transparent",
			base: siteCfg.path
		},
		attributes: {
			id: "thohExtra",
			name: "thohExtra"
		}
	};

	// thoh photos
	var thohAlbumAd = {
		swfFile: "albumad.swf",
		width: "388",
		height: "550",
		flashvars: {
		},
		params: {
		},
		attributes: {
			id: "AlbumAD",
			name: "AlbumAD"
		}
	};

	// thoh 300 x 250 banners 
	var thohBanners300x250 = {
		swfFile: "thohBanners300x250.swf",
		width: "300",
		height: "250",
		flashvars: {
			menu: false,
			xmlFile: "xml/banner300x250.xml",
			height: "250",
			width: "300",
			wmode: "transparent"
		},
		params: {
			base: siteCfg.path
		},
		attributes: {
			id: "thohBannerObj",
			name: "thohBannerObj"
		}
	};

	// thoh videos - thohflvPlyr.swf - 
	
	/*
		displayheight: 480,
		height: 535, 
		width: 770,
		autoscroll: true,
		displaywidth: 770,
		overstretch: true,
		thumbsinplaylist: true
	*/
	
	var thohflvPlyr = {
		swfFile: "flvPlyr.swf",
		width: "770",
		height: "545",
		flashvars: {
			file: "xml/videos.xml",
			autoscroll: "true",
			enablejs: "true",
			displayheight:770,
			height: 545, 
			width: 770,
			autoscroll: "true",
			displaywidth: 545,
			overstretch: "false",
			thumbsinplaylist: "true",
			allowfullscreen: "true",
			shuffle: "false"
		},
		params: {
			allowscriptaccess: "always",
			allowfullscreen: "true",
			menu: "false",
			base: siteCfg.path
		},
		attributes: {
			id: "flvPlyrObj",
			name: "flvPlyrObj"
		}
	};

	var thohHistory = {
		swfFile: "history.swf",
		width: "100%",
		height: "535",
		flashvars: {
			xmlFile: "xml/history.xml",
			showGallery: "hidden",
			contentScale: "none"
		},
		params: {
			menu: false,
			wmode: "transparent",
			scaleMode: "noScale",
			base: siteCfg.path
		},
		attributes: {
			id: "thohHistoryObj",
			name: "thohHistoryObj"
		}
	};


//	issue with opera can't click on idtabs styles don't load until a link is clicked
// ie removes the ticker

// some variables to save
var currentPosition;
var currentVolume;
var currentItem;
var currentState = 2;
var DEBUG = false;

// these functions are caught by the JavascriptView object of the player.
function sendEvent(typ,prm) { thisMovie('thohMainObj').sendEvent(typ,prm); };
function getUpdate(typ,pr1,pr2,pid) {
	if(typ == "time") { currentPosition = pr1; }
	else if(typ == "volume") { currentVolume = pr1; }
	else if(typ == "item") { currentItem = pr1; setTimeout("getItemData(currentItem)",100); }
	else if(typ == "state") { currentState = pr1;  /* console.info(typ + ' ' + pr1);*/ }
	var id = document.getElementById(typ);
	// id.innerHTML = typ+ ": "+Math.round(pr1);
	// pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
	if(pid != "null") {
		// console.debug("received from the player with id: "+pid);
	}
};

function oc(a)	{
// snook.ca occurence in array return turn
  var o = {};
  for(var i=0;i<a.length;i++)
  {
    o[a[i]]='';
  }
  return o;
}

// These functions are caught by the feeder object of the player.
function loadFile(obj) { thisMovie(thohMain.attributes.id).loadFile(obj); };
function addItem(obj,idx) { thisMovie(thohMain.attributes.id).addItem(obj,idx); }
function removeItem(idx) { thisMovie(thohMain.attributes.id).removeItem(idx); }
function getItemData(idx) {
	var obj = thisMovie(thohMain.attributes.id).itemData(idx);
	var nodes = "";
	for(var i in obj) { 
		//	console.debug("mediaplyr event "+i+": "+obj[i]+""); 
	}
};

// This is a javascript handler for the player and is always needed.
function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
};

// wrapper for 
function mp3LinkCall(href, title, rel)	{
				thisMovie(thohMain.attributes.id).controller.getEvent("playpause");
}
function makePaused()	{
	// console.info("currentState: " + currentState);
			if(currentState)
				sendEvent('playpause');
}

function consoleWrite(type, msg)	{
				if (DEBUG)	{
					if (type == 'info')	{
						console.info(msg);
					}	else if (type == 'warning')	{
						console.warn(msg);
					}	else if (type == 'debug')	{
						console.debug(msg);
					}
				}
}

// globals
var bodyClass = '';

// jLink Call
function jLinkCall(url, rel)	{
	if ( $('#contentWrapper .blockUI').length )	{
	}	else	{
		
		//consoleWrite('debug', 'url:	'+url);
		//consoleWrite('debug', 'rel:	'+rel);

		//	add var:value for json format "format:json";
		
		// determin if pretty urls are enabled
		var useInternalRewrite = false;
		// break dow the url & set up required vars.  contruct dataURL and params object then call via json
		var regex = ((useInternalRewrite === false) ? '\/v1\/(home|events|biogs|media|news|charts|music|contact|membership)(.*)' : '\/v1\/index\.php\/(home|events|biogs|media|news|charts|contact|membership)(.*)');
		var viewURL = url.toString(), dataURL = "", params = {}, re = new RegExp(regex, "g"), addOn = [];
		var PageClassName = $('body').attr('class');
		var shortcut = re.exec(viewURL);
		var relation = rel;
		
		// BlockUI
		$('#contentWrapper').block( '<p>Loading Please Wait</p><img src="' + siteCfg.path + '/img/default-ajax_loader.gif" width="25" height="25" border="0" alt="" title="" />' ).pngFix();
		//		regex = '\/([0-9a-zA-Z]*)([\/]*)([0-9a-zA-Z]*)';   --- needs to handle params glitch might be in roots
		regex = '\/(index|display|view|history|photos|videos)([\/]*)([0-9a-zA-Z-]*)';
		re = new RegExp(regex, "g");
		addOn = re.exec(shortcut[2]);

		if(addOn)	{
			switch(addOn[1])	{
				case 'history':
					addOn[1]+=  addOn[2] + addOn[3];
					bodyClass =  'history';
				break;
				case 'photos':
				break;
				case 'videos':
				break;
				case 'view':
					addOn[1]+=  addOn[2] + addOn[3];
				break;
				case 'index':
				break;
				default:
				break;
			}
		}

		dataURL = (
				(!useInternalRewrite) ? siteCfg.path : siteCfg.path.replace('/webroot', '/index.php')
			) + "/" + shortcut[1] + (
				(addOn !== null) ? '/' + addOn[1] : ''
			) + ".json";
		//dataURL = addOn[1] + addOn[2] + addOn[3] + '/index' + "/format:json/";

		// remove swfs
		$(swfObjs).each(function(i){
		   swfobject.removeSWF(swfObjs[i]);
		   // array is now emtpy
		   swfObjs = [];
		});

		$.getJSON(
			dataURL, 
			function (json)	{
				var htmlContent = json.contentStr;
				bodyClass = json.classStr;
				var subClass = json.subclassStr;
				var htmlTitle = json.titleStr;
				var htmlNavigation = json.navigation;
				var targetDiv = '#thoh' +  bodyClass.substr(0, 1).toUpperCase() + bodyClass.substr(1);

				document.title = "The History of History " + htmlTitle;

				if (PageClassName === bodyClass)	{
				
					$(targetDiv).slideUp({
						'duration': 250, 
						'easing': 'easeOutBounce',
						'complete': function ()	{
							$(this).html($(htmlContent).html());
						}
					}).slideDown({
						'duration': 250, 
						'easing': 'easeOutBounce',
						'complete': function ()	{
							jLinkComplete(bodyClass);
							$('.scroller').jScrollPane({ showArrows : true, scrollbarWidth : 7 });
						}
					});
				} else {
					//$("#navi").html(htmlNavigation);
				
					$('body').removeClass(PageClassName).addClass(bodyClass);
					$('#content').append(htmlContent);
					
					var oldContent = $('#thoh' + (PageClassName.substr(0, 1).toUpperCase() + PageClassName.substr(1)));
					
					$('#thoh' + (PageClassName.substr(0, 1).toUpperCase() + PageClassName.substr(1))).fadeOut({
						'duration': 250, 
						'easing': 'easeOutBounce', 
						'complete': function()	{
							oldContent.remove();
							$(targetDiv).fadeIn({
								'duration': 250, 
								'easing': 'easeInBounce', 
								'complete': function()	{
									//consoleWrite('debug', 'shadowbox setup');
									Shadowbox.setup();
									//consoleWrite('debug', 'About to complete');
									jLinkComplete(bodyClass);
									$('.scroller').jScrollPane({ showArrows : true, scrollbarWidth : 7 });
								}
							});
						}
					});
				}
			}
		); // /getJSON
	}
}

var runOnce = false;

function init()	{
	
			var PageClassName = $('body').attr('class');

			if (jQuery.browser.msie === true)		{
				$('.scroller').jScrollPane({ showArrows : true, scrollbarWidth : 7 }).css('left', 0);;
			}

			if (runOnce === false)	{
				themeInit();
				runOnce = true;
			}
				thohSetContentByClass(PageClassName);

				// internal links :) ~ a[@href^="/"] love love jquery

				$('#JulieMcKnightPA, .jLink, .clip, .jlink, .header, .nav	a, a[@href$="mp3"], #footer a, a.lightbox')
						.unbind('click');

				// mp3 - make mp3 link to mp3player if flash installed
				$('a[@href$="mp3"]')
					.bind(
						'click',
						{'href': this.href,'rel': this.rel,'title':this.title},
						function(event)	{
							event.stopPropagation();
							event.preventDefault();
							mp3LinkCall(this.href, this.title, this.rel);
							$(this).flash(
								{ 'src': siteCfg.path + '/swf/mp3player.swf', height: 20, width: 100 },
								{ 'version': 8 },
								function(htmlOptions) {
									$this = $(this);
									htmlOptions.flashvars.file = $this.attr('href');
									$this.before($.fn.flash.transform(htmlOptions));
								}
							);
						}
					);
				// clip popup
				$('a.clip')
					.bind(
						'click',
						{'href': this.href,'rel': this.rel,'title':this.title},
						function(event)	{
							makePaused();
							event.stopPropagation();
							event.preventDefault();
							openCenterWin(this.href, 'clip', 425, 360, 0, 0);
						}
					);
				// clip popup
				$('a#JulieMcKnightPA')
					.bind(
						'click',
						{'href': this.href,'rel': this.rel,'title':this.title},
						function(event)	{
							makePaused();
							event.stopPropagation();
							event.preventDefault();    // open a welcome message
    Shadowbox.open({
        player:     'swf',
        title:      'Julie McKnight',
        content:    '/v1/swf/flvPlyr.swf?file=xml/videos.xml&displayheight=770&height=545&displaywidth=770&width=770&autoscroll=true&overstretch=false&shuffle=false&thumbsinplaylist=false',
        height:     545,
        width:      770
    });
						}
					);

				$('.jLink, .jlink, .header, .nav	a, #footer a')
						.bind(
							'click',
							{'href': this.href,'rel': this.rel},
							function(event)
							{	
								event.stopPropagation ();
								event.preventDefault();
								jLinkCall(this.href, this.rel); 
							}
						);

				$('a.lightbox').lightBox(lightBoxCfg);
				$(document).pngFix(); 
		$('div.biogs > ul, div.events > ul, div.tabs > ul').tabs();
		$('.scroller').jScrollPane({ showArrows : true, scrollbarWidth : 7 }); 
		if ( $('#bScroller').length )	{
			$('#bScroller .scrollableArea').css('width', ($('#bScroller').width() * $('#bScroller .item').length));
			$('#bScroller').prepend('<div class="scrollingHotSpotLeft"></div><div class="scrollingHotSpotRight"></div>');
			$('#bScroller').smoothDivScroll();
		}
}

function jLinkComplete(updateClass)	{
	
	// setFullDisplay('thoh' + (updateClass.substr(0, 1).toUpperCase() + updateClass.substr(1)));
				init();

				$('#contentWrapper').unblock();
				
				/* $('#contentWrapper').animate(
					{'height':$('#' + (updateClass.substr(0, 1).toUpperCase() + updateClass.substr(1))).height()},
					'fast', 
					'linear',
					function ()	{
						$('div.tabs > ul').tabs();
					}
				);	*/
}

// update after json etc
function thohSetContentByClass(bodyClass)	{
	
				switch(bodyClass)	{
					case 'home':		thoh_home(); break;
					case 'events':		thoh_events(); break;
					case 'history':		thoh_history(); break;
					case 'biogs':		thoh_biogs(); break;
					case 'media':		thoh_media(); break;
					case 'charts':		thoh_charts(); break;
					case 'contact':		thoh_contact(); break;
					case 'membership':	thoh_membership(); break;
					case 'photos':		thoh_photos(); break;
					case 'videos':		thoh_videos(); break;
				}
}
function setFullDisplay(newID)	{
	
	/*
			var contHeight = 0;
			var innerHeight = {
				'body':			$('body').innerHeight(),
				'innerWrap':	$('#innerWrap').innerHeight(),
				'outterWrap':	$('#outterWrap').innerHeight(),
				'base':			$('#base').innerHeight(),
				'inBase':		$('#inBase').innerHeight(),
				'introFObj':	$('#introFObj').innerHeight()
			};
			var Height = {
				'body':			$('body').height(),
				'innerWrap':	$('#innerWrap').height(),
				'outterWrap':	$('#outterWrap').height(),
				'base':			$('#base').height(),
				'inBase':		$('#inBase').height(),
				'introFObj':	$('#introFObj').height()
			};

				contHeight = $('#thohMain').height() + contHeight;
				contHeight = $('#thohBar').height() + contHeight;
				contHeight = $('#' + newID).height() + contHeight;
				contHeight = $('#thohFtr').height() + contHeight;

				$('#innerWrap').height(contHeight);
				$('#outterWrap').height(contHeight);
				$('#base').height(contHeight);
				$('#inBase').height(contHeight);
				$('#introFObj').height(contHeight);
				$('body').height(contHeight); */
}

function	thoh_home()	{
		//console.info('thoh_home');

		// home extra box
		var att = { data: siteCfg.path + "/swf/" + thohExtraBox.swfFile, width: thohExtraBox.width, height:thohExtraBox.height, id:"thohHistoryObj" };
		var par = {
			menu: false,
			wmode: "transparent",
			scaleMode: "noScale",
			base: siteCfg.path,
			flashvars: "xmlFile=" + thohExtraBox.flashvars.xmlFile + "&showGallery=" + thohExtraBox.flashvars.showGallery + "&contentScale=" + thohExtraBox.flashvars.contentScale
		};
		if(!('thohExtra' in oc(swfObjs)))	{
			swfobject.createSWF(att, par, "thohExtra");
			swfObjs[swfObjs.length] = 'thohExtra';
			consoleWrite('	extra createSWF created	');
		}	else	{
			consoleWrite('	not created	');
		}

}

function	thoh_events()	{
	
}

function	thoh_history()	{
		//consoleWrite('debug', 'thoh_history');
		// history
		var att = { data: siteCfg.path + "/swf/" + thohHistory.swfFile, width: thohHistory.width, height:thohHistory.height, id:"thohHistoryObj" };
		var par = {
			menu: false,
			wmode: "transparent",
			scaleMode: "noScale",
			base: siteCfg.path,
			flashvars: "xmlFile=" + thohHistory.flashvars.xmlFile + "&showGallery=" + thohHistory.flashvars.showGallery + "&contentScale=" + thohHistory.flashvars.contentScale
		};
		swfobject.createSWF(att, par, "thohHistoryFObj");
		swfObjs[swfObjs.length] = 'thohHistoryFObj';
}

function	thoh_biogs()	{	
	
	/* $('#biogNavList').Accordion({ 
			event: 'mouseover', 
			active: '.selected', 
			selectedClass: 'active', 
			animated: "bounceslide",
			header: '.head',
			navigation: true
		}).change(function(event, newHeader, oldHeader, newContent, oldContent) { 
			$('<div>' + oldHeader.text() + ' hidden, ' + newHeader.text() + ' shown</div>').appendTo('#log'); 
		}); */

}

function	thoh_media()	{
	
}

function	thoh_photos()	{
	
					// photos
					var att = { data: siteCfg.path + "/swf/" + thohslideshowPlyr.swfFile, width: thohslideshowPlyr.width, height:thohslideshowPlyr.height, id:"thohPhotoGalleryObj" };
					var par = {
						menu: false,
						wmode: "transparent",
						scaleMode: "noScale",
						base: siteCfg.path,
						flashvars: "xmlFile=" + thohslideshowPlyr.flashvars.xmlFile + "&contentScale=" + thohslideshowPlyr.flashvars.contentScale
					};
					swfobject.createSWF(att, par, "thohPhotoGalleryFObj");
					swfObjs[swfObjs.length] = 'thohPhotoGalleryFObj';
}

function	thoh_videos()	{
	
	
					// videos
					var att = { data: siteCfg.path + "/swf/" + thohflvPlyr.swfFile, width: thohflvPlyr.width, height:thohflvPlyr.height, id:"thohflvPlyrObj" };
					var par = {
						menu: false,
						wmode: "opaque",
						scaleMode: "noScale",
						base: siteCfg.path,
						allowscriptaccess: thohflvPlyr.params.allowscriptaccess,
						allowfullscreen: thohflvPlyr.params.allowfullscreen,
						flashvars: "file=" + thohflvPlyr.flashvars.file + 
							"&displayheight=" + thohflvPlyr.flashvars.displayheight + 
							"&height=" + thohflvPlyr.flashvars.height + 
							"&displaywidth=" + thohflvPlyr.flashvars.displaywidth + 
							"&width=" + thohflvPlyr.flashvars.width + 
							"&autoscroll=" + thohflvPlyr.flashvars.autoscroll + 
							"&overstretch=" + thohflvPlyr.flashvars.overstretch + 
							"&shuffle=" + thohflvPlyr.flashvars.shuffle + 
							"&thumbsinplaylist=" + thohflvPlyr.flashvars.thumbsinplaylist
					};
					swfobject.createSWF(att, par, "thohVideoPlayerFObj");
					swfObjs[swfObjs.length] = 'thohVideoPlayerFObj';
					makePaused();
	}

function	thoh_charts()	{
	consoleWrite('debug', 'thoh_charts');
}

function	thoh_contact()	{
									consoleWrite('debug', 'FN thoh_contact');
				$('#format').val('json');
				$('#ContactSubmissionForm').submit(function()	{
									consoleWrite('debug', '		contact submit');
					$(this).parent().block('<p>Submitting message</p>');
					$(this).slideUp({
								'duration': 250, 
								'easing': 'easeOutBounce',
								'complete': function ()	{
									$(this).empty();
								}
							});

					// submit the form 
					$(this).ajaxSubmit({ 
						// dataType identifies the expected content type of the server response 
						'dataType': 'json', 
						// success identifies the function to invoke when the server response 
						// has been received 
						'success': thoh_ContactSub 
					});
					return false; 
				});
}

function	thoh_ContactSub(data)	{
				// 'data' is the json object returned from the server 
				var msgText = '';
					
									consoleWrite('debug', 'FN thoh_ContactSub - data:');
									consoleWrite('debug', data);
									if (data.success === true)
									{
										msgText = '<p>Thank You ' + data.name + '</p><p>' + data.message + '</p><p>The a response will be sent to ' + data.email + ' shortly.</p>'
									}	else	{
										msgText = '<p>' + data.name + ' we were unable to send your message. </p><p>' + data.message + '</p>'
									}
					$('#ContactSubmissionForm').html(msgText).slideDown({
								'duration': 250, 
								'easing': 'easeOutBounce',
								'complete': function ()	{
									consoleWrite('debug', 'unblock');
									$('#ContactSubmissionForm').parent().unblock();
								}
							});

					data = false;
}

function	thoh_membership()	{
		
}

function blank()	{
				alert('blank');
}

function debug(obj)	{
				var s = "";
				var i = 0;

				for (prop in obj)
				{
					s += prop + ":" + obj[prop] + "\n";
					if (++i % 10 === 0) {
						consol.debug(s);
						s = "";
					}
				};

};

jQuery.clean.convert = function(html) {
				var n = document.createElement('div');
				n.innerHTML = html;
				return n;
};


if(thisPage == 'welcome')	{
	swfobject.embedSWF(siteCfg.path+"/swf/"+thohIntro.swfFile, "introFObj", "100%", "100%", "8.0.0", siteCfg.path+"/swf/expressInstall.swf", thohIntro.flashvars, thohIntro.params, thohIntro.attributes);
} else {
	
	// thoh header
	swfobject.embedSWF(siteCfg.path + "/swf/" + thohMain.swfFile, "main", thohMain.width, thohMain.height, "8.0.0", false, thohMain.flashvars, thohMain.params, thohMain.attributes);
	if(thisPage == 'home')	{
		swfobject.embedSWF(siteCfg.path+"/swf/"+thohExtraBox.swfFile,"thohExtra",thohExtraBox.width,thohExtraBox.height,"8.0.0",false,thohExtraBox.flashvars,thohExtraBox.params,thohExtraBox.attributes);
		swfObjs[swfObjs.length] = 'thohExtra';
		swfobject.embedSWF(siteCfg.path+"/swf/"+thohAlbumAd.swfFile,"AlbumLaunchAdvertPoster",thohAlbumAd.width,thohAlbumAd.height,"8.0.0",false,thohAlbumAd.flashvars,thohAlbumAd.params,thohAlbumAd.attributes);
		swfObjs[swfObjs.length] = 'thohAlbumAd';
	}
	swfobject.embedSWF(siteCfg.path+"/swf/"+thohTicker.swfFile,"ticker",thohTicker.width,thohTicker.height,"8.0.0",false,thohTicker.flashvars,thohTicker.params,thohTicker.attributes);
}	
//	file=/upload/mediaplayer.xml&enablejs=true&javascriptid=mpl&displayheight=240

	//	jQuery docu ready
	$(document).ready(function()	{
		init();

		$.gaTracker(googleTrackerUA);

		if(DEBUG)	{
			//	$('#footer').append('<a href="#" id="ieOverflowTest">ie8 test</a>');
			$('#ieOverflowTest').bind('click', function()	{
			})
		}
	});

	
	window.onload = function()	{
	};
