<!--
/**********************************************************************************

Function Map

100) elm
101) efi
102) efn
103) OpenWindow
104) openBrWindow
105) confirmAction
106) isValid
107) InStr
108) mid
109) IsEmail
110) IsNumeric 
111) trimString
112) fileManager
113) openEditor
114) checkWYSIWYGPopup
115) showPreview
116) showTemplatePreview
117) showtemplatecode
118) urlFunction
119) addOption
120) removeElement
121) rowHighlight
122) rowNormal
123) trueX
124) trueY
125) DoResize
126) HookContentHilite
127) SetCombo
128) AjaxInvoke
129) HandleEvent
130) AttachEvent
131) IsValidPhone
132) IsValidEmail
133) HookImageRotator
**********************************************************************************/




// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 100) elm
function elm(elmName)
{
   return document.getElementById(elmName);
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 101) efi
function efi(id)
{
    return document.getElementById(id);
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 102) efn
function efn(name)
{
    return document.getElementsByName(name)[0];
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 103) OpenWindow
function OpenWindow(url, winName, features)
{
    var regex = /(\w+)=(\w+)(px)?,?/g;
    var m;
    var max = false;
    var feat = '';
    var dialog = 'no';
    var left, top, width = 320, height = 480;
    var dialogFeat = '';
    var userFiles = false;
    while ((m = regex.exec(features)) != null)
    {
       if (RegExp.$1 == 'maximized' && RegExp.$2.toLowerCase() == 'yes')
       {
           max = true;
       }
       else if (RegExp.$1 == 'userfiles')
       {
           userFiles = true;
       }
       else if (RegExp.$1 == 'left')
       {
           left = RegExp.$2;
       }
       else if (RegExp.$1 == 'top')
       {
           top = RegExp.$2;
       }
       else if (RegExp.$1 == 'width')
       {
           width = RegExp.$2;
       }
       else if (RegExp.$1 == 'height')
       {
           height = RegExp.$2;
       }
       else if (RegExp.$1 == 'dialog')
       {
           dialog = (RegExp.$2 == 'yes' || RegExp.$2 == '1' ? 'yes' : 'no');
       }
       else
       {
           if (feat != '') feat += ',';
           feat += RegExp.$1 + '=' + RegExp.$2;
           if (dialogFeat != '') dialogFeat += ';';
           dialogFeat += RegExp.$1 + ':' + RegExp.$2;
       }
    }
    var tmpFeat = '';
    if (max == true)
    {        
        if (dialog == 'no')
            tmpFeat += 'left=0px,top=0px,width=' + (screen.availWidth - 10) + 'px,height=' + (screen.availHeight - 30) + 'px';        
        else
            tmpFeat += 'dialogLeft:0px;dialogTop:0px;dialogWidth:' + (screen.availWidth - 10) + 'px;dialogHeight=' + (screen.availHeight - 30) + 'px';        
        
    } else
    {
       if (left != '') tmpFeat += (dialog == 'no' ? 'left=' : 'dialogLeft:') + ((screen.availWidth - width) / 2) + 'px';
       if (tmpFeat != '') tmpFeat += (dialog == 'no' ? ',' : ';');
       if (top != '') tmpFeat += (dialog == 'no' ? 'top=' : 'dialogTop:') + ((screen.availHeight - height) / 2) + 'px';
       if (tmpFeat != '') tmpFeat += (dialog == 'no' ? ',' : ';');
       if (width != '') tmpFeat += (dialog == 'no' ? 'width=' : 'dialogWidth:') + width + 'px';
       if (tmpFeat != '') tmpFeat += (dialog == 'no' ? ',' : ';');
       if (height != '') tmpFeat += (dialog == 'no' ? 'height=' : 'dialogHeight:') + height + 'px';
    }

    if (dialog == 'no')
        return window.open(url, winName, tmpFeat + ',' + feat);
    else
        return window.showModalDialog(url, '', tmpFeat + ';' + dialogFeat);

}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 104) openBrWindow
function openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 105) confirmAction
function confirmAction(msg, cURL) {
  if (confirm(msg) == true) {
    document.location.href = cURL;
  }
}


// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 106) isValid
function isValid(string,allowed) {
  for (var i=0; i< string.length; i++) {
    if (allowed.indexOf(string.charAt(i)) == -1)
      return false;
    }
  return true;
}


// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 107) InStr
function InStr(strSearch, charSearchFor) {
  for (i=0; i < strSearch.length; i++) {
    if (charSearchFor == mid(strSearch, i, 1)) {
      return i;
      }
  }
  return -1;
}


// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 108) mid
function mid(str, start, len) {
  // jump out if not within bounds of string
  if (start < 0 || len < 0) { return ""; }
  var midEnd, midLen = String(str).length;
  if (start + len > midLen) { midEnd = midLen; }
  else { midEnd = start + len; }
  return String(str).substring(start,midEnd);
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 109) IsEmail
function IsEmail(ie_str) {
  // validates email address for x@x.x

  var atFound = -1;var dotFound = -1;var charFound = false;var checkStr;var splitString

  checkStr = ie_str;

  splitString = checkStr.split("");
  for (var i = 0; i < checkStr.length+1; i++) {
    if (splitString[i] == "\"" | splitString[i] == "'") {
      return false;
    }
    if (splitString[i] < " " | splitString[i] > " ") { charFound = true; }
    if (splitString[i] == "@") { atFound = i; }
    if (splitString[i] == ".") { dotFound = i; }
  }
  if (charFound == true) {
    if (atFound > -1) {
      if (dotFound > -1) {
        if (dotFound < atFound) {
          return false;
        } else {
		  if ((dotFound-atFound) == 1 | dotFound == (checkStr.length-1) | atFound == 0) {
            return false;
          }
        }
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
  return true;
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 110) IsNumeric
function IsNumeric(sText, isNormalCurrency) {
  var in_charList = "0123456789.";
  var in_searchChar;
  if (isNormalCurrency == true) {
    in_searchChar = '.';
  } else {
    in_searchChar = ',';
    in_charList += ',';
  }
  var in_char;

  if (sText.length == 0) { return false; }

  for (i = 0; i < sText.length; i++) {
    in_char = sText.charAt(i);
    if (in_charList.indexOf(in_char) == -1) { return false; }
    if (in_char == in_searchChar) {
      if (sText.length == 1) { return false; }
      else { in_charList = "0123456789"; }
      }
    }
  return true;
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 111) trimString
function trimString (str) {
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 112) fileManager
function fileManager(p, frm, fld) {
window.open('_loadWindow.asp?m=-1&p=' + escape(p) + '&frm=' + escape(frm) + '&fld=' + escape(fld),'loadWindow','status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=680,height=480');
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 113) openEditor
function openEditor(mode, contentID, languageID, langUpdateAll, template) {
   wysiwygWin = window.open('_loadWindow.asp?m=' + mode + '&i=' + contentID + '&j=' + languageID + '&language_updateAll=' + langUpdateAll + '&template=' + template,'loadWindow' + contentID + languageID,'toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=900,height=650');

}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 114) checkWYSIWYGPopup
function checkWYSIWYGPopup() {
  if (wysiwygWin == null) {
    alert('Your popup window blocker may be preventing the WYSIWYG editor from opening after you save.\n\nPlease launch the editor by clicking on \'WYSIWYG HTML Editor link.\'');
  }
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 115) showPreview
function showPreview(cID, cMode) {
  window.open('_loadWindow.asp?m=9&cID=' + escape(cID) + '&contentMode=' + escape(cMode),'loadWindow','status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=900,height=550');
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 116) showTemplatePreview
function showTemplatePreview(tID) {
  window.open('_loadWindow.asp?m=10&templateHistoryID=' + escape(tID),'loadWindow','status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=900,height=550');


}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 117) showtemplateCode
function showtemplateCode(tID) {
  openBrWindow("_templates_view.asp?templateHistoryID=" + tID, "prv", "toolbar=no,menubar=no,scrollbars=yes,resizable=true,width=900,height=550");
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 118) urlFunction
function urlFunction(mode, cID) {
  if (mode == 1) {
    setTimeout("urlFunction(11," + cID + ")", 250);
  } else if (mode == 11) {
    document.location.reload();

  } else if (mode == 2) {
    setTimeout("urlFunction(22, " + cID + ")", 250);
    
  } else if (mode == 22) {
    document.location.href='_content_publish.asp?contentID=' + cID;
  }
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 119) addOption
function addOption(formElement, optiontext, optionValue) {
  var optionName = new Option(optiontext, optionValue, false, false)
  var length = formElement.length;
  formElement.options[length] = optionName;
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 120) removeElement
function removeElement(array, itemNo) {
  size = array.length;
  validNo = (itemNo != "NaN");
  inRange = ( (itemNo >= 0) && (itemNo <= array.length) );
  if (validNo && inRange) {
    for (var i=0; i<=size; i++)
      array[i] = ((i == itemNo) ? "delete" : array[i]);
      for (var j=itemNo; j<size-1; j++)
      if (j != size) array[j] = array[j+1];
      array.length = size-1;
    return array
  }
  return array
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 121) rowhighlight
function rowhighlight(b,clr){
   if(clr==null)
      clr="dfdfdf";
   b.style.backgroundColor='#'+clr;}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 122) rownormal
