var Switch = Class.create({
	
	elements: {},
	
	addSwitch: function(id, from, to)
	{
		if (!$(id)) return false;
		this.elements[id] = {
			from: from,
			to: to
		};
		
		Event.observe($(id), 'focus', function(){
			this.to(id);
		}.bind(this));
		
		Event.observe($(id), 'blur', function(){
			this.from(id);
		}.bind(this));
		
	},
	
	to: function(id)
	{
		var el = $(id);
		var to = this.elements[id].to;
		var from = this.elements[id].from;
		var c = el.value;
		if (c == from) $(id).value = to;
	},
	
	from: function(id)
	{
		var el = $(id);
		var to = this.elements[id].to;
		var from = this.elements[id].from;
		var c = el.value;
		if (c == to) $(id).value = from;
	}
	
});

function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
return {
width: myWidth,
height: myHeight
};
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
}

function hideWindow ()
{
	var s = windowSize();
	document.write('<div id="whiteSheet" style="z-index: 9999; width: '+s.width+'px; height: '+s.height+'px; position: absolute; left: 0px; top: 0px; background: white;"></div>');
}

hideWindow();

function showWindow ()
{
	$('whiteSheet').remove();
}

var replacer;

Event.observe(window, 'load', function(){

if ($('tableContent') && 'fake' == 'right') {

var textAreas = new Array();
var textAreasCount = 0;

var divs = document.getElementsByTagName('div');

var h1s = document.getElementsByTagName('h1');
var h1 = $(h1s[0]);

for (var i = 0; i < divs.length; i++) {
	var div = $(divs[i]);

	if ( div.id == 'TextArea' || div.id == 'TextArea_small' || div.id == 'TextAreaMore' ) {
		textAreasCount++;
		textAreas[textAreas.length] = div;
	}
}
	
	if ( ($('TextArea') || $('TextArea_small') || $('TextAreaMore')) && textAreasCount == 1) {
		
		var div = $(textAreas[0]);
		$('tableContentText').insert(div);

	} else if (textAreasCount > 1) {
		for (var i = 0; i < textAreas.length; i++) {
			$('tableContentText').insert($(textAreas[i]));
			//$(textAreas[i]).setStyle({'display':'block'});
		}
	}
	
	if ($('RightProductPic') || $('RightPic_320')) {
		var t = ( $('RightProductPic') || $('RightPic_320') ).innerHTML;
		$('tableContentImage').update(t);
		( $('RightProductPic') || $('RightPic_320') ).remove();
	}
	if (h1) h1.insert({'after':$('tableContent')});
}
	showWindow();
	replacer = new Switch();
	replacer.addSwitch('newsletter', 'Sing up for electronic newsletter', '');
	replacer.addSwitch('searchField', 'Search:', '');
	
});
