var ie=(document.all && document.all.item && !window.opera)?1:0;
var layer = 0, tm_id = 0;

function ShowHide(n, vs) {
	var lr, img;
	if ((lr=FindObj('float'+n))==null || (img=FindObj('img'+n))==null) return;
	if (ie) {
		if (!lr.style.left) lr.style.left = img.offsetLeft + 1;
		if (!lr.style.top) lr.style.top = img.offsetParent.offsetTop + 36 + document.body.scrollTop;
		vs = (vs=='show')?'visible':(vs='hide')?'hidden':vs;
		if (layer!=n && lr.filters && msieversion()>=5.5) {
			lr.filters.item(0).Apply();
			lr.style.visibility = vs;
			lr.filters.item(0).Play();
		}
		lr.style.visibility = vs;
	} else {
		lr.visibility = vs;
		lr.left = img.x;
		lr.top = img.y;
	}
	layer = n;
}

function FindObj(id) {
	var obj, d=document;
	if (!(obj=d[id])&&d.all) obj=d.all[id];
	if (!obj && d.getElementById) obj=d.getElementById(id);
	return obj;
}

function msieversion() {
	var ua = window.navigator.userAgent;
	var msie = ua.indexOf("MSIE ");
	if (msie>0) return parseFloat(ua.substring(msie+5,ua.indexOf(";", msie + 5)));
	else return 0;
}

function SetHiddenVar(variable,val) {
	var forma = document.forms['Filter'];
	forma.elements[variable].value = val;
	forma.submit();
	return false;
}

function openImage(image) {
	window.open("/popup.php?img="+image, "popupimage", "scrollbars=0, resizable=1, width=520, height=450").focus();
}

function cartPopup(id,lang) {
	window.open("/cartpopup.php?id="+id+"&lang="+lang, "cartpopup", "scrollbars=0, resizable=1, width=350, height=100").focus();
}

function galleryPopup(id, lang) {
	window.open("/popup.php?num=0&id="+id+"&lang="+lang, "imagepopup", "scrollbars=0, resizable=1, width=400, height=300, top="+(screen.height/2-225)+", left="+(screen.width/2-260)).focus();
}

function ChangeSelRF(val) {
	if (ie) document.all["SelectRF"].innerHTML = document.all["SelRF"+val].innerHTML;
}

function enableAreas() {
document.forms.Forma.elements['fld[transfer][flight_number]'].disabled=!document.forms.Forma.elements['fld[transfer][status]'].checked;
document.forms.Forma.elements['fld[transfer][arr_time]'].disabled=!document.forms.Forma.elements['fld[transfer][status]'].checked;
}


function change_img(name, source) {
//	document.images[name].src = 'files/'+source;
	document.getElementById(name).src = 'files/'+source;
}

var hot = new Array();
var hotnum=0;

function add_to_list(name){
	hot[hotnum++]=name;
//	alert(name);
}

function move_price(){
 for(i=0; i<hotnum; i++) /*if (hot[i] != '')*/ addPrice(hot[i]);
}


function addPrice(id) {
//	var obj = document.images[id+'_id'];
	var obj = document.getElementById(id+'_id');
	var x_offset=obj.offsetLeft+obj.width-15; 
	var y_offset=obj.offsetTop+obj.height-15;

	while(1) {
		 obj = obj.offsetParent;
		 if(obj.offsetLeft) x_offset = x_offset+obj.offsetLeft;
		 if(obj.offsetTop) y_offset = y_offset+obj.offsetTop;
		 if(obj.offsetParent==null) break;
	}

	var targ = FindObj(id+'_lay');
	
	if(targ) {
		targ.style.left = x_offset;
		targ.style.top = y_offset;
		targ.style.visibility = 'visible';
	}

	//alert(targ.position+' y:'+targ.top+' x:'+targ.left);
}
function rusoft() {
  window.open('http://www.rusoft.ru');
}
