/* VMG PARTNERS */
/* Javascript Functions
----------------------------------------------------------------------------- */


/* POST-LOAD FUNCTION
----------------------------------------------------------------------------- */


	$(window).load(function() {

		// HEADER FLASH
		header();
		markup();
		
		if (page == "directions") {
		
			routes();
		
		}
		
		if (page == "index") {
		
			whatisVmg();
		
		}
				
		// REPLACE INSERTED PHOTO WITH ITS ENLARGED VIEW
		if (page == "article") {

			if ($('div.story').find('a.photo').length > 0) {
			
				$('div.story a.photo').each(function() {

					var source = $(this).children('img').attr('src').replace('thumb.', '');
					$(this).children('img').attr('src', source);
					$(this).replaceWith($(this).children('img'));
					
				});
				
			}
		
		}

	});


/* FUNCTION: HEADER
----------------------------------------------------------------------------- */


	function header() {

		var height = "88";
		var flash_section;

		if (page == "index") {

			flash_section = "0";

		}

		else if (page == "team") {

			flash_section = "1";

		}

		else if (page == "philosophy") {

			flash_section = "2";

		}

		else if (page == "portfolio") {

			flash_section = "3";

		}

		else if (page == "news") {

			flash_section = "4";

		}

		else if (page == "article") {

			flash_section = "4";

		}

		else if (page == "contact") {

			flash_section = "5";

		}

		if (page != "routes") {

			var so = new SWFObject( asset_host + "/flash/header.swf", "header.swf", "960", height, "8", "#FFFFFF", true );
			so.addVariable( "section", flash_section );
			so.addVariable( "asset_host", asset_host);
			so.useExpressInstall( asset_host + "/expressinstall.swf");
			so.addParam("AllowScriptAccess", "always");
//			so.write( "header" );
		
		}

	}
	
	
/* FUNCTION: MARKUP
----------------------------------------------------------------------------- */


	function markup() {

		$("#page-index div.widget-editorial.leads h4 a").attr("href", "#");
		$('#page-portfolio div.widget-tag ul.tags > li').each(function() {
			
			var clientName = $(this).children().children('img').attr('alt');
									
			$(this).children('a').attr('title', 'More Info About ' + clientName);
			
		});

	}	


/* FUNCTION: ROUTES
----------------------------------------------------------------------------- */


	function routes() {

		$('#directions ul li a').click(function() {
		
			routes=window.open(
			
				$(this).attr('href'),
				"Directions",
      			"toolbar=no,width=670,height=670,directories=0,status=0,scrollbars=1,resize=1,menubar=0,location=0,left=20,top=20,screenX=20,screenY=20"
      		
      		);
      		
      		return false;
		
		});

	}
	

/* FUNCTION: TWITTER
----------------------------------------------------------------------------- */


	function twitter() {
	
		$('div.tweets').tweet({
		
        	username: "vmgpartners",
          	count: 5,
          	loading_text: "Loading tweets..."

     	 });
     	 
     	 // Using setTimeout since tweet plugin doesn't have callback
     	 setTimeout(cufon, 1000);
     	 setTimeout(function() {
     	 
			$('#ticker ul.tweet_list').cycle({
	
				speed: 300,
				timeout: 7000
	
			});
     	 
     	 }, 1000);
	
	}
	
	
	
/* FUNCTION: WAHT IS VMG? TOGGLE
--------------------------------------------------------------------------- */

	
	function whatisVmg() {
	

		$('div.what_is_vmg a.prompt').toggle(function() {
					
			$('div.what_is_vmg p').slideDown('500');
			$('div.what_is_vmg a.prompt').addClass("up");
			return false;
					
		}, function() {
		
			$('div.what_is_vmg p').slideUp('500');
			$('div.what_is_vmg a.prompt').removeClass("up");
			return false;
			
		});

	
	}

	
