function getCurrentData() {
	var theDate = new Date();
	document.editblock.month.value = theDate.getMonth() + 1;
	document.editblock.year.value = theDate.getYear();
	document.editblock.date.value = theDate.getDate();
}
function AddToFavorite() {
    if ( document.all ) window.external.AddFavorite( window.top.location.href, 'Foris Telecom Ltd' );
    else alert("Press 'Ctrl + D'." );
}
function checkFile() {
	if(document.category.title.value=="" || document.category.link.value=="") {
		alert("An file name and menu item is required!");
		return false;
	}
	var rex = /^([0-9a-z]([-_]?[0-9a-z]))/;
	if (document.category.link.value.match(rex) == null) {
		alert("An file name is not valid Only letters (a-z) or numbers (0-9) is required");
		return false;
	}
}
var cssFix = function(){
  var u = navigator.userAgent.toLowerCase(),
  is = function(t){return (u.indexOf(t)!=-1)};
  $("html").addClass([
    (!(/opera|webtv/i.test(u))&&/msie (\d)/.test(u))?('ie ie'+RegExp.$1)
      :is('firefox/2')?'gecko ff2'
      :is('firefox/3')?'gecko ff3'
      :is('gecko/')?'gecko'
      :is('opera/9')?'opera opera9':/opera (\d)/.test(u)?'opera opera'+RegExp.$1
      :is('konqueror')?'konqueror'
      :is('applewebkit/')?'webkit safari'
      :is('mozilla/')?'gecko':'',
    (is('x11')||is('linux'))?' linux'
      :is('mac')?' mac'
      :is('win')?' win':''
  ].join(''));
}();

function showDiv(name) {
	$("#div"+name).css("display", "block");
	$("#p"+name).css("display", "none");
	createCookie(name,'show',1);
}
function hideDiv(name) {
	$("#div"+name).css("display", "none");
	$("#p"+name).css("display", "block");
	eraseCookie(name);
}
function getDivOld(name){
	var parent = document.getElementById(name);
	var div = document.getElementById('sub'+name);
	if(div.style.display == 'none') {
		parent.className = name+'On';
		div.style.display = 'block';
	} else {
	div.style.display = 'none';
	parent.className = name;
	}
}
function getDiv(name){
	var div = document.getElementById(name);
	if(div.style.display == 'none') {
		div.style.display = 'block';
		$("#footer").css("position", "relative");
		$("#mainContainer").height("auto");
		$("#footer").css("top", "" );
	} else {
	div.style.display = 'none';
	setFooter();
	}
}
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}

function setFooter(column) {
	var pxNum = (column == '#leftCol' ) ? 110 : 42;
	if ( $(document).height() > $(column).height() ) {
		$("#mainContainer").height( ($(document).height() - 10) );
		$("#footer").css("position", "absolute");
		$("#footer").css("left", "0" );
		$("#footer").css("top", ($("#mainContainer").height() - 42) );
	} else {
		$("#mainContainer").height( ($(column).height() + pxNum) );
		$("#footer").css("position", "absolute");
		$("#footer").css("left", "0" );
		$("#footer").css("top", ($("#mainContainer").height() - 42) );
	}
}
function doSubscribe() {
var email = new String(document.subscribe.email.value);
email.toLowerCase();
var rex = /^([0-9a-z]([-_.]?[0-9a-z])+@[0-9a-z]([-.]?[0-9a-z])+\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)$/i;
if (email.length == 0)
{
	alert(textEmail[1]);
	document.feedback.email.select();
	return false;
} else if (email.match(rex) == null) {
	alert(textEmail[2]);
	document.feedback.email.select();
	return false;
}

	$.post('subscribe-ajax.php', { subscribe:$("input[@name='subscribe']:checked").val(), email:$("#email").val() }, function(result) {
		$("#result").html(result);
		$("#email").val('');
	} );
}
function showSubMenu() {
	$("#subParent").click( function() {
		if ( $(".subMenu").css("display") == 'none' ) {
			$(".subMenu").css("display", "block");
			$(this).addClass("hovered");
			setFooter("#leftCol");
		} else {
			$(this).removeClass("hovered");
			$(".subMenu").css("display", "none");
			setFooter("#leftCol");
		}
	});
}
$(document).ready( function() {
	/*setFooter("#rightCol");
	if ( weather == 1) $.post("ajaxweather.php", {city:01}, finish);
	showSubMenu();*/
})
//////////////// weather ////////////////
function getWeather(name) {
	$("#weather").html('<img src="/images/waiting.gif" width="47" height="47" style="margin:20px 0 0 0"/>');
	$.post("ajaxweather.php", {city:name}, finish);
}
function finish(result) {
	$("#weather").html(result);
}
//////////////// end weather ////////////////


function getMonAjax(m, y){
	$.get(cssRoot+"/calendar-ajax.php", {m:m, y:y }, function(result){ $("#calendarBlock").html(result) } );
	return false;
}
function getMonAjaxCalendar(m, y){
	$.get(cssRoot+"/calendar-ajax.php", {m:m, y:y, cal:1 }, function(result){ $("#calendarCalendarBlock").html(result) } );
	return false;
}
