//Falcorweb CMS javascripts version 2010-04-04 - added window dimensions array (winxy[]) 
//and WRAPPED all functions in "if" not exists condition


// E M A I L   D I S G U I S E R 
if(typeof window.str_replace != "function") {
function str_replace(search, replace, subject) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
    return sa ? s : s[0];
   }//end function
}//end if not function


if(typeof window.fwEmReveal != "function") {
function fwEmReveal(textStr) {
   //works in conjuction with php script, "emObfuscate" in displayContent.php
   var newTextStr = textStr;
   newTextStr = str_replace('~%^at~%^','@',newTextStr);
   newTextStr = str_replace('~%^mai~%^lto~%^:~%^','mailto:',newTextStr);
   return newTextStr;
   }
}//end if not function


// F O N T   A D J U S T
if(typeof window.increaseFont != "function") {
function increaseFont() {
   if (document.body.className == '')
      document.body.className = 'small';
   newClassName = (document.body.className == 'small') ? 'medium' : 'large';
   setFont(newClassName);
   setCookie("bodyClass",newClassName);
   }
   }//end if not function


if(typeof window.decreaseFont != "function") {
function decreaseFont() {
   if (document.body.className == '')
      document.body.className = 'small';
   newClassName = (document.body.className == 'large') ? 'medium' : 'small';
   setFont(newClassName);
   setCookie("bodyClass",newClassName);
   }
}//end if not function

if(typeof window.setFont != "function") {
function setFont(className) {
   if(!className)
      className = readCookie("bodyClass");
   if(!className)
      className = 'small';
   document.body.className = className;
   setCookie("bodyClass",className);
   }
}//end if not function


// F I X   P N G S   I N   I E 

if(typeof window.fixPngs != "function") {
function fixPngs() {
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}
} //end function fixPngs
} //end if not function



// C O O K I E   F U N C T I O N S

if(typeof window.setCookie != "function") {
function setCookie(c_name,value,expiredays) {
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
}//end if not function


if(typeof window.readCookie != "function") {
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;
   }
}//end if not function


if(typeof window.eraseCookie != "function") {
function eraseCookie(name) {
	createCookie(name,"",-1);
}
}//end if not function


// M I S C
if(typeof window.popTempUnavail != "function") {
function popTempUnavail() {
   alert('This item is temporarily unavailable.');
}  
}//end if not function


if(typeof window.getWinxy != "function") {
function getWinxy() {
   var winxy = [];
   winxy[0] = (self.innerWidth) ? self.innerWidth : 
      (  (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth :
         document.body.clientWidth  );
   winxy[1] = (self.innerHeight) ? self.innerHeight : 
      (  (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : 
         document.body.clientHeight  );
   return winxy;
   }//end function
}//end if not function

