if (self != top) top.location.replace(self.location); //FrameBuster

function testForEnter(e,btn) 
{
	if (document.getElementById && document.all) {
		key = e.keyCode
	}
	else {
		key = e.which
		//alert(key)
	}
	if (key == 13) {
		window.event.returnValue=false;
		window.event.cancel = true;
		btn.click();
	}
		//alert(event.keyCode);
		//alert(btn);
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function t_reportSize() {
  myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
//alert('size function1');
  } else {
	if( document.documentElement &&
		( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	  //IE 6+ in 'standards compliant mode'
	  myWidth = document.documentElement.clientWidth;
	  myHeight = document.documentElement.clientHeight;
//alert('size function2');
	} else {
	  if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
//alert('size function3');
	  } else {
		//alert('no match');
		//alert('cw='+document.documentElement.clientWidth);
		}
	}
  }
  return myWidth;
}

function checkWidth() { 
	var w = readCookie('t_cwidth');
//alert("width="+w);
	if (w==0)
	{
		w=400;
	}
	if (!w || w>320) {
		//ignore resize on mobile (size drops below 321)
		var newW = t_reportSize();
	//alert('new width='+newW);
		if (!w || w != newW) {
			if (w>(newW+20) || w<(newW-20)) { 
			//Ignore scrollbar addition/removal
			//set width and Redirect 
			createCookie('t_cwidth',newW,365);
			w = readCookie('t_cwidth');
			if (w && w>0) {
				//alert('Redirecting='+w);
				window.location=window.location;
				}
			}
		}
	}
}
