function getbodySize() 
{
	  var size=[];
	  size['w'] = (document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth;
      size['h'] = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
      return size;
}
function getViewSize() {
    var size = [];

    if (typeof window.innerWidth != 'undefined') {
        size['w']  = window.innerWidth,
        size['h'] = window.innerHeight
    }
    else if (typeof document.documentElement != 'undefined'
        && typeof document.documentElement.clientWidth !=
        'undefined' && document.documentElement.clientWidth != 0) {
            size['w']  = document.documentElement.clientWidth,
            size['h'] = document.documentElement.clientHeight
    } else {
        size['w']  = document.getElementsByTagName('body')[0].clientWidth,
        size['h'] = document.getElementsByTagName('body')[0].clientHeight
    }

    return size;
}
function getImageSize( id) {
    var oHlpr = document.createElement( 'IMG');
    var oPic = document.getElementById( id);
    oHlpr.style.visibility = 'hidden';
    oHlpr.style.position = 'absolute';
    oHlpr.top = 0; oHlpr.left = 0;
    oHlpr.src = oPic.src;
    document.body.appendChild( oHlpr);
    var imSize = { 'w':oHlpr.offsetWidth,'h':oHlpr.offsetHeight }
    document.body.removeChild( oHlpr);
    return imSize;
}
function yScroll(){
    var y = (document.compatMode=='CSS1Compat'&&!window.opera)?document.documentElement.scrollTop:document.body.scrollTop;
    return y;
}
function close_popup(id){
    document.getElementById(id).style.display ='none';
    document.getElementById('background').style.display ='none';
}

function check_length(str, min, max){
 n=str.length; 
 if(n < min || n > max){
	 return false;
 }
 return true;
}
function ckeck_symbols(str,array1,array2){
	n=str.length; 
 	i=0;
	while (i<n){
	 k=true;
	 for(var key in array1){
		if(str[i] >= array1[key][0] && str[i] <= array1[key][1]){
			k=false;
			break;
		}
	 }
	 if(k)for(var key in array2){
		if(str[i] == array2[key]){
			k=false;
			break;
		}
	 }
	 if(k)return false;
	 i++;
	}
	 return true;
}
//---------------------------------------------
var id_mirco_categories='0';
function show_mirco_categories(id){
	hidden_mirco_categories(id);
	if(id){
	block_id='categor'+id;	
	id_mirco_categories = block_id;
	document.getElementById(block_id).style.display='block';
	}
	
}
function hidden_mirco_categories(id){
	if(('categor'+id) != id_mirco_categories && id_mirco_categories != '0'){
		document.getElementById(id_mirco_categories).style.display='none';
		id_mirco_categories='0';
	}
}
//----------------------------------------------
function upload_img_answer(address, file_name, type){
    document.getElementById(type).value = file_name;
	document.getElementById('upload_img').src=address;
	document.getElementById('upload_img').style.display='inline';
}
function upload_photos_answer(address, file_name, id){
	//alert(address+' | '+file_name+' | '+id); 
	
	form=document.getElementById('add_foto');  
	var Input = document.createElement('input');
    Input.type = 'hidden';
    Input.value = file_name;
    Input.name = 'file['+id+']';
    Input.id = 'file'+id;
    form.appendChild(Input);
	document.getElementById('upload_img'+id).src=address;    document.getElementById('upload_img'+id).style.display='inline';
	//<input type="hidden" name="file[1]" value="nhdtjhy5dyh5d45646" id="file1">
	id++;
	parent = form.parentNode;	
	HTML='<form action="/upload_img.php" method="post" target="photos_iframe" enctype="multipart/form-data" id="photos_form'+id+'" class="form addmaterials_2">';
	HTML=HTML+'<input type="hidden" name="type" value="photos">';
	HTML=HTML+'<input type="hidden" name="id" value="'+id+'">';
	HTML=HTML+'<div class="name"></div>';
	HTML=HTML+'<div class="input">';
	HTML=HTML+'<input type="file" name="file" class="text" onchange="document.getElementById(\'photos_form'+id+'\').submit();"><br>';
	HTML=HTML+'</div>';
	HTML=HTML+'<div class="content_center">';
	HTML=HTML+'<img src="" id="upload_img'+id+'" class="upload_img">';
	HTML=HTML+'</div>';
	HTML=HTML+'</form>';
	div = document.createElement('div');
	div.id = 'div_form'+id;
	div.innerHTML = HTML;
	parent.insertBefore(div,form); 
	//form1=document.getElementById('photos_form1');
	
		
	
}
/*function check_login(str){
	if (str == '') {alert ('Вы не ввели логин!'); return false;}
	if(!check_length(str,min, max)){
		alert('Логин должен иметь длину от 3 до 20 символов');
		return false;
	}
	n=str.length; 
 	i=0;
	while (i<n)
	{
	 if ((str[i] < '0' OR str[i] > '9') AND (str[i] < 'A' OR str[i] > 'z')) 
	 	{
		 alert 'Логин содержит недоступные символы!';
		 return false;
		}
	 i++;
	}
	return true;
}
function check_password(){
	if (str == '') {alert ('Вы не ввели логин!'); return false;}
	if(!check_length(str,min, max)){
		alert('Логин должен иметь длину от 3 до 20 символов');
		return false;
	}
}*/
function registration_submit() {
	//var log=document.getElementById('login').value.trimRight().trimLeft();
	//if(check_login(log)&&check_password()){
		document.getElementById('regist_form').submit();
	//}
	 	 
}

