/*
 *  Laser Lib - v2
 *  Copyright 2009, Laser Sream Video
 *  Patent Pending USPTO Number 11/465,409
 *
 * new functions
 * laser_create will create and show the div
 * laser_delete
 * laesr_show will no longer create
 * laser_hide will only make the div invisable
 */

function ImageObject(){
	this.laser_hide          = laser_hide;
	this.laser_set_css       = laser_set_css;
	this.laser_show_image    = laser_show_image;
	this.laser_find_center   = laser_find_center;
}

function VideoObject(){
	this.laser_hide          = laser_hide;
	this.laser_set_css       = laser_set_css;
	this.laser_show_video    = laser_show_video;
	this.laser_find_center   = laser_find_center;
}

function AjaxObject () {
	this.laser_hide	         = laser_hide;
	this.laser_set_css       = laser_set_css;
	this.laser_show_ajax     = laser_show_ajax;
	this.laser_find_center   = laser_find_center;
}

function IframeObject () {
	this.laser_hide	         = laser_hide;
	this.laser_set_css       = laser_set_css;
	this.laser_show_iframe   = laser_show_iframe;
	this.laser_find_center   = laser_find_center;
}

function laser_show_image(){
	
	this.laser_set_css();
	
	jQuery("#" + this.name).append( "<img src='" + this.url + "' />" );
}

function laser_show_ajax() {

	this.laser_set_css();
	
	jQuery("#" + this.name).load(this.url);
}

function laser_show_iframe() {

	this.laser_set_css();
	
	jQuery("#" + this.name).append("<iframe name='iframe_"+this.name+"' frameborder='0'  vspace='0'  hspace='0'  marginwidth='0'  marginheight='0' width='"+this.width+"'  scrolling='no'  height='"+this.height+"'  src='"+this.url+"'></iframe>");

}

function laser_show_video() {
	
	this.laser_set_css();

	jQuery("#" + this.name).append( 
		"<object width='" + this.width + "' height='" + this.height + "'>" +
		"<param name='movie' value='" + this.url + "'>" +
		"<param name='wmode' value='transparent'>"+
		"<param name='allowScriptAccess' value='sameDomain'>"+
		"<embed src='" + this.url + 
		"' width='"    + this.width + 
		"' height='"   + this.height + 
		"' wmode='transparent'>" +
		"</embed>"+
		"</object>"
	);
}

function laser_set_css(){

	var dn  = "#" + this.name;

	jQuery(dn).remove();
	
	jQuery("body").append("<div id='"+this.name+"'/>");

	if (this.anchor_bottom) {

 			// anchor the object to the bottom
 			if( jQuery.browser.msie ) {

	 			jQuery("html body").css("height","100%");
	 			jQuery("html body").css("overflow","auto");
				jQuery(dn).css("position","absolute");

			} else {

				jQuery(dn).css("position","fixed");
			}
			jQuery(dn).css("bottom",this.bottom || "0");
	} else {

		// do normal positioning
		jQuery(dn).css("position","absolute");
		jQuery(dn).css("top",this.top);
	
	}
	
	if (this.anchor_right) {
		jQuery(dn).css("right","0");
	} else {
		jQuery(dn).css("left",this.left + this.laser_find_center());
	}
	jQuery(dn).css("width",this.width);
	jQuery(dn).css("height",this.height);
	jQuery(dn).css("z-index",this.zindex);
}

function laser_hide(){ 

	jQuery("#"+this.name).remove(); 
}

function laser_soft_hide(){ 

	jQuery("#"+this.name).hide(); 
}

// turn this into a ternary operator
function laser_find_center(){
	
	if (this.center){ return jQuery(window).width() / 2 ; } 
	
	else { return 0; }
}

jQuery.laser_cookie = function(name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options = jQuery.extend({}, options);
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { 
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
jQuery.noConflict();

jQuery(document).ready(function(laser) {

	var web_page        = "http://www.nancyaridenhour.com";

var cookie_days     = 1;

var video           = new VideoObject();
video.url           = "/wp-content/themes/nancyridenhour/scripts/spokesmodel/home.swf";
video.name          = "laser_home_video_nr";
video.center        = false;
video.top           = 150;
video.anchor_bottom = true;
video.anchor_right = true;
video.left          = 0;
video.width         = 300;
video.height        = 500;
video.zindex        = 2000;

var image          = new ImageObject();
image.url          = "/wp-content/themes/nancyridenhour/scripts/spokesmodel/Play-Video-3.gif";
image.name         = "play_video_image";
image.center       = false;
image.anchor_bottom = true;
image.anchor_right = true;
image.top = 50;
image.left = 10;
image.zindex       = 1;
	if (laser.laser_cookie(video.name)){
	
		image.laser_show_image();
		
		laser("#"+image.name).click(function(){ 
					
			image.laser_hide();
			
			video.laser_show_video(); 
		});
		
	} else {

		laser.laser_cookie(video.name, true, { expires: cookie_days });
		
		video.laser_show_video();
	}
});
