/*
if (document.layers) {
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = captureMousePosition;
} else if (document.all) {
	document.onmousemove = captureMousePosition;
} else if (document.getElementById) {
	document.onmousemove = captureMousePosition;
}
var document_obj = document.getElementById('document');
var document_container = document.getElementById('document_container');

var drag = false;
var cXp = 0;
var cYp = 0;
var xMousePos = 0;
var yMousePos = 0;
var xMousePosMax = 0;
var yMousePosMax = 0;
function captureMousePosition(e) {
	if (!e) var e = window.event;
	if (navigator.appName !="Microsoft Internet Explorer") {
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
	} else {
		xMousePos = window.event.x+document.body.scrollLeft;
		yMousePos = window.event.y+document.body.scrollTop;
		xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
		yMousePosMax = document.body.clientHeight+document.body.scrollTop;   
	}
	//window.status = "x:"+xMousePos+"  y:"+yMousePos;
}
*/

function SetCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
function setHeaderCookie(name,value){
	var expirationDate = new Date("June 5, 2010");
	SetCookie('header['+name+']',value, expirationDate, '/');
}

function get_abs_pos_from_elm(el){
	var SL = 0, ST = 0;
	var is_div = /^div$/i.test(el.tagName);
	if (is_div && el.scrollLeft)
		SL = el.scrollLeft;
	if (is_div && el.scrollTop)
		ST = el.scrollTop;
	var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
	if (el.offsetParent) {
		var tmp = get_abs_pos_from_elm(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}

function hide_floating_elms(){
	if(navigator.appName == "Microsoft Internet Explorer"){
		var tags = new Array("select", "iframe", "applet");
		for(var i in tags){
			var c_tags = document.getElementsByTagName(tags[i]);
			for(var a=0; a < c_tags.length; ++a){
				c_tags[a].style.visibility = 'hidden';
			}
		}
	}
}
function show_floating_elms(base){
	if(navigator.appName == "Microsoft Internet Explorer"){
		var tags = new Array("select", "iframe", "applet");
		for(var i in tags){
			if(base){
				var c_tags = base.getElementsByTagName(tags[i]);
			}else{
				var c_tags = document.getElementsByTagName(tags[i]);
			}
			for(var a=0; a < c_tags.length; ++a){
				c_tags[a].style.visibility = 'visible';
			}
		}
	}
}

function floating_window(){
	var self = this;
	var base_div = document.createElement('div');
		base_div.style.display = 'none';
	var s_body = document.getElementById('s_body');
		s_body.style.height = '0px';
		s_body.appendChild(base_div);
	var transparency;
	var owner_obj;
	var interval;
	var transparency_int;
	
	function set_content(str){
		base_div.innerHTML = str;
	}
	function set_visible(bool){
		base_div.style.display =(bool)?'':'none';
	}
	function set_width(num){
		base_div.style.width = String(num)+'px';
	}
	function set_height(num){
		base_div.style.height = String(num)+'px';
	}
	function set_position(x,y,z){
		//window.status = 'x:'+x+' y:'+y+' z:'+z;
		if(navigator.appName == 'Microsoft Internet Explorer'){
			x += 1;
			y += 1;
		}
		base_div.style.top = String(y) + 'px';
		base_div.style.left = String(x) + 'px';
		base_div.style.zIndex = String(z);
	}
	function set_base_className(str){
		base_div.className = str;
	}
	function set_transparency(num){
		transparency = num;
		if(navigator.appName == 'Microsoft Internet Explorer'){
			base_div.style.filter = 'alpha(opacity='+String(num)+'0)';
		}else{
			base_div.style.opacity = String(num * .1);
		}
		return(transparency);
	}
	function animate_transparency(){
		var c_trans = get_transparency();
		var n_trans = c_trans + transparency_int;
		if(n_trans >= 10){
			n_trans = 10;
			clearInterval(interval);
		}
		if(n_trans <= 0){
			n_trans = 0;
			clearInterval(interval);
			set_visible(false);
		}
		set_transparency(n_trans);
	}
	function get_transparency(){
		return(transparency);
	}
		
	function fade_in(){
		set_visible(true);
		transparency_int = 3;
		clearInterval(interval);
		interval = setInterval(animate_transparency,1);
		
	}
	function fade_out(){
		transparency_int = -1;
		clearInterval(interval);
		interval = setInterval(animate_transparency,1);
	}
	
	this.set_content = set_content;
	this.set_visible = set_visible;
	this.set_width = set_width;
	this.set_height = set_height;
	this.set_position = set_position;
	this.set_base_className = set_base_className;
	this.set_transparency = set_transparency;
	
	this.get_transparency = get_transparency;
	
	this.fade_in = fade_in;
	this.fade_out = fade_out;
}

floating_window.prototype.info_balloon = function(){
	var self = this;
	
	var owner_obj;
	var attached = false;
	var owner_y;
	var off_timer;
	
	this.set_base_className('info_ballon');
	
	function attach(obj){
		if(obj){
			owner_obj = obj;
			attached = true;
		}
		return(attached);
	}
	function set_position_from_mouse(){
		/*
		if(!owner_y){
			owner_y = get_abs_pos_from_elm(owner_obj).y + owner_obj.clientHeight+owner_obj.scrollTop;
			window.status = get_abs_pos_from_elm(owner_obj).y + owner_obj.clientHeight+owner_obj.scrollTop;
		}*/
		self.set_position(xMousePos+5,yMousePos+10,900);
	}
	function start_follow_mouse(){
		if(attached){
			owner_obj.onmousemove = set_position_from_mouse;
			//window.status ="start follow";
		}
	}
	
	function stop_follow_mouse(){
		owner_obj.onmousemove = null;
		//window.status ="stop follow";
	}
	
	function show(){
		start_follow_mouse()
		self.fade_in();
	}
	
	function hide(){
		stop_follow_mouse();
		self.fade_out();
	}
	
	this.show = show;
	this.hide = hide;
	this.attach = attach;
	this.start_follow_mouse = start_follow_mouse;
	this.stop_follow_mouse = stop_follow_mouse;
}

function dd_menu_display(){
	var s_body = document.getElementById('s_body');
	this.current_menu;
	this.off_bounds = new Object();
	this.menu_owner;
	var is_menu_visible = false;
	var off_bounds;
	var current_menu;
	function set_off_bounds_by_menu_obj(){
		var r = this.current_menu.get_position();
		this.off_bounds.l = Number(r.x);
		this.off_bounds.r = Number(r.x) + Number(r.w);
		this.off_bounds.t = Number(r.y);
		this.off_bounds.b = Number(r.y) + Number(r.h);
		off_bounds = this.off_bounds;
	}
	
	function show_menu(menu_obj,owner_obj){
		this.current_menu = menu_obj;
		this.current_menu.show(owner_obj);
		current_menu = this.current_menu;
		this.set_off_bounds_by_menu_obj();
		is_menu_visible = true;
		hide_floating_elms();
		document.onmousedown = function(){
			hide_current_menu_by_mouse_pos();
		}
	}
	function hide_current_menu(){
		this.current_menu.hide();
		is_menu_visible = false;
		show_floating_elms();
		document.onmousedown = function(){}
	}
	function hide_current_menu_by_mouse_pos(){
		if(xMousePos < off_bounds.l || xMousePos > off_bounds.r || yMousePos < off_bounds.t || yMousePos > off_bounds.b){
			current_menu.hide();
			is_menu_visible = false;
			show_floating_elms();
			document.onmousedown = function(){}
		}
	}
	function check_switch(menu_obj,owner_obj){
		//window.status = "is_menu_visible =" + is_menu_visible
		if(is_menu_visible){
			this.hide_current_menu();
			this.show_menu(menu_obj,owner_obj);
		}
	}
	
	this.show_menu = show_menu;
	this.hide_current_menu = hide_current_menu;
	this.hide_current_menu_by_mouse_pos = hide_current_menu_by_mouse_pos;
	this.set_off_bounds_by_menu_obj = set_off_bounds_by_menu_obj;
	this.check_switch = check_switch;
}

function dd_menu(item_array){
	var s_body = document.getElementById('s_body');
	this.owner_obj;
	this.tallest_img_height;
	this.cont_div = document.createElement('div');
	this.cont_div_shaddow = document.createElement('div');
	var shaddow_spacer = new Image(1,1);
		shaddow_spacer.scr ='/skins/works/widgets_2/common/spacer.gif';
	this.cont_div_shaddow.appendChild(shaddow_spacer);
	this.cont_div.className="dd_menu";
	this.cont_div_shaddow.className="dd_shaddow";
	
	this.cont_div.style.position = "absolute";
	this.cont_div.style.display = 'none';
	this.cont_div_shaddow.style.display = 'none';
	
	this.item_table = document.createElement('table');
	this.item_table.setAttribute('cellpadding','0');
	this.item_table.setAttribute('cellspacing','0');
	this.item_table.setAttribute('border','0');
		
	this.item_table.className = "item_table";
	var tbody = document.createElement('tbody');
	this.item_table.appendChild(tbody);
	
	this.item_array;
	
	s_body.appendChild(this.cont_div);
	s_body.appendChild(this.cont_div_shaddow);

	this.cont_div.appendChild(this.item_table);
	
	function create(item_array){
		this.item_array = item_array;
		var count = 0;
		for(var i in this.item_array){
			if(this.item_array[i] != 'seperator'){
				this.item_array[i]['h'] = this.create_menu_item(this.item_array[i].c,this.item_array[i].u,this.item_array[i].iu,this.item_array[i].confirmText);
			}else if(this.item_array[i] == 'seperator'){
				this.item_array[i]['h'] = this.create_seperator();
			}
		}
		//this.cont_div.innerHTML = this.cont_div.innerHTML;
		this.set_shaddow();
	}
	
	function set_shaddow(){
		this.cont_div_shaddow.style.width = String(this.cont_div.clientWidth)+"px";
		this.cont_div_shaddow.style.height = this.cont_div.clientHeight+3+"px";
		this.cont_div_shaddow.style.top = String(Number(this.cont_div.style.top.substring(0,this.cont_div.style.top.indexOf('px'))))+'px';
		this.cont_div_shaddow.style.left = String(Number(this.cont_div.style.left.substring(0,this.cont_div.style.left.indexOf('px'))) - 3)+'px';
	}
	
	function set_position(x,y){
		if(navigator.appName == 'Microsoft Internet Explorer'){
			x += 1;
			y += 1;
		}
		y += 2;
		this.cont_div.style.left = String(x)+'px';
		this.cont_div.style.top = String(y)+'px';
	}
	function set_position_from_element(obj_element){
		r = get_abs_pos_from_elm(obj_element);
		this.set_position(r.x,r.y+obj_element.clientHeight);
		this.set_shaddow();
	}
	function get_position(){
		r = new Object;
		r.y = this.cont_div.style.top.substring(0,this.cont_div.style.top.indexOf('px'));
		r.x = this.cont_div.style.left.substring(0,this.cont_div.style.left.indexOf('px'));
		r.h = this.cont_div.clientHeight;
		r.w = this.cont_div.clientWidth;
		return(r);
	}
	function set_visibility(bool){
		this.cont_div.style.display = (bool)?'':'none';
		this.cont_div_shaddow.style.display = (bool)?'':'none';
		this.set_shaddow();
	}
	function create_menu_item(caption,url,icon_url,confirm_text){
		var new_row = document.createElement('tr');
			new_row.className = "standard_row";
			new_row.onmouseover = function(){
				this.className = 'hover_row';
				window.status = caption;
			}
			new_row.onmouseout = function(){
				this.className = 'standard_row';
				window.status = '';
			}
			if(confirm_text){
				new_row.setAttribute("onclick","var yes = confirm('"+confirm_text+"'); if(yes){location.href = '"+url+"' }");
			}else{
				new_row.setAttribute("onclick","location.href = '"+url+"'");
			}
			if(confirm_text){
				new_row.onclick = function(){
					var yes = confirm(confirm_text);
					if(yes){
						location.href = url;
					}
				}
			}else{
				new_row.onclick = function(){
					location.href = url;
				}
			}
		var icon_td = document.createElement('td');
			new_row.appendChild(icon_td);
		var image_obj = new Image();
			if(icon_url){
				image_obj.src = icon_url;
				this.tallest_img_height = image_obj.height;
			}else{
				image_obj.src = '/skins/works/widgets_2/common/spacer.gif';
			}
			icon_td.appendChild(image_obj);
			icon_td.className = "icon";
		var caption_td = document.createElement('td');
			new_row.appendChild(caption_td);
			caption_td.className = "caption";
		var caption_text = document.createTextNode(caption);
			caption_td.appendChild(caption_text);
			this.item_table.firstChild.appendChild(new_row);
		return(new_row);
	}
	function remove_menu_item(item_index){
		
	}
	function create_seperator(height,style,color){
		var new_row = document.createElement('tr');
			new_row.className = "seperator";
		var td = document.createElement('td');
		var td2 = document.createElement('td');
			new_row.appendChild(td);
			new_row.appendChild(td2);
		var image_obj = new Image(1,1);
			image_obj.src = "/skins/works/widgets_2/common/spacer.gif";
		var image_obj2 = new Image(1,1);
			image_obj2.src = "/skins/works/widgets_2/common/spacer.gif";
			td.appendChild(image_obj);
			td2.appendChild(image_obj2);
			this.item_table.firstChild.appendChild(new_row);
		return(new_row);
	}
	function remove_seperator(item_index){
		
	}
	
	function show(caller_obj){
		this.owner_obj = caller_obj;
		this.set_position_from_element(caller_obj);
		this.set_visibility(true);
		caller_obj.className = 'selected';
	}
	function hide(){
		this.owner_obj.className = 'standard';
		this.set_visibility(false);
	}
	
	this.create = create;
	this.set_shaddow = set_shaddow;
	this.set_position = set_position;
	this.set_position_from_element = set_position_from_element;
	this.set_visibility = set_visibility;
	this.create_menu_item = create_menu_item;
	this.remove_menu_item = remove_menu_item;
	this.create_seperator = create_seperator;
	this.remove_seperator = remove_seperator;
	this.get_position = get_position;
	this.show = show;
	this.hide = hide;
	
	this.create(item_array);
}
var display_locked = false;
function combo_box(){
	var s_body = document.getElementById('s_body');
	this.owner_element
	var owner_element
	this.cont_div = document.createElement('div');
	this.cont_div_shaddow = document.createElement('div');
	s_body.appendChild(this.cont_div);
	s_body.appendChild(this.cont_div_shaddow);
	this.cont_div.className="combo_box_container";
	this.cont_div_shaddow.className="combo_box_container_shaddow";
	this.cont_div.style.position = "absolute";
	this.cont_div.style.display = 'none';
	this.cont_div.innerHTML = '<div style="padding:5px;">Loading Please Wait&#160;&#160;&#160;<img src="/skins/works/widgets_2/bumper/ticker.gif" alt="" width="15" height="15" border="0" align="absmiddle"></div>';
	this.cont_div_shaddow.innerHTML = '<img src="/skins/works/widgets_2/commom/spacer.gif" alt="" width="1" height="1" border="0">';
	var cont_div = this.cont_div;
	var cont_div_shaddow = this.cont_div_shaddow;
	this.off_bounds = new Array();
	set_shaddow_position();
	
	function set_off_bounds(){
		var r = this.get_position();
		this.off_bounds.l = Number(r.x);
		this.off_bounds.r = Number(r.x) + Number(r.w)+18;
		this.off_bounds.t = Number(r.y);
		this.off_bounds.b = Number(r.y) + Number(r.h);
		off_bounds = this.off_bounds;
	}
	function set_shaddow_position(){
		var r = get_position();
		cont_div_shaddow.style.width = Number(r.w)-3 +'px';
		cont_div_shaddow.style.height = Number(r.h) +'px';
		cont_div_shaddow.style.top = Number(r.y)+6 +'px';
		cont_div_shaddow.style.left = Number(r.x)-3 +'px';
	}
	
	function set_position(x,y){
		cont_div.style.left = String(x)+'px';
		cont_div.style.top = String(y)+'px';
		set_shaddow_position();
	}	
	function set_visible(bool){
		cont_div.style.display = (bool)?'':'none';
		cont_div_shaddow.style.display = cont_div.style.display;
	}	
	this.set_owner_element = function(new_owner){
		this.owner_element = new_owner;
		owner_element = new_owner;
	}
	this.set_owner_id = function(id){
		this.owner_element_id = id;
	}
	function get_abs_pos_from_elm(el){
		var SL = 0, ST = 0;
		var is_div = /^div$/i.test(el.tagName);
		if (is_div && el.scrollLeft)
			SL = el.scrollLeft;
		if (is_div && el.scrollTop)
			ST = el.scrollTop;
		var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
		if (el.offsetParent) {
			var tmp = get_abs_pos_from_elm(el.offsetParent);
			r.x += tmp.x;
			r.y += tmp.y;
		}
		return r;
	} 
	function get_adj_pos_from_owner(){
		r = get_abs_pos_from_elm(owner_element);
		r.y += (navigator.appName == "Microsoft Internet Explorer")? owner_element.clientHeight +2: owner_element.clientHeight;
		r.x += (navigator.appName == "Microsoft Internet Explorer")? 1: 0;
		return(r);
	}
	function set_width(num){
		cont_div.style.width = (navigator.appName == "Microsoft Internet Explorer")? String(num+2) +'px': String(num) +'px';
		this.set_off_bounds();
		set_shaddow_position();
	}
	function set_height(num,show_overflow){
		if(num){
			cont_div.style.height = String(num)+'px';
			cont_div.style.overflow = (show_overflow)?'show':'auto';
		}else{
			cont_div.style.height ='';
		}
		set_shaddow_position();
	}
	function set_width_from_owner(){
		//set_width(owner_element.clientWidth);
	}
	function set_display(){
		if(!this.owner_element){
			this.set_owner_element(document.getElementById(this.owner_element_id));
		}
		pos = get_position();
		var reposition = false;
		if(owner_element){
			var availiable_y_space = document.body.clientHeight - pos.y - 5;
			var availiable_neg_y_space = pos.y - owner_element.clientHeight - 3;
			if(availiable_y_space < 150 && availiable_neg_y_space >= 150){
				var avail_space = availiable_neg_y_space;
				reposition = true;
			}else{
				var avail_space = availiable_y_space;
			}
		}
		if(avail_space < cont_div.clientHeight){
			this.set_height(avail_space,false);
		}
		if(reposition){
			this.set_position(pos.x,pos.y - cont_div.clientHeight - owner_element.clientHeight - 2);
		}
		this.set_off_bounds();
		set_shaddow_position();
	}
	function set_content(str){
		set_shaddow_position();
		this.set_height('',false);
		cont_div.innerHTML = str;
		this.set_display();
	}	
	function show(){
		if(!this.owner_element){
			this.set_owner_element(document.getElementById(this.owner_element_id));
		}
		var r = get_adj_pos_from_owner();
		this.set_position(r.x,r.y);
		this.set_width_from_owner();
		this.set_visible(true);
		hide_floating_elms();
		show_floating_elms(this.cont_div);
		this.set_off_bounds();
		document.onmousedown = function(){
			hide_by_mouse_pos();
		}
		this.set_display();
	};
	
	function hide(){
		set_visible(false);
		show_floating_elms();
	};
	
	function get_position(){
		r = new Object;
		r.y = cont_div.style.top.substring(0,cont_div.style.top.indexOf('px'));
		r.x = cont_div.style.left.substring(0,cont_div.style.left.indexOf('px'));
		r.w = cont_div.clientWidth+5;
		r.h = cont_div.clientHeight;
		return(r);
	}
	
	this.get_visible = function(){
	
	};
	
	function hide_by_mouse_pos(){
		if(!display_locked){
			if(xMousePos < off_bounds.l || xMousePos > off_bounds.r || yMousePos < off_bounds.t || yMousePos > off_bounds.b){
				set_visible(false);
				show_floating_elms();
				document.onmousedown = function(){}
			}
		}
	}
	
	this.show = show;
	this.hide = hide;
	this.set_content = set_content;
	this.set_visible = set_visible;
	this.set_height = set_height;
	this.set_width = set_width;
	this.set_width_from_owner = set_width_from_owner;
	this.set_position = set_position;
	this.set_off_bounds = set_off_bounds;
	this.hide_by_mouse_pos = hide_by_mouse_pos;
	this.get_position = get_position;
	this.get_abs_pos_from_elm = get_abs_pos_from_elm;
	this.get_adj_pos_from_owner = get_adj_pos_from_owner;
	this.set_shaddow_position = set_shaddow_position;
	this.set_display = set_display;
}



function slide_show(){
	var object = this;
	var base_image;
	var caption_owner;
	var time_interval;
	var interval
	var speed;
	var photos_array;
	var image_position;
	var position = 0;
	var current_image = false;
	var next_image = false;
	var run = false;
	var visible = true;
	function set_visibility(bool){
		if(current_image != false){
			current_image.style.display = (bool)?'':'none';
		}
		if(next_image != false){
			next_image.style.display = (bool)?'':'none';
		}
		visible = bool;
	}
	
	function position_image(img_obj){
		image_position = get_abs_pos_from_elm(base_image);
		img_obj.style.position = 'absolute';
		img_obj.style.zIndex = 800; 
		img_obj.style.top = image_position.y +'px';
		img_obj.style.left = image_position.x +'px';
		img_obj.style.width = base_image.width+1 + 'px';
		img_obj.style.height = base_image.height+1 + 'px';
	}
	function position_images(){
		if(next_image){
			position_image(next_image);
		}
		if(current_image){
			position_image(current_image);
		}
	}
	function set_base_image(image_obj){
		base_image = image_obj;
		image_position = get_abs_pos_from_elm(base_image);
		next_image = get_next_image();
	}
	function set_caption_owner(caption_obj){
		caption_owner = caption_obj
	}
	function set_caption(value){
		var new_val_elm = document.createTextNode(value);
		while(caption_owner.hasChildNodes()){
			caption_owner.removeChild(caption_owner.firstChild);
		}
		caption_owner.appendChild(new_val_elm);
	}
	function set_time_interval(value){
		time_interval = value;
	}
	function set_speed(value){
		speed = value;	
	}
	function set_photos_arrary(array){
		photos_array = array;
	}
	function set_current_image(index){
	
	}
	
	this.set_visibility = set_visibility;	
	this.set_base_image = set_base_image;
	this.set_caption_owner = set_caption_owner;
	this.set_time_interval = set_time_interval;
	this.set_speed = set_speed;
	this.set_photos_arrary = set_photos_arrary;
	this.position_images = position_images;
	
	function get_next_image(){
		next_pos = ((position + 1) >= photos_array.length)?0:position + 1;
		//alert(photos_array[next_pos]['th']);
		if(!photos_array[next_pos]['obj']){
			photos_array[next_pos]['obj'] = new Image();
			photos_array[next_pos]['obj'].src = photos_array[next_pos]['th'];
			photos_array[next_pos]['obj'].border = 0;
			photos_array[next_pos]['obj'].className = 'simple_border';
			photos_array[next_pos]['obj'].style.cursor = "pointer";
			photos_array[next_pos]['obj'].style.display = 'none';
			photos_array[next_pos]['obj'].onclick = function(){
				var none = window.open(photos_array[position]['fl']);
			}
			//s_body.appendChild(photos_array[next_pos]['obj']);
			document.body.appendChild(photos_array[next_pos]['obj']);
			/*
			if(navigator.appName == 'Microsoft Internet Explorer'){
				document.body.appendChild(photos_array[next_pos]['obj']);
			}else{
				//document.body.appendChild(photos_array[next_pos]['obj']);
				base_image.parentNode.appendChild(photos_array[next_pos]['obj']);
			}*/
			position_image(photos_array[next_pos]['obj']);
			photos_array[next_pos]['obj'].style.filter = 'alpha(opacity=0)';
			photos_array[next_pos]['obj'].style.opacity = '0';
		}
		position_image(photos_array[next_pos]['obj']);
		//photos_array[next_pos]['obj'].style.display = '';
		return(photos_array[next_pos]['obj']);
	}
	function move_carret(){
		if(run){
			position = (position + 1 >= photos_array.length)?0:position + 1;
			set_caption(photos_array[position]['mc']);
			if(current_image){
				current_image.style.display = 'none';
			}
			current_image = next_image;
			current_image.style.zIndex = 0;
			next_image = get_next_image();
			next_image.style.zIndex = 800;
			next_image.style.filter = 'alpha(opacity=0)';
			next_image.style.opacity = '0';
			interval = setInterval(swap_images,time_interval);
		}else{
			clearInterval(interval);
		}
		
	}
	ie_alhpha = 0;
	function fade_in_next_img(){
		//position_image(next_image);
		if(navigator.appName == "Microsoft Internet Explorer"){
			new_opacity = ie_alhpha + speed;
			next_image.style.filter = 'alpha(opacity='+String(new_opacity)+')';
			ie_alhpha = new_opacity;
			if(new_opacity >= 100){
				clearInterval(interval);
				ie_alhpha = 0;
				move_carret();
			}
		}else{
			new_opacity = Number(next_image.style.opacity) + (speed * .01);
			next_image.style.opacity = new_opacity;
			if(new_opacity >= 1){
				clearInterval(interval);
				move_carret();
			}
		}
	}
	function check_next_image_loaded(){
		if(next_image.complete){
			clearInterval(interval);
			interval = setInterval(fade_in_next_img,50);
			next_image.style.display = (visible)?'':'none';
		}
	}
	function swap_images(){
		if(next_image.complete){
			clearInterval(interval);
			interval = setInterval(fade_in_next_img,50);
			next_image.style.display = (visible)?'':'none';
		}else{
			clearInterval(interval);
			interval = setInterval(check_next_image_loaded,50);
		}
	}
	function start(){
		image_position = get_abs_pos_from_elm(base_image);
		run = true;
		interval = setInterval(swap_images,time_interval);
	}
	function stop(){
		run = false;
	}
	this.start = start;
	this.stop = stop;
	
	window.onresize = function(){
		position_images();
	}
}




function simple_ajax_html_element(owner,uri,timer){
	var xr = new XMLRequest();
	owner.InnerHTML = '<div style="padding:5px; background-color:#d5d5d5; border:1px solid #fff;"><img src="/skins/works/widgets_2/bumper/ticker.gif" alt="" width="15" height="15" border="0" align="absmiddle"/>&#160;&#160;&#160;Updating</div>'		
	function render_html_fragment(xr){
		owner.innerHTML = xr.responseText;
	}
	function get_html_fragment(){
		xr.connect('GET',uri,true);
		xr.sendAndLoad('',render_html_fragment);
	}
	get_html_fragment();
	if(timer > 0){ interval = setInterval(get_html_fragment,timer); }
}

function simple_ajax_element(){
		var parent_element;
		var xml_doc = new xml_document();
		var xsl_doc = new xml_document();
		var default_xml_url;
		var default_xsl_url;
		var timer;
		var interval;
		var update_message = 'Now Updating';
		var trans = new xml_xsl_transform();
		
		function set_bumper(){
			parent_element.innerHTML = '<div style="padding:5px; background-color:#d5d5d5; border:1px solid #fff;"><img src="/skins/works/widgets_2/bumper/ticker.gif" alt="" width="15" height="15" border="0" align="absmiddle"/>&#160;&#160;&#160;'+update_message+'</div>'		
		}
		
		function initialize(p_elm,xml_url,xsl_url,m_time){
			set_parent_element(p_elm);
			set_default_xml_url(xml_url);
			set_default_xsl_url(xsl_url);
			set_timer(m_time);
						
			load_xsl(load_xml_and_combine);
			set_bumper();
		}
		function set_parent_element(elm){
			if(elm){
				parent_element = elm;
				return(parent_element);
			}else{
				return(false);
			}
		}
		function set_default_xml_url(url){
			if(url.length > 0){
				default_xml_url = url;
				return(default_xml_url);
			}else{
				return(false);
			}
		}
		function set_default_xsl_url(url){
			if(url.length > 0){
				default_xsl_url = url;
				return(default_xsl_url);
			}else{
				return(false);
			}
		}
		function set_timer(time){
			if(time > 0){
				timer = time;
			}
		}
		function set_update_message(message){
			if(message.length > 0){
				update_message = message;
				return(update_message);
			}else{
				return(false);
			}
		}
		
		function load_xsl(result_method){
			try{
				if(xsl_doc && (default_xsl_url.length > 0)){
					xsl_doc.load_xml(default_xsl_url,result_method);
				}else{
					return(false);
				}
			}catch(e){
				parent_element.innerHTML = '<div style="padding:5px; background-color:#d5d5d5; border:1px solid #fff;" align="center">Could not locate xsl</div>';
			}
		}
		function load_xml(result_method){
			try{
				if(xml_doc && (default_xml_url.length > 0)){
					xml_doc.load_xml(default_xml_url,result_method);
				}else{
					return(false);
				}
			}catch(e){
				parent_element.innerHTML = '<div style="padding:5px; background-color:#d5d5d5; border:1px solid #fff;" align="center">Could not locate xml</div>';
			}
		}
		function load_xml_and_combine(){
			set_bumper();
			load_xml(create_html);
		}
		function create_html(){
			var html = trans.do_transform(xml_doc.doc,xsl_doc.doc,false,'alerts');	
			parent_element.innerHTML = html;
			clearInterval(interval);
			if(timer > 0){
				interval = setInterval(load_xml_and_combine,timer);
			}
		}
		
		this.initialize = initialize;
		this.set_parent_element = set_parent_element;
		this.set_default_xml_url = set_default_xml_url;
		this.set_default_xsl_url = set_default_xsl_url;
		this.set_timer = set_timer;
		this.set_update_message = set_update_message;
	} 