var params='toolbar=0,menubar=0,scrollbars=1,resizable=1';

function gettime(){
url="/time";
var o = document.createElement("script");
o.setAttribute("type", "text/javascript");
o.setAttribute("src", url);
o.setAttribute("id", "dataLoader");
if (document.getElementById("dataLoader")){ document.body.removeChild(document.getElementById("dataLoader"));}
document.body.appendChild(o);
//alert(123);
}

var h=0;
var m=0;
var s=0;

var h1=0;
var m1=0;
var s1=0;

function runtime(){
return;
	h=document.getElementById('hour').innerHTML;h++;h--;
	m=document.getElementById('min').innerHTML;m++;m--;
	s=document.getElementById('sec').innerHTML;s++;

	if(s >59){
		s=0;
		m++;
	}
	if(m >59){
		s=0;
		m=0;
		h++;
	}

	if(h >23){
			h=0;
			s=0;
			m=0;
	}
	s='0'+s;
	m='0'+m;
	s=s.substr(s.length-2,2);
	m=m.substr(m.length-2,2);
	document.getElementById('hour').innerHTML=h;
	document.getElementById('min').innerHTML=m;
	document.getElementById('sec').innerHTML=s;
	setTimeout(function(){runtime()},1000);

}

function runtime1(){
return ;
	h1=document.getElementById('hour1').innerHTML;h1++;h1--;
	m1=document.getElementById('min1').innerHTML;m1++;m1--;
	s1=document.getElementById('sec1').innerHTML;s1++;
	if(s1 >59){
		s1=0;
		m1++;
	}
	if(m1 >59){
		s1=0;
		m1=0;
		h1++;
	}

	if(h1 >23){
			h1=0;
			s1=0;
			m1=0;
	}
	s1='0'+s1;
	m1='0'+m1;
	s1=s1.substr(s1.length-2,2);
	m1=m1.substr(m1.length-2,2);
	document.getElementById('hour1').innerHTML=h1;
	document.getElementById('min1').innerHTML=m1;
	document.getElementById('sec1').innerHTML=s1;
	setTimeout(function(){runtime1()},1000);
}

var countries="";

var getparam="";




function gettocountries(id,url){

	id++;
	id--;
getparam="";
var path=url+"/tocountries/list/"+id;
getload(path);
document.getElementById('tocountriestmp').style.display='none';
setTimeout("document.getElementById('tocountries').innerHTML=\"<select id='tofield'>\"+getparam+\"</select>\"",300);

}


function convert(url){
var from=document.getElementById("fromfield").value;
var to=document.getElementById("tofield").value;
var count=document.getElementById("count").value;
var path=url+"/tocountries/convert/"+from+"/"+to+"/"+count;
getparam="";
getload(path);
setTimeout("document.getElementById('rat').innerHTML=getparam[3] +\" <b>\"+getparam[1]+\"</b> = \"+getparam[0]+\" <b>\"+getparam[2]+\"</b>\"",100);
}




function getload(path){
var now = new Date();
path+="&t="+now.getTime();
//alert(path);
var o = document.createElement("script");
o.setAttribute("type", "text/javascript");
o.setAttribute("src", path);
o.setAttribute("id", "dataLoader");
if (document.getElementById("dataLoader")){ document.body.removeChild(document.getElementById("dataLoader"));}
document.body.appendChild(o);
}

function selday(day,mounth,year,pole){

if (day<10){day='0'+day;}
if (mounth<10){mounth='0'+mounth;}

document.getElementById(pole).value=year+'-'+mounth+'-'+day;
getload('/calendar/'+day+'/'+mounth+'/'+year);
//document.getElementById('calendar').style.display='none';
}

function getLoad(path){
	getload(path);

}

function newwindow(path){
x=screen.width;
y=screen.Height;
w=700;
h=520;
var left=(x-w)/2;
var top=(y-h)/2;

win = window.open(path,"",'left='+left+', top='+top+', width='+w+', height='+h+', resizable=1');
}

function setCookie(name, value) {
      var valueEscaped = escape(value);
      var expiresDate = new Date();
      expiresDate.setTime(expiresDate.getTime() + 365 * 24 * 60 * 60 * 1000); // срок - 1 год, но его можно изменить
      var expires = expiresDate.toGMTString();
      var newCookie = name + "=" + valueEscaped + "; path=/; expires=" + expires;
      if (valueEscaped.length <= 4000) document.cookie = newCookie + ";";
}

// Получить куки
function getCookie(name) {
      var prefix = name + "=";
      var cookieStartIndex = document.cookie.indexOf(prefix);
      if (cookieStartIndex == -1) return null;
      var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
      if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;
      return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}


