var timerID = null;
var timerRunning = false;

function stopclock (){
        if(timerRunning)
                clearTimeout(timerID);
        timerRunning = false;
}
function showtime () {
        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
		var date = now.getDate();
		var year = now.getFullYear();
		var month = now.getMonth() + 1;
        //var seconds = now.getSeconds()
		mydate = new Date();
		myday = mydate.getDay(); 
		if(myday == 0) var day = " воскресенье ";
		else if(myday == 1)day = " понедельник " ;
		else if(myday == 2)day = " вторник " ;
		else if(myday == 3)day = " среда " ;
		else if(myday == 4)day = " четверг " ;
		else if(myday == 5)day = " пятница " ;
		else if(myday == 6)day = " суббота " ;
		if(month == 1)mymonth = " января " ;
		else if(month == 2)mymonth = " февраля " ;
		else if(month == 3)mymonth = " марта " ;
		else if(month == 4)var mymonth = " апреля " ;
		else if(month == 5)mymonth = " мая " ;
		else if(month == 6)mymonth = " июня " ;
		else if(month == 7)mymonth = " июля " ;
		else if(month == 8)mymonth = " августа " ;
		else if(month == 9)mymonth = " сентября " ;
		else if(month == 10)mymonth = " октября " ;
		else if(month == 11)mymonth = " ноября " ;
		else if(month == 12)mymonth = " декабря " ;
		var timeValue = ((hours <10) ? "0" : "")+((hours >24) ? hours -24 :hours)+((minutes < 10) ? ":0" : ":") + minutes + "";
		var dayValue = timeValue+day+date+mymonth;
        
		//document.getElementById('face').innerHTML=timeValue;
		//alert(1);
		document.getElementById('faceDate').innerHTML=dayValue;
        timerID = setTimeout("showtime()",0);
        timerRunning = true;
}

function showtimeEn () {
        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
		var date = now.getDate();
		var year = now.getFullYear();
		var month = now.getMonth() + 1;
        //var seconds = now.getSeconds()
		mydate = new Date();
		myday = mydate.getDay(); 
		if(myday == 0) var day = " Sunday ";
		else if(myday == 1)day = " Monday " ;
		else if(myday == 2)day = " Tuesday " ;
		else if(myday == 3)day = " Wednesday " ;
		else if(myday == 4)day = " Thursday " ;
		else if(myday == 5)day = " Friday " ;
		else if(myday == 6)day = " Saturday " ;
		if(month == 1)mymonth = " January " ;
		else if(month == 2)mymonth = " February " ;
		else if(month == 3)mymonth = " March " ;
		else if(month == 4)var mymonth = " April " ;
		else if(month == 5)mymonth = " May " ;
		else if(month == 6)mymonth = " June " ;
		else if(month == 7)mymonth = " July " ;
		else if(month == 8)mymonth = " August " ;
		else if(month == 9)mymonth = " September " ;
		else if(month == 10)mymonth = " October " ;
		else if(month == 11)mymonth = " November " ;
		else if(month == 12)mymonth = " December " ;
		var timeValue = ((hours <10) ? "0" : "")+((hours >24) ? hours -24 :hours)+((minutes < 10) ? ":0" : ":") + minutes + "";
		var dayValue = timeValue + day+" "+date+" "+mymonth+" ";
        
		//document.getElementById('face').innerHTML=timeValue;
		document.getElementById('faceDate').innerHTML=dayValue;
        timerID = setTimeout("showtimeEn()",0);
        timerRunning = true;
}
function showtimeBel () {
        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
		var date = now.getDate();
		var year = now.getFullYear();
		var month = now.getMonth() + 1;
        //var seconds = now.getSeconds()
		mydate = new Date();
		myday = mydate.getDay(); 
		if(myday == 0) var day = " Няделя ";
		else if(myday == 1)day = " Паняделак ";
		else if(myday == 2)day = " Ауторак " ;
		else if(myday == 3)day = " Серада " ;
		else if(myday == 4)day = " Чацверг " ;
		else if(myday == 5)day = " Пятнiца " ;
		else if(myday == 6)day = " Субота " ;
		if(month == 1)mymonth = " Студзеня " ;
		else if(month == 2)mymonth = " Лютага " ;
		else if(month == 3)mymonth = " Сакавiка " ;
		else if(month == 4)var mymonth = " Красавiка " ;
		else if(month == 5)mymonth = " Мая " ;
		else if(month == 6)mymonth = " Чэрвеня " ;
		else if(month == 7)mymonth = " Лiпня " ;
		else if(month == 8)mymonth = " Жнiуня " ;
		else if(month == 9)mymonth = " Верасеня " ;
		else if(month == 10)mymonth = " Кастрычнiка " ;
		else if(month == 11)mymonth = " Лiстапада " ;
		else if(month == 12)mymonth = " Снежаня " ;
		var timeValue = ((hours <10) ? "0" : "")+((hours >24) ? hours -24 :hours)+((minutes < 10) ? ":0" : ":") + minutes + "";
		var dayValue = timeValue + day+" "+date+" "+mymonth+" ";
        
		//document.getElementById('face').innerHTML=timeValue;
		document.getElementById('faceDate').innerHTML=dayValue;
        timerID = setTimeout("showtimeBel()",0);
        timerRunning = true;
}

