var ie=(document.all && document.all.item && !window.opera)?1:0;


function ShowMail(user, domain1, domain2) {
	var email = user+'&#64;'+domain1+'&#46;'+domain2;
	if (ShowMail.arguments[3]) name = ShowMail.arguments[3];
	else name = email;
	document.writeln('<a href="mailto:'+email+'">'+name+'</a>');
}

function check_browser() {
		var version = 0;
		if (navigator.userAgent.indexOf ("MSIE 5") != -1)
			version = "IE"; 
		else if (navigator.userAgent.indexOf("MSIE 4") != -1)
			version = "IE"; 
		else if (navigator.userAgent.indexOf ("MSIE 4.5") != -1)
			version = "IE"; 
		else if (navigator.userAgent.indexOf ("Opera") != -1)
			version = "Opera"; 
		else if (navigator.userAgent.indexOf ("Mozilla/5.0") != -1)
			version = "Mozilla"; 
		else if (navigator.userAgent.indexOf ("Mozilla/4.7") != -1)
			version = "Mozilla"; 

//		else version = "IE";
	return version;
}

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 MM_findObj(n, d) { 
  	var p,i,x;  
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];
  	for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) 
		x=d.getElementById(n); 
	return x;
}
function cartpopup(url)
{
	return window.open(url, "cart_window", "scrollbars=1, resizable=1, width=700, height=500").focus();
}

function resetframe(){
	window.document.all('cartframe').src='about:blank';
}

function hidediv(){
	window.parent.document.all('cartdiv').style.display='none';
}

function hidecart(){
	window.parent.document.all('cartframe').src='about:blank';
	window.parent.setTimeout("hidediv();",3000);
}

function buy(id){
  
  Elem = document.getElementById('cartdiv');
  if (Elem.style.display!='none') return;
  tbody=Elem.firstChild;
  tr=tbody.firstChild;
  td=tr.firstChild;
  td.innerHTML="<table cellpadding='0' cellspacing='0'><tr><td style='color:#FFFFFF;'>"+cart_text+"</td></tr></table>";

  Elem.style.top=document.body.scrollTop+window.event.clientY-165;
  Elem.style.left=document.body.scrollLeft+window.event.clientX;
  Elem.style.display='block';

/*
  window.document.all('cartdiv').style.top=document.body.scrollTop+window.event.clientY-165;
  window.document.all('cartdiv').style.left=document.body.scrollLeft+window.event.clientX;
  window.document.all('cartdiv').style.display='block';
 */ 
 count=document.getElementById('count'+id).value; 
 document.getElementById('count'+id).value=1;

//  window.document.all('cartframe').src='/?pre=cart&act=add&new_ids['+id+'][count]='+count+'&new_ids['+id+'][type]=0'; 
//	window.location = window.location + '?pre=cart&act=add&new_ids['+id+'][count]='+count+'&new_ids['+id+'][type]=0';
//	window.location = window.location + '?pre=cart&act=add&new_id['+id+']='+count;
   document.getElementById('cartframe').src='/?pre=cart&act=add&new_id['+id+']='+count; 
}
//------------------------------------------------------
function galleryPopup(id, lang) {
	window.open("/popup.php?num=0&id="+id+"&lang="+lang, "imagepopup", "scrollbars=0, resizable=1, width=400, height=300").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;
}

var hot = new Array();
var hotnum=0;

function add_to_list(name){
	hot[hotnum++]=name;
}

function move_price(){
 for(i=0; i<hotnum; i++) addPrice(hot[i]);
}


function addPrice(id){
var obj = document.images[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');
}
