/** general js **/

var browser=navigator.appName
var b_version=navigator.appVersion
var version=parseInt(b_version)


function checksubscribeform(){
  var error = false;
  var errormsg = 'ERROR!!! The following fields are mandatory:\n\n';
  if (document.getElementById('name').value == ''){
   errormsg = errormsg + ' - Name\n';
   error = true;
  }
  if (document.getElementById('email').value == ''){
   errormsg = errormsg + ' - Email\n';
   error = true;
  }
  if (error == true){
   alert (errormsg);
  }
  else{
   if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email').value)){
    myform=document.getElementById('subscribeform');								
    myform.method='post';
    myform.action='index.php?id=103';
    myform.submit();
   }
   else{
	alert("ERROR!!! That is not a valid email address.")
   }	  
  }
 }

function checkcontactform(){
  var error = false;
  var errormsg = 'ERROR!!! The following fields are mandatory:\n\n';
  if (document.getElementById('mailto').value == ''){
   errormsg = errormsg + ' - To\n';
   error = true;
  }
  if (document.getElementById('name').value == ''){
   errormsg = errormsg + ' - Name\n';
   error = true;
  }
  if (document.getElementById('email').value == ''){
   errormsg = errormsg + ' - Email\n';
   error = true;
  }
    if (document.getElementById('phone').value == ''){
   errormsg = errormsg + ' - Telephone\n';
   error = true;
  }
  if (document.getElementById('message').value == ''){
   errormsg = errormsg + ' - Message\n';
   error = true;
  }
  if (error == true){
   alert (errormsg);
  }
  else{
   if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email').value)){
    myform=document.getElementById('contactform');								
    myform.method='post';
    myform.action='index.php?id=76';
    myform.submit();
   }
   else{
	alert("ERROR!!! That is not a valid email address.")
   }	  
  }
 }

function fixPNG(myImage) 
{

    if ((browser  == 'Microsoft Internet Explorer')  && (version < 7) && (document.body.filters))
    {

       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}

function setQuickRoll(name){

	tgt = 'tools/genquickroll.php?bgcolor=194|195|196|transparent=TRUE&color=110|110|112&text1='+name;

	document.getElementById('quickRoll').src=tgt;

}

function setOpacity(obj, opacity) {
        opacity = (opacity == 100)?99.999:opacity;
        // IE/Win
        obj.style.filter = "alpha(opacity:"+opacity+")";
        // Safari<1.2, Konqueror
        obj.style.KHTMLOpacity = opacity/100;
        // Older Mozilla and Firefox
        obj.style.MozOpacity = opacity/100;
        // Safari 1.2, newer Firefox and Mozilla, CSS3
        obj.style.opacity = opacity/100;
}


function findPosX(obj)
{
        obj = document.getElementById(obj);
        var curleft = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curleft += obj.offsetLeft
                        obj = obj.offsetParent;
                }
        }
        else if (obj.x)
                curleft += obj.x;
        return curleft;
}

function findPosY(obj)
{
                obj = document.getElementById(obj);
        var curtop = 0;
        if (obj.offsetParent)
        {
                while (obj.offsetParent)
                {
                        curtop += obj.offsetTop
                        obj = obj.offsetParent;
                }
        }
        else if (obj.y)
                curtop += obj.y;
        return curtop;
}


function setQuickLinkHeight(){
		
	// target position
	bottom = findPosY('heightMarker');
	// where does the quicklink start
	navEnd = findPosY('navMarker');

	// offset
	diff = 84;
	quickHeight = (parseInt(bottom) - parseInt(navEnd)) - diff;

	endQuick = findPosY('quicklinkEnd');

	if(bottom >= endQuick){
		document.getElementById('quicklinkContentBox').style.height = quickHeight + 'px';
	}

}

function getHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  return myHeight;
}

function getScrollHeight() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  //return [ scrOfX, scrOfY ];
    return scrOfY;
}

function setGreyPanelHeight(){
        // target position

	end = findPosY('theEnd');

	height = getHeight();

	if(end >= height){
		pos = end;
	} else {
		pos = height;
	}

        document.getElementById('greyPanel').style.height = pos + 'px';



}

function showAd(){
	return true;
        pos = findPosY('bannerAdPanel');
        if(pos > 10){
                document.getElementById('bannerAdPanel').style.display='none';
        } else {

         document.getElementById('bannerAdPanel').style.display='inline';
        }

}
