// JavaScript Document
function showHide(el)
{
    if (document.getElementById(el).style.display == "block")
    {
        document.getElementById(el).style.display = "none";
    }
    else
    {
        document.getElementById(el).style.display = "block";
    }
}

function showHideMain()
{
  document.getElementById('cc-hidden').style.display = "block";
  document.getElementById('cc-link').style.display = "none";
  document.getElementById('kredit').style.display = "none";
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
function checkForm()
{
	if (trim(document.forms["feedback"].elements["name"].value) == "" || 
	    !isValidEmail(document.forms["feedback"].elements["email"].value)
		|| trim(document.forms["feedback"].required.value) == "" )
	{
		alert("Fill in required fields!");
		return false;
	}
	return true;
}
function showComments()
{
	
  document.getElementById('comments').style.display = "block";
  document.getElementById('shc').style.display = "none";
}
function checkComment()
{
	if (trim(document.forms["comment"].elements["author_name"].value) == "" || 
	    !isValidEmail(document.forms["comment"].elements["email"].value)
		|| trim(document.forms["comment"].comment.value) == "")
	{
		alert("Fill in required fields!");
		return false;
	}
	return true;
}
function checkForm()
{
	if (trim(document.forms["comment"].elements["comp"].value) == "" || 
	    !isValidEmail(document.forms["comment"].elements["from"].value)
		|| trim(document.forms["comment"].text.value) == "")
	{
		alert("Fill in required fields.");
		return false;
	}
	return true;
}

function PPic(sPicURL) {
     window.open( "/popup.html?"+sPicURL, "",  
     "resizable=1,HEIGHT=200,WIDTH=200");
   }
   
function updateGallery(tumb, full, num)
{
	document.images['photo'].src = tumb;
	document.getElementById('phlink').href = 'javascript:PPic("' + full + '");';
	document.getElementById('palielinat').href = 'javascript:PPic("' + full + '");';
	
	for (var i=0; i<10; i++) {
		if (document.getElementById('isact' + i) != null)
		{
			document.getElementById('isact' + i).className = "";
		}			
	}
	
	document.getElementById('isact' + num).className = "isact";
	
}