function rownormal(b){
   b.style.backgroundColor='';}


var gContentIndex = 1;

function ShowShade()
{
	efi('WaitPanel').style.display = 'block';
}

function HideShade()
{
//	efi('BodyPanel').filters[0].Opacity = 100;
	efi('WaitPanel').style.display = 'none';
}

OnContentEdit = function()
{
    openContentEditor(this.ContentIndex);
}

OnFormEdit = function()
{
   openFormEditor();
}

function OnSubmitDoNull()
{
	alert('Form is disabled in Edit Mode.');
	return false;
}
editorHilite = function()
{   
   gContentIndex = 1;
   var imgNodes = document.getElementsByTagName('IMG');
   for (var i = imgNodes.length - 1; i >= 0; i--)
   {       
       if (imgNodes[i].getAttribute('IsEdit') == 'A')
       {
           document.body.removeChild(imgNodes[i]);
       }
   }

   var embedNodes = document.getElementsByTagName('EMBED');
   for (var i = embedNodes.length - 1; i >= 0; i--)
   {       
   	   var embed = embedNodes[i];
       var img = document.createElement('IMG');
       var tbl = document.createElement('TABLE');
       img.src = '/images/fck_flashlogo.gif';
       var cell = tbl.insertRow().insertCell();
       cell.width = embed.width;
       cell.height = embed.height;       
       cell.align = 'center';
       cell.style.border = '1px solid gray';
       cell.appendChild(img);
       embed.parentElement.replaceChild(tbl, embed);
   }
   
   var forms = document.getElementsByTagName('FORM');
   for (var i = 0; i < forms.length; i++)
   {
   	   var form = forms[i];
   	   form.onsubmit = OnSubmitDoNull;
   }
   
   
   
   var comments = document.getElementsByTagName('!');
   for (var i = 0; i < comments.length; i++)
   {
       if (comments[i].text.toUpperCase() == '<!--STARTC-->')
       {

           if (comments[i].parentElement.childNodes.length == 2 )
           {
                 comments[i].parentElement.innerHTML = '&nbsp;' + comments[i].parentElement.innerHTML;
           }
           
           var colCount = 0;
           for (var j = 0; j < comments[i].parentElement.all.length; j++)
           {
           	   if (comments[i].parentElement.all[j].tagName == 'TABLE')
           	   {
           	   	   if (comments[i].parentElement.all[j].rows.length > 0)
           	   	   {
           	   	   	   	colCount = comments[i].parentElement.all[j].rows[0].cells.length;
           	   	   }
           	   }
           }
           
            
           var img = document.createElement('IMG');
           img.style.position = 'absolute';
           img.setAttribute('IsEdit', 'A');
           img.src = '/images/edit.gif';
           img.style.left = trueX(comments[i].parentElement);
           img.style.top = trueY(comments[i].parentElement);
           img.style.zIndex = 0;
           img.title = 'Edit this content.';
           img.ContentIndex = gContentIndex;
           img.onclick = OnContentEdit;
           img.style.cursor = 'hand';
           document.body.appendChild(img);                     
		   
		   AjaxInvoke('/_editor_ajaxprocess.asp', 'SET_DIM=1&ContentId=' + EZY_CONTENT_ID + '&SubContentId=' + gContentIndex + '&Width=' + comments[i].parentNode.clientWidth + '&Height=' + comments[i].parentNode.clientHeight + '&Align=' + escape(comments[i].parentNode.align) + '&vAlign=' + escape(comments[i].parentNode.vAlign) + '&class=' + escape(comments[i].parentNode.className) + '&style=' + escape(comments[i].parentNode.style.cssText) + '&TableCols=' + escape(colCount));
           comments[i].parentElement.style.border = '1px dotted blue';
           gContentIndex ++;
           
       } else if (comments[i].text.toUpperCase() == '<!--STARTF-->')
       {
           comments[i].parentElement.style.border = '1px dotted brown';
           var img = document.createElement('IMG');
           img.style.position = 'absolute';
           img.src = '/images/edit_form.gif';
           img.style.left = trueX(comments[i].parentElement);
           img.style.top = trueY(comments[i].parentElement);
           img.style.zIndex = 0;
           img.ContentIndex = gContentIndex;
           img.onclick = OnFormEdit;
           img.style.cursor = 'hand';
           document.body.appendChild(img);
 	   } else if (comments[i].text.toUpperCase() == '<!--CFM-->')
       {
           comments[i].parentElement.style.border = '1px dotted gray';
           var img = document.createElement('IMG');
           img.style.position = 'absolute';
           img.src = '/images/custom_form.gif';
           img.style.left = trueX(comments[i].parentElement);
           img.style.top = trueY(comments[i].parentElement);
           img.style.zIndex = 0;
           img.ContentIndex = gContentIndex;           
           img.style.cursor = 'default';
           document.body.appendChild(img);
           
           var parentElement = comments[i].parentElement;
           for (var iCFM = 0; iCFM < parentElement.all.length; iCFM++)
           {
           	   
           	   if (parentElement.all[iCFM].tagName == 'INPUT')
           	   {
           	   	   if (parentElement.all[iCFM].type == 'submit')           	   	   
           	   	   	  parentElement.all[iCFM].disabled = true;
           	   }
           }
       } else if (comments[i].text.toUpperCase() == '<!--MENU-->')
       {
           comments[i].parentElement.style.border = '1px dotted gray';
           comments[i].parentElement.innerHTML = 'MENU' + comments[i].parentElement.innerHTML;
       } 
   }

}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 123) trueX
function trueX(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;
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 124) trueY
function trueY(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;
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 125) DoResize
function DoResize()
{
   window.setTimeout('editorHilite()', 250);
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 126) HookContentHilite
function HookContentHilite()
{
    AttachEvent(window, 'onload', editorHilite);
    AttachEvent(window, 'onresize', DoResize);
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 127) SetCombo
function SetCombo(controlName, value)
{
    var select = efn(controlName);
    for (var i = 0; i < select.options.length; i++)
    {
        if (select.options[i].value.toUpperCase() == value.toUpperCase())
        {
            select.selectedIndex = i;
            return;
        }
    }
    if (select.options.length > 0)
    select.selectedIndex = 0;
}  

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 128) AjaxInvoke
function AjaxInvoke(script, param)
{
   	var transport;
   	transport = (window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest());
   	//alert(script + '?Ajax=1&' + param);
   	transport.open('GET', script + '?Ajax=1&' + param, false);
   	transport.send(null);
	//alert(transport.responseText);
   	return transport.responseText;
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 129) HandleEvent
var objectMap = new Array();
var JslEventElement = null;

