function checkemail(str)
{
	var testresults
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		testresults=true
	else
	{
		testresults=false
	}
	return (testresults)
}

function setselectfocus(h)
{
   h.focus();h.select();
}

function checkform(field,message)
{
	s=field.value;
	if(checkemail(s)) {
      return true;
	}
	else
	{
   		alert(message);
   		setselectfocus(field);
   		return false;
   	}
   	return false;
}

function checkContactForm(cform) {
    if (cform.name.value == "" )
    {
		$('contactmessage').update('<span  class="contactMessageErr">Enter you name!</span');
		$('contactmessage').show();
        cform.name.focus();
        return false;
    }

    if (cform.message.value == "" )
    {
		$('contactmessage').update('<span  class="contactMessageErr">Enter you message!</span');
		$('contactmessage').show();
        cform.message.focus();
        return false;
    }
    if (cform.zahystvidblyadskihspameriv.value == "" )
    {
		$('contactmessage').update('<span  class="contactMessageErr">Enter code!</span');
		$('contactmessage').show();
        cform.zahystvidblyadskihspameriv.focus();
        return false;
    }


    $('contactmessage').hide();
    $('progressbar').show();

    return true;
}

		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 getWindowWidth() {
			var windowWidth = 0;
			if (typeof(window.innerWidth) == 'number') {
				windowWidth = window.innerWidth;
			}
			else {
				if (document.documentElement && document.documentElement.clientWidth) {
					windowWidth = document.documentElement.clientWidth;
				}
				else {
					if (document.body && document.body.clientWidth) {
						windowWidth = document.body.clientWidth;
					}
				}
			}
			return windowWidth;
		}

		function setFooter2() {

		window.setFooter=function()
		{

			if (document.getElementById) {

					var footerElement = document.getElementById('pagefooter');


      				var scrollx = 0;
     				 scrollx = (window.scrollX) ? window.scrollX : document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft;

						footerElement.style.left = (scrollx)+'px';
						setTimeout("setFooter()", 10);

				}


		/*
			if (document.getElementById) {
				var windowHeight = getWindowHeight();
				if (windowHeight > 0) {
					var contentHeight = document.getElementById('pagecontent').offsetHeight;
					var footerElement = document.getElementById('pagefooter');
					var footerHeight  = footerElement.offsetHeight;
					if (windowHeight - (contentHeight + footerHeight) >= 0) {
						footerElement.style.position = 'relative';

      				var scrollx = 0;
     				 scrollx = (window.scrollX) ? window.scrollX : document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft;


						footerElement.style.top = (windowHeight - (contentHeight + footerHeight)-20) + 'px';
						footerElement.style.left = (scrollx)+'px';



					}
					else {
						footerElement.style.position = 'static';
					}
				}
			}*/
		}
		setFooter();
		}

 window.onscroll = function()
 {
 setFooter2();
 }



 function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1)
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

function ScrollToObject(objectid,offsetX)
{
	x = findPosX(document.getElementById(objectid))+offsetX;
	window.scrollTo(x,0);
}

function ScrollToObjectRight(objectid,offsetX)
{
	windowWidth = getWindowWidth();
	x = findPosX(document.getElementById(objectid))+offsetX-windowWidth;
	window.scrollTo(x,0);
}


//window.defaultStatus="[Online Portfolio] v.2";
