<?php
	require_once( $_SERVER['DOCUMENT_ROOT'] . '/res/settings/settings.php' );
?>
var xmlFile = "/res/actions/get_rand_images.php";
var lgPath = "lgPath=/lib/galleries/general/lg";
var tnPath = "tnPath=/lib/galleries/general/tn";
//
var project_xmlFile = "/res/actions/get_rand_images.php";
var project_lgPath = "lgPath=/lib/galleries/general/lg";
var project_tnPath = "tnPath=/lib/galleries/general/tn";

var Site = {
	
	pageDomReady: function() {
		Site.preloadImages('/lib/images/page_header/photos_index.jpg');
		Site.blurAllLinks();
		if ($('page_header_left_photo')) $('page_header_left_photo').setStyle('background-image','url(/lib/images/page_header/content_' + parent_name + '.jpg)');
	},
	pageLoaded: function () {
		Site.loadPageHeaderPhotos();
		Site.loadProjectPhotos();
		
	},
	preloadImages: function () {
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=Site.preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	},
	scrollCheck: function() {
		if ( $('scrollsTo') && $('scrollsTo').value ) Site.scrollsTo($('scrollsTo').value);
	},
	openWindow: function(winUrl,winName,winOptions) {
		return window.open(winUrl,winName,winOptions);
	},
	blurAllLinks: function() {
		$$('a').each(function(aLink) {
			aLink.addEvent('focus', function(){ aLink.blur(); });
		});
	},
	scrollsTo: function( pageAnchor ) {
		anchorScroll.toElement($(pageAnchor));
		 return false;
	},
	loadPageHeaderPhotos: function () {
		if ($('page_header_right_photo')) {
			var flashcheckObj = new SWFObject("", "check", "", "", "9", "#FFFFFF", true);
			if (flashcheckObj.installedVer.major >= "9") {
				var swfFile = '/lib/swf/page_header_photos_index.swf';
				
				if ($('homepage')) {
					swfFile = '/lib/swf/page_header_photos_index.swf';
					var swfWidth = '690px';
					var swfHeight = '300px';
				} else {
					swfFile = '/lib/swf/page_header_photos.swf';
					var swfWidth = '690px';
					var swfHeight = '133px';
				}
				flashHeaderObj = new SWFObject(swfFile, "page_header_right_photos", swfWidth, swfHeight, 9, "#F9F8FD", true);
				flashHeaderObj.addParam("wmode", "transparent");
				flashHeaderObj.addParam("salign", "tl");
				flashHeaderObj.addParam("scale", "noscale");
				flashHeaderObj.addVariable("xmlFile", xmlFile);
				flashHeaderObj.addVariable("lgPath", lgPath);
				flashHeaderObj.addVariable("tnPath", tnPath);
				flashHeaderObj.write("page_header_right_photo");
			}
		}
	},
	loadProjectPhotos: function() {
		if ($('project_info_col_1')) {
			flashHeaderObj = new SWFObject("/lib/swf/property_images.swf", "page_header_right_photos", "450", "345", 9, "#F9F8FD", true);
			flashHeaderObj.addParam("wmode", "transparent");
			flashHeaderObj.addParam("salign", "tl");
			flashHeaderObj.addParam("scale", "noscale");
			flashHeaderObj.addVariable("xmlFile", project_xmlFile);
			flashHeaderObj.addVariable("lgPath", project_lgPath);
			flashHeaderObj.addVariable("tnPath", project_tnPath);
			flashHeaderObj.addVariable("project_id", project_id);
			flashHeaderObj.write("project_info_col_1");
		}
	},
	setupAjaxNews: function() {
		if ( $('news_article_wrapper') ) {
			var url = "/res/actions/get_rss_news.php";
			new Ajax(url, {
				method: 'get',
				update: $('news_article_wrapper'),
				onComplete: function() { setTimeout (Site.setupNewsArticlesScroll, 10000); }
			}).request();
		}
	},
	removeTeamPhoto: function(user_id) {
		if ( confirm("Are you sure you want to delete this photo?") ) {
			var url = "/res/actions/ajax/remove_team_photo.php?user_id="+user_id;
			$('team_photo_'+user_id).setProperty('src','http://<?php echo $DATA_HOST[$SERVER] ?>/lib/team_photos/no_image.jpg');
			new Ajax(url, {
				method: 'get',
				update: $('team_update_status'),
				onComplete: function() { 
					$$('.team_edit_images').each(function(img) {
						$(img).setProperty('src',$(img).getProperty('src'));
					});
				}
			}).request();
		}
	},
	removeInsightPhoto: function(insight_id) {
		if ( confirm("Are you sure you want to delete this photo?") ) {
			var url = "/res/actions/ajax/remove_insight_photo.php?insight_id="+insight_id;
			$('insight_photo_'+insight_id).setProperty('src','');
			new Ajax(url, {
				method: 'get',
				update: $('insight_update_status'),
				onComplete: function() { 
					$$('.team_edit_images').each(function(img) {
						$(img).setProperty('src',$(img).getProperty('src'));
					});
				}
			}).request();
		}
	},
	removeMembershipPhoto: function(membership_id) {
		if ( confirm("Are you sure you want to delete this photo?") ) {
			var url = "/res/actions/ajax/remove_membership_photo.php?membership_id="+membership_id;
			$('membership_photo_'+membership_id).setProperty('src','');
			new Ajax(url, {
				method: 'get',
				update: $('membership_update_status'),
				onComplete: function() { 
					$$('.team_edit_images').each(function(img) {
						$(img).setProperty('src',$(img).getProperty('src'));
					});
				}
			}).request();
		}
	},
	validateContactForm: function() {
		var contactObj 				= new Object;
		contactObj.errorStyles 		= new Object;
		contactObj.errorCssClassOff	= 'contactErrorFieldOff';
		contactObj.useEffects		= true;
		contactObj.requiredFields 	= new Object;
		contactObj.emailFields 		= new Object;
		contactObj.numberFields		= new Object;
		contactObj.requiredFields.contact_name = "Name is Required.";
		contactObj.emailFields.contact_email = "Email is Required.";
		contactObj.numberFields.contact_validation = "Validation Code is Required.";
		contactObj.errorStyles.backgroundColor = "#b20000";
		contactObj.errorStyles.color = "#ffffff";
		if ( ajaxValidateForm( 'frmContact', contactObj ) ) {
			$('frmContact').setStyle('display', 'none');
			$('form_status_bar').setHTML('<span class="project_action_message"><img align="absmiddle" src="/lib/images/spinner.gif" alt="" />&nbsp;&nbsp;&nbsp;Please Wait Sending</span>');
			$('is_ajax').value = 'true';
			$('frmContact').send({
				update: $('frmContact'),
				onComplete: function() {
					$('form_status_bar').setHTML('');
					$('frmContact').setStyle('display', 'inline');
				}
			});
		}
	},
	removeUser: function(id) {
		if ( confirm("Are you sure you want to delete this user?") ) {
			var col_1 = $(id+"_team_col_1");
			var col_2 = $(id+"_team_col_2");
			var mce   = $(id+"_user_info_container");
			var myFx = new Fx.Style(col_1, 'opacity').start(1,0);
			var myFx2 = new Fx.Style(col_2, 'opacity').start(1,0);
			var myFx3 = new Fx.Style(mce, 'opacity').start(1,0);
			$(id+"_deleted").setProperty('value',1);
		}
	},
	removeInsight: function(id) {
		if ( confirm("Are you sure you want to delete this insight?") ) {
			var col_1 = $(id+"_insights_col_1");
			var col_2 = $(id+"_insights_col_2");
			var mce   = $(id+"_insight_title");
			var mce2   = $(id+"_insight_text");
			var myFx = new Fx.Style(col_1, 'opacity').start(1,0);
			var myFx2 = new Fx.Style(col_2, 'opacity').start(1,0);
			var myFx3 = new Fx.Style(mce, 'opacity').start(1,0);
			var myFx4 = new Fx.Style(mce2, 'opacity').start(1,0);
			$(id+"_deleted").setProperty('value',1);
		}
	},
	removeMembership: function(id) {
		if ( confirm("Are you sure you want to delete this membership?") ) {
			$(id+"_deleted").setProperty('value',1);
			var col_1 = $(id+"_memberships_col_1");
			var col_2 = $(id+"_memberships_col_2");
			var mce   = $(id+"_memberships_title");
			var mce2   = $(id+"_memberships_text");
			var myFx = new Fx.Style(col_1, 'opacity').start(1,0);
			var myFx2 = new Fx.Style(col_2, 'opacity').start(1,0);
			//var myFx3 = new Fx.Style(mce, 'opacity').start(1,0);
			//var myFx4 = new Fx.Style(mce2, 'opacity').start(1,0);
			var myFx3 = new Fx.Style(col_1, 'height').start(0);
			var myFx4 = new Fx.Style(col_2, 'height').start(0);
			
		}
	},
	teamUpdateStatus: function(msg) {
		$('team_update_status').setHTML(msg);
		$$('.team_edit_images').each(function(img) {
			$(img).setProperty('src',$(img).getProperty('src'));
		});
	},
	teamNewStatus: function(msg) {
		$('team_new_status').setHTML(msg);
	},
	insightUpdateStatus: function(msg) {
		$('insight_update_status').setHTML(msg);
		$$('.insight_edit_images').each(function(img) {
			$(img).setProperty('src',$(img).getProperty('src'));
		});
	},
	insightNewStatus: function(msg) {
		$('insight_new_status').setHTML(msg);
	},
	membershipUpdateStatus: function(msg) {
		$('membership_update_status').setHTML(msg);
		$$('.membership_edit_images').each(function(img) {
			$(img).setProperty('src',$(img).getProperty('src'));
		});
	},
	membershipNewStatus: function(msg) {
		$('membership_new_status').setHTML(msg);
	}
}
window.addEvent('domready', Site.pageDomReady);
window.addEvent('load', Site.pageLoaded);