function JslEventHandler(object, strEvent, func, instance)
{
	this.Object = object;
	this.Event = strEvent;
	this.Function = func;
	this.Instance = instance;
	this.Execute = JslEventHandler_Execute;
}

function JslEventHandler_Execute(object)
{
	if (this.Object)
	{
		if (typeof(this.Function) == 'function')
			this.Function(this.Object, this.Instance);	
		else
		{
			window.execScript(this.Function);
		}
	}
}
function HandleEvent()
{
	JslEventElement = event.srcElement;
	var objName;
	if (JslEventElement == null)
	{
		JslEventElement = window;	
		objName = 'window';
	}
	else
		objName = JslEventElement.uniqueID;
	var funcMap = objectMap[objName]['on' + window.event.type];
	for (var i = 0; i < funcMap.length; i++)
	{
		if (funcMap[i].Object && JslEventElement == funcMap[i].Object)	
		{
			if (objName == 'window')
			{
					funcMap[i].Execute(JslEventElement);			
			}
			else
				funcMap[i].Execute(JslEventElement);
		}
	}
	JslEventElement = null;
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 130) AttachEvent

function AttachEvent(obj, event, func)
{		
	if (event == 'onload')
	{		
		if (typeof obj.onload != 'function')
			obj.onload = func;
		else
		{
			oldFunc = obj.onload;
			obj.onload = function() { oldFunc(); func(); }
		}
	}
}

