var d = document;
var winIE = (navigator.userAgent.indexOf('Opera')==-1 && (d.getElementById && d.documentElement.behaviorUrns)) ? true : false;

function bodySize(){
	if(winIE && d.documentElement.clientWidth) {
		sObj = d.getElementsByTagName('body')[0].style;
		sObj.width = (d.documentElement.clientWidth<990) ? '990px' : '100%';
	}
}

function init(){
	if (winIE) { bodySize(); }
}

onload = init;
if (winIE) { onresize = bodySize; }

/** Убирает дефолтовый текст при получении элементом фокуса **/
function replace_on( el, txt ) {
	if ( el.value == txt ) el.value = '';
}

/** Подставляет дефолтовый текст при потере элементом фокуса **/
function replace_out( el, txt ) {
	if ( el.value == '' ) el.value = txt;
}

/** Открывает всплывающее окно заданных размеров URI **/
function openWnd(url, wname, w, h, scrb) {
	window.open(
		url,
		wname,
		'screenX=' + (screen.width/2 - Math.round(w/2)) + ',screenY=' + (screen.height/2 - Math.round(h/2)) + ',width=' + w + ',height=' + h + ',resizeble=no,status=no,toolbar=no,menubar=no,scrollbars=' + scrb
	);
	return false;
}

/** Создание куки **/
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 );
}

