// JavaScript Document
function onResize(){
	var ss = getWindowSize();
	/*
	top: 50%;
	margin-top: -239px;
	*//*
	margin-top: 112px;
	top: 0px;
	*/
	var obj = document.getElementById('cent');
	if(ss[1] > 600){
		obj.style.margin = '-239px 0px 0px -485px';
		obj.style.top = '50%';
	}else{
		obj.style.margin = '0px 0px 0px -485px';
		obj.style.top = '112px';
	}
}
function getWindowSize() {
    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 [myWidth, myHeight];
}
var popUpWin=0;
function openWindow(root, subp){
	if(popUpWin)
		if(!popUpWin.closed)
			popUpWin.close();
	popUpWin = open('http://cni-moscow.ru/print/'+subp, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=600,height=600,left=100, top=100,screenX=100,screenY=100');
}
function changeImg(img, path){
		if(img){
				img.src = path;
		}
}
function printPage(){
	window.print();
	window.close();
}
function form_send(){
	if(!document.getElementById('c_name').value){
		alert('Вы не ввели ваше имя');
		return;
	}
	if(!document.getElementById('c_contact').value){
		alert('Вы не ввели вашу контактную информацию');
		return;
	}
	if(!document.getElementById('c_text').value){
		alert('Вы не ввели сообщение');
		return;
	}
	document.getElementById('sendd').submit();
}
function register(){
	var email = document.getElementById('email_tf').value;
	if(email && email != st){
		var str = 'resizable=no,width=400,height=230,screenX=200,screenY=200,left=100,top=100';
		var o = window.open('register.php?email='+email, '_blank', str);
	}else{
		alert('Вы не ввели Ваш e-mail');
	}
}
function clearField(obj){
	obj.value='';
}
function loaded(data){
	document.getElementById('body_text_cont').innerHTML = data;
	upup();
}
function upup(){
	document.getElementById('body_text').scrollUpdate();
//	alert(document.getElementById('body_text').height);
//	scroll_d_b
}
function loader(){
	document.getElementById('body_text_cont').innerHTML = 'Загрузка...';
	upup();
}
anchors = {};
function changePage_(a, b){
	if(a && b){
		if(!anchors[a+'_'+b]){
			anchors[a+'_'+b] = true;
			document.getElementById('anchors').innerHTML += '<a name="'+a+'_'+b+'"></a>';
		}

		if (navigator.userAgent.indexOf ("MSIE 6.0") == -1)
			window.location.hash=a+'_'+b;

		lookup('data/'+a+'_'+b+'.txt');
		document.getElementById('middle').style.backgroundImage = 'url(img/'+a+'.jpg)';
		document.getElementById('second_kar').style.display = 'block';
		document.getElementById('main').style.display = 'none';
	
		var toflash;
		switch(a){
			case 'company':
				toflash = '0';
			break;
			case 'news':
				toflash = '1';
			break;
			case 'salon':
				toflash = '2';
			break;
			case 'education':
				toflash = '3';
			break;
			case 'products':
				toflash = '4';
			break;
			case 'furniture':
				toflash = '5';
			break;
			case 'partners':
				toflash = '6';
			break;
			case 'contacts':
				toflash = '7';
			break;
		}
		thisMovie("menu").setItem('_root.item_'+toflash, 1);
	}
}
function thisMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}
function init(){
	st = 'Your e-mail';

	CSBfleXcroll('body_text');

	upup();

	onResize();
}
function checkHash(){
	if(now != window.location.hash){
		now = window.location.hash;
		alert(now);
		var h = now.split('_');
		h = [h.shift().substr(1), h.shift()];
		changePage(h[0], h[1]);
	}
}
