function pop(obj, name, width, height) {
    if (!name) {
        name = 'pop';
    }
    if (!width) {
        width = 400;
    }
    if (!height) {
        height = 600;
    }
    popupWin = window.open(obj.href, name, 'width='+width+',height='+height);
    popupWin.focus();
}

function goto_country(){
	box = document.destinations.country;
	destination = box.options[box.selectedIndex].value;
	if (destination>'') {
		window.location.href=destination;
	}
}

var wImg = 0;
var hImg = 0;
function preview_image(img_src, txt, show_descr) {
//alert(img_src);

	if(!txt) txt = '';
	if(!show_descr) show_descr = 0;
	
    pic = new Image();
    pic.src = img_src;
    pic.alt = txt;
	pic.onload = function() {
//		view_image(pic.src, pic.width, pic.height);
		if(!txt) {
			wImg = pic.width+46;
			hImg = pic.height+36;
		}
		else {
			wImg = pic.width+46;
			hImg = pic.height+46;
		}
		if (wImg>screen.availWidth-150 || wImg==0) {
			wImg = screen.availWidth-150;
		}
	    if (hImg>screen.availHeight-150 || hImg==0) {
			hImg = screen.availHeight-150;
		}
	}
	
    setTimeout('view_image(pic.src, pic.width, pic.height, pic.alt, '+show_descr+');', 500);
}

function view_image(img_src, img_width, img_height, glTxt, show_descr){

	if(!show_descr) show_descr = 0;
	
	
	if(!glTxt)
		glTxt = '';
    if (img_width>screen.availWidth-150 || img_width==0) {
        win_width = screen.availWidth-150;
    } else {
		if(!glTxt) {
	        win_width = img_width+36;
		}
		else {
	        win_width = img_width+46;
		}
    }
    if (img_height>screen.availHeight-150 || img_height==0) {
        win_height = screen.availHeight-150;
    } else {
		if(!glTxt) {
	        win_height = img_height+36;
		}
		else {
	        win_height = img_height+46;
		}
    }
    win_top  = Math.abs((screen.availHeight - win_height)/3);
    win_left = Math.abs((screen.availWidth -win_width)/3);
    photoWindow = window.open('', '', "resizable=yes,top=" + win_top + ',left=' + win_left + ",width="+win_width+',height='+win_height+",status=0,menubar=0,toolbar=0,scrollbars=yes");
    photoWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>');
    photoWindow.document.write('<head><title>'+img_src+'</title><style type="text/css">.preview-image {padding: 0; margin: 0; background: #FFF} .pad {padding: 10px 0 0 10px}</style>');
    photoWindow.document.write('<scr'+'ipt type=text/javascript>');
    photoWindow.document.write('document.onkeypress = function CloseOnEsc(key) { if(document.all) { var keyCode = window.event.keyCode; } else { if (key.which == 0) {window.close();return;}   }  if (keyCode == 27) {window.close();return;} }');
    photoWindow.document.write('</scr'+'ipt>');
    photoWindow.document.write('</head><body class="preview-image"><div class="pad"><img src="'+img_src+'" ');
    if ( (img_width>1) && (img_height>1) ) {
        photoWindow.document.write('width="'+img_width+'" height="'+img_height+'"');
    }
    photoWindow.document.write(' border=0 onclick="javascript:window.close();">');
    photoWindow.document.write('</div>');
	if(glTxt!='') {
		photoWindow.document.write('<div style="padding: 10px 0px 0px 10px; text-align: center; color: #3C4959; font: 12px Arial, Tahoma, Geneva, Helvetica, sans-serif; float: left;"><div style="width: '+(img_width)+'px;" id="descr">'+glTxt+'</div></div></body></html>');
	}
	
	
	
	if(show_descr > 0){
		var obj_descr = document.getElementById("imgGallery_descr_"+show_descr);
	    var descr_img = obj_descr.innerHTML;
	    photoWindow.document.write('<div style="padding: 10px 0px 0px 10px; text-align: center; color: #3C4959; font: 12px Arial, Tahoma, Geneva, Helvetica, sans-serif; float: left;"><div style="width: '+(img_width)+'px;" id="img_descr">'+descr_img+'</div></div></body></html>');
	}
		
	/*
	title_id.innerHTML = galleryImg[id][now]['title']; 
	descr_id.innerHTML = galleryImg[id][now]['description'];
	*/
	
	
    photoWindow.document.close();
	photoWindow.onload = function() {
		photoWindow.innerWidth = wImg-10;
		photoWindow.innerHeight = hImg;
		var ie=document.all
		if(glTxt!='')
			photoWindow.document.getElementById('descr').style.width=wImg-((ie)?46:48);
		if(descr_img!='' && show_descr > 0)
			photoWindow.document.getElementById('img_descr').style.width=wImg-((ie)?46:48);
	}
}

