
//popup functionality
window.onerror=null;
var win = null;
function stripBlanks(ctl) 
{
	var email = ctl.value;
	ctl.value = email.replace(new RegExp(' ','g'), '');

}
function PopWindow(mypage,myname) {
	//closePopWin();
	winprops = 'height=500,width=820,top=30,left=0,scrollbars=1,resizable=1,status=1';
	win = window.open(mypage, myname, winprops);
	}
function SizedPopWindow(mypage,myname,w,h) {
	//closePopWin();
	winprops = 'height='+h+',width='+w+',top=30,left=0,scrollbars=1,resizable=1,status=1';
	win = window.open(mypage, myname, winprops);
	}
function closePopWin() {
	if(win != null) { 
		if(!win.closed) { 
			win.close();
			win = null;
			} else {
			win = null;
			}
		}	
	}

	
if (document.images){
	homeon = new Image
	homeoff = new Image
	howon = new Image
	howoff = new Image
	whaton = new Image
	whatoff = new Image
	watchon = new Image
	watchoff = new Image
	sayon = new Image
	sayoff = new Image
	faqon = new Image
	faqoff = new Image
	viewon = new Image
	viewoff = new Image
	realon = new Image
	realoff = new Image
	
	touchon = new Image
	touchoff = new Image
	sprayon = new Image
	sprayoff = new Image
	cleanon = new Image
	cleanoff = new Image
	
	peopleon = new Image
	peopleoff = new Image
	homesubon = new Image
	homesuboff = new Image
	
	cleanjournalon = new Image
	cleanjournaloff = new Image
	
	asctout1on = new Image
	asctout1off = new Image
	asctout2on = new Image
	asctout2off = new Image
	asctout3on = new Image
	asctout3off = new Image
	
	homeon.src = "/i/2_ros_clean_nav_home_on.gif"
	homeoff.src = "/i/2_ros_clean_nav_home_off.gif"	
	howon.src = "/i/2_ros_clean_nav_how_on_.gif"
	howoff.src = "/i/2_ros_clean_nav_how_off.gif"
	whaton.src = "/i/2_ros_clean_nav_what_on_.gif"
	whatoff.src = "/i/2_ros_clean_nav_what_off.gif"
	watchon.src = "/i/2_ros_clean_nav_watch_on.gif"
	watchoff.src = "/i/2_ros_clean_nav_watch_off.gif"
	sayon.src = "/i/2_ros_clean_nav_whatpeople_on.gif"
	sayoff.src = "/i/2_ros_clean_nav_whatpeople_off.gif"
	faqon.src = "/i/2_ros_clean_nav_faq_on.gif"
	faqoff.src = "/i/2_ros_clean_nav_faq_off.gif"
	viewon.src = "/i/2_ros_clean_nav_demo_on.gif"
	viewoff.src = "/i/2_ros_clean_nav_demo_off.gif"
	realon.src = "/i/2_ros_clean_nav_real_on.gif"
	realoff.src = "/i/2_ros_clean_nav_real_off.gif"
	
	touchon.src = "/i/2_ros_clean_botnav_touch_on.gif"
	touchoff.src = "/i/2_ros_clean_botnav_touch_off.gif"
	sprayon.src = "/i/2_ros_clean_botnav_spray_on.gif"
	sprayoff.src = "/i/2_ros_clean_botnav_spray_off.gif"
	cleanon.src = "/i/2_ros_clean_botnav_clean_on.gif"
	cleanoff.src = "/i/2_ros_clean_botnav_clean_off.gif"
	
	peopleon.src ="/i/2_ros_clean_nav_people_on.gif"
	peopleoff.src="/i/2_ros_clean_nav_people_off.gif"
	homesubon.src="/i/2_ros_clean_nav_home_sub_on.gif";
	homesuboff.src="/i/2_ros_clean_nav_home_sub_off.gif";
	
	cleanjournalon.src="/i/scrubbing_bubbles_auto_shower_roll.jpg";
	cleanjournaloff.src="/i/scrubbing_bubbles_auto_shower_off.jpg";
	
	asctout1on.src="/i/tout/asc_tout_1_on.gif";
	asctout1off.src="i/tout/asc_tout_1_off.gif";
	asctout2on.src="/i/tout/asc_tout_2_on.gif";
	asctout2off.src="i/tout/asc_tout_2_off.gif";
	asctout3on.src="/i/asc_tout_3_on.jpg";
	asctout3off.src="i/asc_tout_3.jpg";
	
}
else {
	
	homeon.src = ""
	homeoff.src = ""
	howon.src = ""
	howoff.src = ""
	whaton.src = ""
	whatoff.src = ""
	watchon.src = ""
	watchoff.src = ""
	sayon.src = ""
	sayoff.src = ""
	faqon.src = ""
	faqoff.src = ""
	viewon.src = ""
	viewoff.src = ""
	realon.src = ""
	realoff.src = ""	
	
	touchon.src = ""
	touchoff.src = ""
	sprayon.src = ""
	sprayoff.src = ""
	cleanon.src = ""
	cleanoff.src = ""





}
if (document.layers || document.all || document.getElementById)
	var doc = 'document.', vis='.visibility';
