
    function atlas_image(URL) {
        var rf_img = new Image();
        rf_img.src = "http://view.atdmt.com/iaction/" + URL + '/?' + Math.random();
		//trace("image_track="+URL);
    }
	
	function atlas_js(URL)
	{
		if ( URL )
		{
		  var element = document.getElementById(URL);
		  if (element) document.body.removeChild(element);
		  element = document.createElement('script');
		  element.setAttribute('id',URL);
		  element.setAttribute('type','text/javascript');
		  document.body.appendChild(element);
		  element.src = "http://view.atdmt.com/jaction/"+URL+ '/?' + Math.random();
		  //trace("js_track="+URL);
		}
	}

	function post_facebook() {
		var address = "http://www.facebook.com/share.php?u="+encodeURIComponent(site_address)+"&t="+encodeURIComponent("Share the Love - Bath &amp; Body Works");
		open_window(address);
	}
	
	function post_twitter() {
		var address = "http://twitter.com/home?status="+encodeURIComponent("I shared my love. You should too. "+site_address);
		open_window(address);
	}
	
	function open_window(address) {
		window.open(address, '_blank');
		return false;
	}
	
	function open_popup(address) {
		window.open(address, "bbwwindow","location=0,status=0,scrollbars=1,width=670,height=350");
		return false;
	}
	
	function show_terms() { 
		open_popup("/terms/");
	}
	
	function show_hints() { 
		open_popup("/official-rules/#submissions");
	}
	
	function show_rules() { 
		open_popup("/official-rules/");
	}
	
	function show_shipping() {
		open_popup('/shipping-promotion/');	
	}
	
	function survey() {
		//open_popup('/survey/');	
	}
	
	function track(category,action,label,value) {
		//trace("category="+category+"&action="+action+"&label="+label+"&value="+value);
		if(label.length>0&&value.length>0) {
			pageTracker._trackEvent(category,action,"VideoEvent",Math.floor(value));
		} else if(label.length>0) {
			pageTracker._trackEvent(category,action,label);
		} else {
			pageTracker._trackEvent(category,action);
		}
	}
	
	function save_story(image,x,y,title,story,name,email_address) {
		/*if(image.length>0&&title.length>0&&story.length>0&&name.length>0&&email_address.length>0) {
			
			// encode
			image=encodeURIComponent(image);
			title=encodeURIComponent(title);
			story=encodeURIComponent(story);
			name=encodeURIComponent(name);
			email_address=encodeURIComponent(email_address);
			
			$.ajax({
				type: "POST",
				url: "/ajax/save_story.php",
				data: "image="+image+"&x="+x+"&y="+y+"&title="+title+"&story="+story+"&name="+name+"&email_address="+email_address,
				success: function(result){
					if(result==0) this_movie("flashcontent").upload_failure();
					this_movie("flashcontent").upload_success();
				},
				error: function(msg1,msg2,msg3) {
					this_movie("flashcontent").upload_failure();
				}
			});
		} else {
			this_movie("flashcontent").upload_failure();
		}*/
	}
	
	function love_it(id) {
		if(id>0) {
			$.ajax({
				type: "POST",
				url: "/ajax/love_it.php",
				data: "id="+id,
				success: function(result){
					if(result==0) this_movie("flashcontent").love_it_failure();
					this_movie("flashcontent").love_it_success();
				},
				error: function(msg1,msg2,msg3) {
					this_movie("flashcontent").love_it_failure();
				}
			});
		} else {
			this_movie("flashcontent").love_it_failure();
		}
	}
	
	function trace(msg){
		console.log(msg);
	}
	
	$().ready(function() {
					   
		// PREPARE VARIABLES
		var flashvars = { siteXML:"xml/site.xml" };
		var params = { quality:"high",scale:"noscale",wmode:"window",allowscriptaccess:"always",bgcolor:"#FFFFFF" };
		var attributes = { id:"flashcontent" };
		
		// PLACE SWF
		swfobject.embedSWF("main.swf", "flashcontent", "910", "640", "9", "/swf/expressInstall.swf", flashvars, params, attributes);
	
	});