/*function AttachEvent(obj, objEvent, func, instance)
{
	var objName;
	if (obj.uniqueID)
		objName = obj.uniqueID;
	else if (obj.navigate)
		objName = 'window';
	else
		throw 'Object must be a element or window.';	
	if (objectMap[objName] == undefined)
		objectMap[objName] = new Array();
	if (objectMap[objName][objEvent] == undefined)
	{
		objectMap[objName][objEvent] = new Array();				
		if (obj.attachEvent)
		{
			obj.attachEvent(objEvent, HandleEvent);
		} else if (obj.addEventListener)
		{
			obj.addEventHandler('on' + objEvent, HandleEvent);
		}
	}
	objectMap[objName][objEvent].push(new JslEventHandler(obj, objEvent, func, instance));
}
*/

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 130) HtmlEncode
function HtmlEncode (str)
{
   var div = document.createElement('div');
   var text = document.createTextNode(str);
   div.appendChild(text);
   return div.innerHTML;
}; 

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 131) IsValidPhone
function IsValidPhone(phone)
{
	return /^[+\s\d\.]+$/.test(phone);
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 132) IsValidEmail
function IsValidEmail(email)
{
	return /^[\w\-_\.]+@[\w\-_]+\.[\w\-_]+(\.[\w\-_]{2})?$/.test(email);
}

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 133) HookImageRotator

var ImageRotateArray = new Array();

function GetA(element, aName, defaultValue)
{
    var value = element.getAttribute(aName);
    if (value == null)
        return defaultValue;
    else
        return value;
}

function HookImageRotator()
{
    var imgs = document.getElementsByTagName("IMG");
    for (var i = 0; i < imgs.length; i++)
    {
        var img = imgs[i];
        if (img.getAttributeNode('_isimgrot') != null)
        {            
            var imgrot = new Object();
            imgrot.Element = img;                        
            imgrot.ImageList = AjaxInvoke('/_filepipe.asp', 'cmd=IMGROTLIST&ImageId=' + img.getAttribute('_rotimgid')).split('\r\n');                        
            imgrot.Index = 0;            
            imgrot.TimeOut = parseInt(GetA(img, '_displaytime', 5));
            imgrot.Random = (GetA(img, '_random', '0') == '1' ? true : false);
            imgrot.TimeCurr = 1;                        
            if (img.getAttribute('_once') == '1')
            {
                imgrot.Element.src = __userFolder + "/" + imgrot.ImageList[parseInt(Math.random() * 10000) % imgrot.ImageList.length];            
            }                      
            else
            {
                ImageRotateArray.push(imgrot);  
                imgrot.Element.src = __userFolder + "/" + imgrot.ImageList[0];            
            }
        }
    }
    StartImageRotate();
}

function StartImageRotate()
{
    window.setInterval(OnPicRotate, 1000);
}

function OnPicRotate()
{
    for (var i = 0; i < ImageRotateArray.length; i++)
    {
        var imgrot = ImageRotateArray[i];
        if (imgrot.TimeCurr >= imgrot.TimeOut)
        {            
            imgrot.TimeCurr = 1;
            if (imgrot.Random)
            {
                var index = parseInt(Math.random() * imgrot.ImageList.length);
                while (imgrot.Index == (index % imgrot.ImageList.length) && imgrot.ImageList.length > 1)
                {
                    index = parseInt(Math.random() * imgrot.ImageList.length);
                }                                
                imgrot.Index = (index) % imgrot.ImageList.length;
            } else
                imgrot.Index = (imgrot.Index + 1) % imgrot.ImageList.length;
            imgrot.Element.src = __userFolder + "/" + imgrot.ImageList[imgrot.Index];            
        }        
        else
        {
            imgrot.TimeCurr++;
        }
    }
}


//-->

