$(document).ready(function(){	var a = new Date().getTime();	$("#exchange_main_div div div div div").load("/ajax/exchange.php?a="+a);
});
window.onresize = function(){	var myWidth = $(window).width();
	var myHeight = $(window).height();
	var popupHeight = $("#calc").height();
	var popupWidth = $("#calc").width();
	$("#back").css({
		"height": myHeight+"px",
		"width": myWidth+"px"
	});
	if(navigator.appName=="Microsoft Internet Explorer" && parseFloat(navigator.appVersion)<7){
		$('#calc').css({'left':myWidth/2-popupWidth/2});
	}
	else{
		$('#calc').css({
			'top': myHeight/2-popupHeight/2,
			'left': myWidth/2-popupWidth/2
		});
	}
}
function hide_exchange(){	setTimeout("hide==1?$('#exchange_main_div,.iframe').animate({opacity:'hide'},1500):'';",10000);}
function show_exchange_places(){	var vis = $("#obmenniki").css("display");
	if(vis=="none" && exchange==1){		$("#obmenniki, .iframe").animate({height:"show"},200);
	}
	else if(vis!='none' && exchange==0){		$("#obmenniki, .iframe").animate({height:"hide"},200);
	}}

function hide_exchange_places(){	if(exchange==0){setTimeout("show_exchange_places()",1000);}}

function set_exchange(num){	exchange = num;}
var data = new Array();
var exchange = 0,hide=1;
function show_calc(){	data[0] =new Array(0,'KZT',1,1);
	var i=1,j=1;

	var myWidth = $(window).width();
	var myHeight = $(window).height();
	var popupHeight = $("#calc").height();
	var popupWidth = $("#calc").width();

	$("#back").css({		"opacity": "0.4",
		"filter":"alpha(opacity=40)",
		"height": myHeight+"px",
		"width": myWidth+"px"
	});
	$('#back,#calc').fadeIn(400);
	if(navigator.appName=="Microsoft Internet Explorer" && parseFloat(navigator.appVersion)<7){		$('#calc').css({'left':myWidth/2-popupWidth/2});	}
	else{		$('#calc').css({
			'top': myHeight/2-popupHeight/2,
			'left': myWidth/2-popupWidth/2
		});
	}
 	$('#back').click(function(){
		$("#back,#calc").fadeOut(400);
	});
	$("#exchange_main_div table:eq(0) tr:gt(1)").each(function(){		j=1;
		data[i] = new Array();
		data[i][0] = i;		$("td",this).each(function(){			data[i][j] = $(this).html();
			j++;		});		i++;
	});
}

function calc(){
	var i1=document.getElementById("cur1").value*1;
	var i2=document.getElementById("cur2").value*1;
	var amount=document.getElementById("amount").value*1;
	var amount2=document.getElementById("amount2");
	if(i1==0&&i2!=0) curIdx=1/data[i2][2];
	if(i1!=0&&i2==0) curIdx=data[i1][2];
	if(i1!=0&&i2!=0&&i1!=0) curIdx=data[i1][2]/data[i2][3];
	if(i1==i2) curIdx=1;
	amount2.innerHTML=(amount*curIdx).toFixed(2);
}

function calc2(){	var i1=document.getElementById("cur3").value;
	var i2=document.getElementById("cur4").value;
	var amount=document.getElementById("amount1").value;
	var amount2=document.getElementById("amount3");
	if(i1==0&&i2!=0) curIdx=1/data[i2][3];
	if(i1!=0&&i2==0) curIdx=data[i1][3];
	if(i1!=0&&i2!=0&&i1!=i2) curIdx=data[i1][3]/data[i2][2];
	if(i1==i2) curIdx=1;
	amount2.innerHTML=(amount*curIdx).toFixed(2);
}