function igallery_image(img_src, img_width, img_height, img_title){
    if (img_width>screen.availWidth-150 || img_width==0) {
        win_width = screen.availWidth-150;
    } else {
        win_width = img_width+20;
    }
    if (img_height>screen.availHeight-150 || img_height==0) {
        win_height = screen.availHeight-150;
    } else {
        win_height = img_height+20;
    }
    win_top  = Math.abs((screen.availHeight - win_height)/3);
    win_left = Math.abs((screen.availWidth -win_width)/3);
    photoWindow = window.open('', '', "resizable=yes,top=" + win_top + ',left=' + win_left + ",width="+win_width+',height='+win_height+",status=0,menubar=0,toolbar=0,scrollbars=yes");
    photoWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>');
    photoWindow.document.write('<head><title>'+img_title+'</title><style type="text/css"><!-- body {margin:0;padding:0} --></style>');
    photoWindow.document.write('<scr'+'ipt type=text/javascript>');
    photoWindow.document.write('document.onkeypress = function CloseOnEsc(key) { if(document.all) { var keyCode = window.event.keyCode; } else { if (key.which == 0) {window.close();return;}   }  if (keyCode == 27) {window.close();return;} }');
    photoWindow.document.write('</scr'+'ipt>');
    photoWindow.document.write('</head><body><img src="'+img_src+'" ');
    if ( (img_width>1) && (img_height>1) ) {
        photoWindow.document.write('width="'+img_width+'" height="'+img_height+'"');
    }
    photoWindow.document.write(' border=0 onclick="javascript:window.close();">');
    photoWindow.document.write('</body></html>');
    photoWindow.document.bgColor="#f0f0f0";
    photoWindow.document.close()
}

function show_obj(obj_id){
obj=document.getElementById(obj_id);
remove_class(obj, 'hide');
add_class(obj, 'show');
}

function hide_obj(obj_id){
obj=document.getElementById(obj_id);
remove_class(obj, 'show');
add_class(obj, 'hide');
}

function add_class(e,c) {
  e.className=e.className+" "+c;
}

function remove_class(e,c) {
  cn=e.className;
  p=cn.indexOf(c);
  if (p>-1){e.className=cn.substr(0,p)+cn.substr(p+c.length);  }
}

function SetCookie(cookieName, cookieValue, nHours) {
 var today = new Date();
 var expire = new Date();
 if (nHours==null || nHours==0) nHours=1;
 expire.setTime(today.getTime() + 3600000*nHours);
 document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}

function GetCookie(name){
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else  {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)  {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}


function DeleteCookie(name, path, domain) {
    if (getCookie(name))  {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


function submitPools(id, lang) {
	var frm = document.getElementById('form_polls'+id);
	var radios = document.getElementsByName("var_radio"+id);
	var check = false;
	if(radios) {
		for(i=0; i<radios.length; i++) if(radios[i].checked) check = true;
	}
	if(!check) {
		if(lang == "ru") {
			alert('Выберите Ваш ответ');
		}
		else {
			alert('Select you answer');
		}
	}
	else {
		frm.submit();
	}
}