if (document.all)
	var doc = 'document.all.', vis = '.style.visibility';
// below check enables NN 6.x compatibility
if (!document.all && document.getElementById)
	var doc = 'document.getElementById("', vis = '").style.visibility';
	
function writeObj(obj) {
trimString(obj);
document.write(obj);
}
function trimString (str) {
  var pattern = /\s+/g;
  return str.replace(pattern,'');
}


// the onload event, in most cases navInit should be added to whatever javascript initialization is already in place
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
//addLoadEvent(expandInit);

function expandInit() {
	changeOpac(0,'real');
	height('real');
	timey = window.setTimeout("reverse('real')",5000);
	$('realContainer').style.display = "block";
}


function isMouseLeaveOrEnter(e,handler)
{	
	var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
	while (reltg && reltg != handler) reltg = reltg.parentNode;
	return (reltg != handler);
}

function tao(e,handler,id) {
	if (!e) var e = window.event
	if(isMouseLeaveOrEnter(e,handler)) {
		if (isitdown == 'no')
		{
			height(id);
		}
		window.clearTimeout(timey);
	}
}

function zen(e,handler,id) {
	if (!e) var e = window.event
	if(isMouseLeaveOrEnter(e,handler)) {
		if (isitdown == 'yes')
		{
			reverse(id);
		}
	}
}

// handles the height plus opacity shift
function height(id) {

	isitdown = 'yes'

	var speed = 16;
    var timer = 0;
	heightStep = 69/100;
	changeHeight(0,id)

	for(var x=0; x<=100; x=x+5)
	{
		setTimeout("changeHeight(" + x + ",'" + id + "')",(timer * speed));
		setTimeout("changeOpac(" + x + ",'" + id + "')",(timer * speed));
		timer++;
	}
}

// handles the height plus opacity shift in reverse
function reverse(id) {
	
	isitdown = 'no'

	var speed = 16;
    var timer = 0;
	heightStep = 69/100;

	var i=100;
	do 
	{
	setTimeout("reverseHeight(" + i + ",'" + id + "')",(timer * speed));
	setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
	timer++;
	}
	while (i=i-5);
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
//	console.log(id);
	var object = $(id).style;
    object.opacity = (opacity / 101);
    object.MozOpacity = (opacity / 101);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}


function changeHeight(currentHeight, id) {
	var sync = heightStep*currentHeight;
    $(id).style.height = sync + "px";
}

function reverseHeight(currentHeight, id) {
	var sync = heightStep*currentHeight;
    $(id).style.height = sync + "px";
}

// a simple get elements by id function
function $() {
	if (arguments.length == 1) return get$(arguments[0]);
	var elements = [];
	$c(arguments).each(function(el){
		elements.push(get$(el));
	});
	return elements;
	function get$(el){
		if (typeof el == 'string') el = document.getElementById(el);
		return el;
	}
}