function Viewport() { 
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		this.windowX = window.innerWidth;
		this.windowY = window.innerHeight;

	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		this.windowX = document.documentElement.clientWidth;
		this.windowY = document.documentElement.clientHeight;

	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		this.windowX = document.body.clientWidth;
		this.windowY = document.body.clientHeight;

	}

	//this.windowX = (document.documentElement && document.documentElement.clientWidth) || window.innerWidth || self.innerWidth || document.body.clientWidth; 
	//this.windowY = (document.documentElement && document.documentElement.clientHeight) || window.innerHeight || self.innerHeight || document.body.clientHeight; 

	this.scrollX = (document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft; 
	this.scrollY = (document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop; 
	this.pageX = (document.documentElement && document.documentElement.scrollWidth) ? document.documentElement.scrollWidth : (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth; 
	this.pageY = (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
}


function get_backgroundimage(el_id) {
	el = document.getElementById(el_id);

	if (document.defaultView != null) {
		var bg = document.defaultView.getComputedStyle(el,null).getPropertyValue('background-image');
	
	} else {
		var bg = el.currentStyle['backgroundImage'];

	}
	
	return bg;

}



function search_focus() {
	terms = document.getElementById('search_terms');
	
	if (terms.value=='Search') {
		terms.value = '';
	}

	//alert('search_focus');
}

function search_blur() {
	terms = document.getElementById('search_terms');
	
	if (terms.value=='') {
		terms.value = 'Search';
	}
	
	//alert('search_blur');
}

function search_submit() {
	terms = document.getElementById('search_terms');
	
	if (terms.value=='Search') {
		terms.value = '';
	}
	
}

/* Input element helpers for input's onFocus and onBlur i.e. onFocus="input_focus(this)"
 * generic clear and restore - checks default value and current value for input fields
 * jasonv 20090309*/
function input_focus(thefield) {
	if (thefield.defaultValue==thefield.value)
	thefield.value = "";
}
function input_blur(thefield) {
	if (thefield.value=='')
	thefield.value = thefield.defaultValue; 
}

function form_submit(thefield) {//action onSubmit on form tag
	//walk the children, if default==current then '' //ui: you left this blank
	for (i=0; i<(thefield.childNodes.length); i++) {
		var child = thefield.childNodes[i];
		if (child.tagName=="INPUT" && child.type=="text") {
			if(child.defaultValue==child.value) {
				child.value='';
			}
		}
	}
}

/*
//replace with jquery?
//subnav helper for a complex highlight/active position
function sub_nav_indicator(marker,adjust) {
	//target is the markers parent
	var t_el = marker.parentNode;
	if (t_el){
		var t_pos = t_el.offsetTop;
	}
	var adjust_top = adjust;

	var i_el = document.getElementById('sub_nav_indicator');
	//alert(t_el.className+": offsetTop: "+i_el.offsetTop);
	
	if (i_el && t_el) {
		i_el.style.top=t_pos+adjust_top+'px';
		i_el.style.position='absolute';
		i_el.style.display='inline';
	}
}
*/

function join_slide() {
	window_width = $(window).width();
	
	if (window_width < 1037) {
		slide_delay = 1000;
		
	} else {
		slide_delay = 0;
	
	}
		cmd = "join_slide_go()";
		join_timer = setTimeout(cmd, slide_delay);

}

function join_slide_go() {
	doc_width = $(document).width();

	if (doc_width > 1020) {
		right_width = $("#right_white").width();
		join_width = $("#top_join_now").width();

		current_pos = $("#top_join_now").css("left");
		current_pos = current_pos.substring(0, (current_pos.length - 2));

		left_pos = ((right_width + 1037) - join_width);

		if (left_pos > 1020) {
			left_pos = 1020;
		}

		move_x = left_pos - current_pos;

		move("top_join_now", move_x, 0, 500);

	}
}

var fps = 100;
function move(eleId, varX, varY, transTime) {
	if(eleId) {
		i = 0;
		oDiv = document.getElementById(eleId);

		// ASK 2009-04-21> change start vars to use jquery.
		//startX = oDiv.style.left.replace(/px/, "") * 1;
		startX = $("#"+eleId).css("left").replace(/px/, "") * 1;
		//startY = oDiv.style.top.replace(/px/, "") * 1;
		startY = $("#"+eleId).css("top").replace(/px/, "") * 1;

		steps = fps * (transTime / 1000);
		delay = transTime / steps;
		incX = varX / steps;
		incY = varY / steps;
	}
	if (i <= steps) {
		var posX = Math.ceil(startX + (i * incX));
		var posY = Math.ceil(startY + (i * incY));
		oDiv.style.left = posX + "px";
		oDiv.style.top = posY + "px";
		i++;
		setTimeout("move()", delay);
	} else {
		// alert('done');
		return;
	}
}
