function hide_id(nodeId)
{
    var node = document.getElementById(nodeId);
    if (node)
    {
        node.className=node.className.replace('showed', '');
        node.className += ' hidden';
    }
}

function show_id(nodeId)
{
    var node = document.getElementById(nodeId);
    if (node)
    {
        node.className=node.className.replace('hidden', '');
        node.className += ' showed';
    }
}

function toggle_id(nodeId)
{
    var node = document.getElementById(nodeId);
    if (node)
    {
        if (node.className.indexOf('hidden') != -1)
            node.className=node.className.replace('hidden', 'showed')
        else if (node.className.indexOf('showed') != -1)
            node.className=node.className.replace('showed', 'hidden')
        else node.className += ' showed';
     }
}

function setPrintCSS(isPrint) {
// By Akella cssing.org.ua
  if (document.getElementsByTagName)
      x = document.getElementsByTagName('link');
  else
  {
      return;
  }
  for (var i=0;i<x.length;i++) {
      if(x[i].title == 'printview'){x[i].disabled = !isPrint;}
      if(x[i].title == 'screenview'){x[i].disabled = isPrint;}
  }
}

function checkForm()
{
var err = '';
 if ((document.getElementById('name').value == '') || (document.getElementById('name').value == 'Name'))
 {
  err = err + '<li>' + '<strong>Name</strong> - required to be filled' + '</li>';
 }
if ((document.getElementById('mail').value == '') || (document.getElementById('mail').value == 'Email Address'))
 {
  err = err + '<li>' + '<strong>Email</strong> - required to be filled' + '</li>';
 }
 if ((document.getElementById('message').value == '') || (document.getElementById('message').value == 'Message'))
 {
  err = err + '<li>' + '<strong>Message</strong> - required to be filled' + '</li>';
 }
 
 if ((document.getElementById('mail').value != '')&&(document.getElementById('mail').value != 'Email Address'))
 {
  if (!checkEmail(document.getElementById('mail').value))
  {
   err = err + '<li>' + '<strong>Valid Email</strong></li>';
  }
 }

if (err != '')
 {
  err ='<span>You forgot or did not correctly enter one or more fields. Please correct these errors:</span><ul>' + err + '</ul>';
  document.getElementById('fill_form').innerHTML=err;
  document.getElementById('fill_form').className="visible";
return false;
 }

 return true;
}

function checkEmail(e)
{
 ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

 for(i=0; i < e.length ;i++)
  if(ok.indexOf(e.charAt(i))<0)
   return (false);

 if (document.images)
 {
  re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
  re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
  if (!e.match(re) && e.match(re_two))
   return true;
  else
   return false;

 }
 return true;

}

function moveHintsN(e)
{
	document.getElementById('hints').style.visibility = "visible";
	var z = []; 		
	if (!e) e = event;
	if (e.pageX)
		{
			z['left'] = e.pageX ;
			z['top'] = e.pageY-20;
		}
		else
		{
			z['left'] = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			z['top'] = e.clientY + document.body.scrollTop + document.documentElement.scrollTop - 20;
		}
			z['height'] = 30;
			z['width'] = 20;		
	setPosition(document.getElementById('hints'), z);
}



function hideHintsN(e)
{
	document.onmousemove = null;
	document.onmouseout = null;
    document.getElementById('hints').style.visibility = "hidden";
}

function showHints(text, el)
{
	if (text == "") return;
	document.getElementById('hints').innerHTML = text;
	document.onmousemove = moveHintsN;
	document.onmouseout = hideHintsN;
}

function getBounds(tElement)
{
	var left = tElement.offsetLeft,
		top = tElement.offsetTop,
		parent;
	console.debug(left + ' ' + top);
	for (parent = tElement.offsetParent; parent; parent = parent.offsetParent)
	{
		left += parent.offsetLeft;
		top += parent.offsetTop;
	}
	return {left: left, top: top, width: tElement.offsetWidth, height: tElement.offsetHeight};
}

function setPosition()
{
	var scrollTop = document.documentElement.scrollTop,
		tElement = arguments[0],
		tBounds = arguments[1],
		w = tElement.clientWidth,
		h = tElement.clientHeight,
		winW = document.documentElement.clientWidth,
		winH = document.documentElement.clientHeight,
		vPX = 0,
		tHeightNotSet = true;

	if ((w + tBounds.left > winW) && (winW - w + tBounds.left > w))
		tElement.style.left = tBounds.left - w + tBounds.width + 'px';
	else
		tElement.style.left = tBounds.left + 'px';

	if (h + tBounds.top > winH + scrollTop)
	{
		if (h - tBounds.top > 0)
			if (h + tBounds.top - winH - scrollTop > h - tBounds.top)
				tHeightNotSet = false;
	}
	
	if ((tBounds.top + h > winH + scrollTop) && tHeightNotSet)
		if (tBounds.top - h - scrollTop > 0)
			tHeightNotSet = false;
	
	if ((winH - tBounds.top + scrollTop - h - tBounds.height < 0) && (tBounds.top - scrollTop - h > winH - tBounds.top + scrollTop - h - tBounds.height))
		tHeightNotSet = false;
//alert(tBounds.height);
	if (tHeightNotSet)
		tElement.style.top = tBounds.top + tBounds.height + vPX + 'px';
	else
		tElement.style.top = tBounds.top - h - vPX + 'px';
}






/* *********************************
        ON LOAD
********************************* */
window.onload = function(){

}
$(document).ready(function() {
$("div.post div.hentry h2 a").click(function() {
  $(this).parent().parent().parent().find("div.entry-content").slideToggle();
  return false;
});
})