function startclockEn () {
        stopclock();
        showtimeEn();
}
function startclockBel () {
        stopclock();
        showtimeBel();
}
function startclockIndex () {
        stopclock();
        showtime();
}

$(document).ready(function() {
	//$('#photoRes').click(function() {	
	var photoResW = jQuery('#photoRes').width();
	var photoResH = jQuery('#photoRes').height();
	var kof = 0;
	//alert(photoResW/photoResH);
	if (photoResW < photoResH){
		kof = photoResH/photoResW;
		if (kof < 1) $('#photoRes').css('width', '125px');
		else if (kof > 1 && kof < 1.5) $('#photoRes').css('height', '125px');
		else $('#photoRes').css('height', '125px');
		//alert(kof);
	}
	if (photoResH < photoResW){
		var kof = photoResW/photoResH;
		if (kof < 1.5) $('#photoRes').css('height', '125px');
		else if (kof > 1.7) $('#photoRes').css('width', '220px');
		else $('#photoRes').css('width', '125px');
		//alert("K:"+kof);
	}
	//});
});
function Resize() {
	//$('#photoRes').click(function() {	
	var photoResW = jQuery('#photoRes').width();
	var photoResH = jQuery('#photoRes').height();
	var kof = 0;
	//alert(photoResW/photoResH);
	if (photoResW < photoResH){
		kof = photoResH/photoResW;
		if (kof < 1) $('#photoRes').css('width', '125px');
		else if (kof > 1 && kof < 1.5) $('#photoRes').css('height', '125px');
		else $('#photoRes').css('height', '125px');
		//alert(kof);
	}
	if (photoResH < photoResW){
		var kof = photoResW/photoResH;
		if (kof < 1.5) $('#photoRes').css('height', '125px');
		else if (kof > 1.7) $('#photoRes').css('width', '220px');
		else $('#photoRes').css('width', '125px');
		//alert("K:"+kof);
	}
	//});
}
function ResizeNew() {
	//$('#photoRes').click(function() {	
	var photoResW = jQuery('.img_cat img').width();
	var photoResH = jQuery('.img_cat img').height();
	var kof = 0;
	//alert(photoResW/photoResH);
	if (photoResW < photoResH){
		kof = photoResH/photoResW;
		if (kof < 1) $('.img_cat img').css('width', '98px');
		else if (kof > 1 && kof < 1.5) $('.img_cat img').css('height', '98px');
		else $('.img_cat img').css('height', '98px');
		alert("W < H: "+kof);
	}
	if (photoResH < photoResW){
		var kof = photoResW/photoResH;
		if (kof < 1.5) $('.img_cat img').css('height', '98px');
		else if (kof > 1.7) $('.img_cat img').css('width', '170px');
		else $('.img_cat img').css('width', '98px');
		alert("W > H: "+kof);
	}
	//});
}
