﻿function trim(str)
{
      return str.replace(/^\s{1,}/ig, "").replace(/\s{1,}$/ig, "");
}


function OpenSubMenu(DivId)
{
var CollapseDiv =document.getElementById(DivId);
var ArrowUpDown = document.getElementById('arrow'+DivId);
var sAttr = (window.clientInformation) ? "className" : "class";
if (CollapseDiv!= null)
 {
    if(CollapseDiv.style.display=="none")
    {
        CollapseDiv.style.display="block";
        ArrowUpDown.setAttribute(sAttr, "ms-navitemArrowUP", 0);
    /*.ms-navitemArrowUP*/
    }
    else
    {
        CollapseDiv.style.display="none";
    
        ArrowUpDown.setAttribute(sAttr, "ms-navitemArrowDown", 0);
    }
  }
}

/* SiteMap */
function changeCloseOpenHeaderTitle(divid,hiddendiv)
{

try
{
/*SecondLevelMainContainer*/


var divTochage =document.getElementById(divid);
var DivStatus =document.getElementById(hiddendiv);
/*========================= Hushay 22/1/2008 =========================================*/
var divs = DivStatus.getElementsByTagName('DIV');

var sDivStyle ;

var sCloseOpenText;
var sCurrentText;
if(divTochage.textContent != null)
{
 sCurrentText= divTochage.textContent;
}
else
{
 sCurrentText = divTochage.innerText;
}

if(sCurrentText.indexOf('סגור') > -1)//sCurrentText.indexOf('סגור') > -1)
{
  
  divStyle = 'none';
  sCloseOpenText= 'פתח<<';
}
else
{
	
 divStyle = 'block';
 sCloseOpenText= 'סגור<<';

}

for(var i =0;i< divs.length;i++)
{
	var currentDiv = divs[i];
	
	
	
	if(currentDiv.className=='SecondLevelMainContainer')
	{
		currentDiv.style.display = divStyle;
		
	}
}
if(divTochage.textContent != null)
{
  divTochage.textContent= sCloseOpenText;
}
else
{
divTochage.innerText= sCloseOpenText;
}
/*======================================================================*/

//if(DivStatus.style.display=="none")
//{
//DivStatus.style.display="block";
//divTochage.innerText ="סגור<<";

//}
//else
//{
//DivStatus.style.display="none";
//divTochage.innerText ="פתח<<";

//}


}
catch(e)
{}
}
function ToggleTopLevelSiteMap(DivId) 
{
/*debugger;*/
try
{

   var CollapseDiv =document.getElementById(DivId);
    
    if(CollapseDiv.style.display=="none")
    {
        CollapseDiv.style.display="block";
    
    }
    else
    {
      CollapseDiv.style.display="none";
     
    }
    }
    catch(e)
    {
    }
}




function ChangePlustMinus(DivId)
{

try
{

var MinusPlusIcon = document.getElementById(DivId);
var sAttr = (window.clientInformation) ? "className" : "class";



if(MinusPlusIcon.attributes['className'])
{
        if(MinusPlusIcon.attributes['className'].value=="TopLevelIcon")
        {
        MinusPlusIcon.attributes['className'].value ="TopLevelIconplus";

            
            
           
            }
        else
        {
         MinusPlusIcon.attributes['className'].value ="TopLevelIcon";
          
        }

}
else
    {
        if(MinusPlusIcon.attributes['class'].value=="TopLevelIcon")
        {
        MinusPlusIcon.attributes['class'].value ="TopLevelIconplus";

           
            }
        else
        {
          
            MinusPlusIcon.attributes['class'].value ="TopLevelIcon";
        }


    }
}
catch(e)
{}
}

function OpenLinkInSameWindow(url)
{
    window.location.href = url;
}
 function expand(divHeader, divInternal)
        {
            if (divInternal.className == 'ClosedDiv')
            {
                divInternal.className  = 'OpendDiv';
                divHeader.className  = 'collapseHeaderOpened';

            }
            else
            {
                divInternal.className  = 'ClosedDiv';
                divHeader.className  = 'collapseHeader';

            }

           
               
        }
        
        function expandAll(div)
        {
        	if(div.className == 'OpenAllClosed')
       		{
       			div.className = 'OpenAllOpened';
       		
       			div.innerText = 'סגור הכל';
       			
       			var divs=document.getElementsByTagName('div')
				for (var i=0; i<divs.length; i++){
					if (divs[i].className == 'ClosedDiv')
		                divs[i].className  = 'OpendDiv';
	                if (divs[i].className == 'collapseHeader')
		                divs[i].className  = 'collapseHeaderOpened';

				} 
       		}
       		else
       		{
				div.className = 'OpenAllClosed';  
				  			
				div.innerText = 'פתח הכל';
				
				
				var divs=document.getElementsByTagName('div')
				for (var i=0; i<divs.length; i++){

					if (divs[i].className == 'OpendDiv')
		        	    divs[i].className  = 'ClosedDiv';
	                if (divs[i].className == 'collapseHeaderOpened')
		       		    divs[i].className  = 'collapseHeader';
		        }

       		}
        }
        
        
        
        
var tabCounter = 1;

function setTabs(node)
{ 

    var objChildNodes= node.childNodes;
    for (var j=0 ; j < objChildNodes.length ; j++)
    {
        if(objChildNodes.length > 0)
        {
            setTabs(node.childNodes[j])
        }
    }
    if(node.nodeName == 'INPUT' || node.nodeName == 'TEXTAREA' || node.nodeName == 'SELECT' || node.nodeName == 'A' || node.nodeName == 'AREA' || node.nodeName == 'EMBED' || ((node.nodeName == 'DIV' || node.nodeName == 'SPAN' || node.nodeName == 'LABEL' || node.nodeName == 'IMG' ) && (node.getAttribute('onclick') != null  )))    
    {
        if(node.getAttribute('tabindex') != -1)
        {
            var oCurrentObject = node;
            var oAttributes = oCurrentObject.attributes;
            var namedItem = document.createAttribute("tabindex");
            namedItem.value = tabCounter;
            oAttributes.setNamedItem(namedItem);
            tabCounter++;
        }   
     }
}

function onLoadEvent()
{
    isBrowserFavorrites();
   ConstructionPermitsSetPage();
}



function ConstructionPermitsSetPage()
{
    try
    {  
        setTabs(document.getElementById('dvPageheader'));
        setTabs(document.getElementById('dvTopMeuDivContainer'));        
        setTabs(document.getElementById('dvBreadcrumb'));
        setTabs(document.getElementById('dvTopSearch'));
        setTabs(document.getElementById('dvRightNav'));
        setTabs(document.getElementById('dvMainContent'));
        setTabs(document.getElementById('dvFooter'));

    }
    catch(e)
    {
    }


}

function isBrowserFavorrites()
{
    var  IE_NUM = 6;
    var  MOZ_NUM = 2; 
    if(navigator.userAgent.indexOf('MSIE') > -1)
    {
        IE_NUM = parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf('MSIE')+5,navigator.userAgent.indexOf('MSIE')+6));
    }
    else if(navigator.userAgent.indexOf('Firefox/') > -1)
    {
        MOZ_NUM = parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox/')+8,navigator.userAgent.indexOf('Firefox/')+9));
    }
      
    if(!readCookie('isBrowserFavorrites') == '1')
    {
        if(!(MOZ_NUM >= 3 ||  IE_NUM >= 7))
        {
            var text='האתר מומלץ לצפייה ברזולוציית מסך של\n';
            text +='1024 X 768\n';
            text +='ובדפדפן מסוג\n';
            text +='Internet explorer\n';
            text +='גירסה 7 ומעלה או\n';
            text +='Mozilla Firefox\n';
            text +='גרסה 3 ומעלה\n';
            alert(text);
            createCookie('isBrowserFavorrites','1',1)
        }
    }              
}

function refreshAfterItemsAdded()
{
    if(document.referrer.indexOf('CreatePage') > -1)
    {        
        window.location.href = location.href+" ";
    }   
}

function createCookie(name,value,days)
{
	if (days) 
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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;
}

function eraseCookie(name) 
{
	createCookie(name,"",-1);
}



/*Start Functions For Cities Ajax */

 var currentCityIndex = null;
function AjaxFillValues(e,ch, inputID,AjaxPath)
{

    var keynum;
   
    if(window.event) // IE
    {
        keynum = e.keyCode;
    }
    else if(e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }
    
    if(keynum == 38 || keynum == 40)
        return;
    
    /*Clear Current input title*/
    document.getElementById(inputID).title = ch;
    
    /*Get four inputs titles (city Code) */
     
       var params = "&inputID=" + inputID  ;
           params +="&Prefix=" +  document.getElementById(inputID).value;           
        
        var inputCoords = findElementCoords(document.getElementById(inputID));
        
    if(ch == "")
    { /*String to search */
        document.getElementById("Cities").style.display = "none"
    }
    else
    {
        document.getElementById("Cities").style.display = "block"
        document.getElementById("Cities").style.left  = inputCoords[0];
        document.getElementById("Cities").style.top  = inputCoords[1]+document.getElementById(inputID).offsetHeight;
        document.getElementById("Cities").style.width = document.getElementById(inputID).offsetWidth - 5  ;
         document.getElementById("Cities").setAttribute("LoadingText","טוען...");
       
        AJAX.asyncWithCallback(AjaxPath,params,"insertRequestIntoDiv",true,false,document.getElementById("Cities"));
    }
}

function insertRequestIntoDiv(Request)
{
document.getElementById("Cities").innerHTML = Request;
}


function highlightCity(rowID)
{
    if(rowID.id)
    {
        document.getElementById(rowID.id).className = "ItemSearchContentSelected";
        currentCityIndex = rowID.id;
    }
    else
    {
         document.getElementById(rowID).className = "ItemSearchContentSelected";
         currentCityIndex = rowID;          
    }
}

function lowlightCity(rowID)
{
    if(rowID.id)
    {
       
        document.getElementById(rowID.id).className = "ItemSearchContent";
        currentCityIndex = rowID.id;
    }
    else
    {
        document.getElementById(rowID).className = "ItemSearchContent";
        currentCityIndex = rowID;
      
    }
}

function citySelected(value, inputID, CityCode)
{
    var inputElem = document.getElementById(inputID);
    inputElem.title = CityCode;
    inputElem.value = value;
    inputElem.blur();
    hideCitiesDiv();
   
}

function hideCitiesDiv()
{
    var citiesElem = document.getElementById("Cities");
    citiesElem.style.display = "none";
 
     citiesElem.innerText = "";
  
    currentCityIndex = null;
   
}

function keyboardFunc(e,id)
{
    
    var keynum;
    var keychar;
    var numcheck;
    if(window.event) // IE
      {
        keynum = e.keyCode;
      }
    else if(e.which) // Netscape/Firefox/Opera
      {
        keynum = e.which;
      }
    switch(keynum)
    {
    //enter
        case 13:
            
            if(currentCityIndex)
            {
                var elem = document.getElementById(currentCityIndex);

                citySelected(elem.innerHTML, id, elem.title);
                doSearch();
            }
        break;
        //key up
        case 38:
            
            if(currentCityIndex)
            {
                var num = new Number(currentCityIndex.slice(3));
                
                if( num > 0 )
                {
                    lowlightCity(currentCityIndex);
                    highlightCity("li_" + (--num));
                }
            }
            
        break;
        //key down
        case 40:
             
            if(currentCityIndex)
            {
           
                var num = new Number(currentCityIndex.slice(3));
                var citiesElem = document.getElementById("Cities");
                if( num < citiesElem.childNodes.length-1 )
                {
                    lowlightCity(currentCityIndex);
                    highlightCity("li_" + (++num));
                }
                else
                {
                    lowlightCity(currentCityIndex);
                    highlightCity("li_0");
                }
            }
            else
            {
                highlightCity("li_0");
            }
           
        break;
        default:
        break;
    }
    
}

function findElementCoords(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) 
	{
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) 
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}
/*End Functions For Cities Ajax */

//*************************************************************
/* VALIDATION  */


function ValidateInput(objToValidate)
    {
       
        var isValid = true;
       var strErrorMessage;
       var strRegExp;
       //Email 
   
      if(objToValidate.getAttribute("email")!= null)
      {
        strRegExp = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
        if(CheckValidation(objToValidate,strRegExp) == false)
        {
          
          isValid = false;   
        }
      }
      //password - exacty 6 english alfa numeric
      if(objToValidate.getAttribute("pwd")!= null)
      {
        strRegExp = /^[0-9a-zA-Z]{6,6}/; 
        if(CheckValidation(objToValidate,strRegExp) == false)
        {
         
          isValid = false;   
        }
      }
      //max length
      if(objToValidate.getAttribute("MaxLen") != null)
      {
      
        if(trim(objToValidate.value).length > Number(objToValidate.getAttribute("MaxLen")))
        {
       
         
          isValid = false;   
        }
      }
      //min length
      if(objToValidate.getAttribute("MinLen") != null)
      {
      
        if(trim(objToValidate.value).length < Number(objToValidate.getAttribute("MinLen")))
        {
       
         
          isValid = false;   
        }
      }
      //English and  Numbers Only
      if(objToValidate.getAttribute("Eng")!= null)
      {
        strRegExp = /^[a-zA-Z0-9 -]+$/; 
        if(CheckValidation(objToValidate,strRegExp) == false)
        {
         
          isValid = false;   
        }
      }
      //Hebrew and Numbers Only
      if(objToValidate.getAttribute("Heb")!= null)
      {
        strRegExp = /^[א-ת0-9 -]+$/; 
        if(CheckValidation(objToValidate,strRegExp) == false)
        {
          
          isValid = false;   
        }
      }
      if(objToValidate.getAttribute("Alpha")!= null)
      {
        strRegExp = /^[א-ת0-9a-zA-Z -]+$/; 
        if(CheckValidation(objToValidate,strRegExp) == false)
        {
          
          isValid = false;   
        }
      }
      
      if(objToValidate.getAttribute("MyRegEx")!= null)
      {
        strRegExp =objToValidate.getAttribute("MyRegEx");
        
        
        if(CheckValidation(objToValidate,eval(strRegExp)) == false)
        {
           isValid = false;   
        }
      }
      

      //handle errors
      if(isValid == true)
      {
      	if(objToValidate.getAttribute("ErrObjId") != null)
        {
            if(document.getElementById(objToValidate.getAttribute("ErrObjId"))!=null)
            {
              var browserCheck = (document.all) ? 1 : 0; 
        
              if( browserCheck > 0 )  
               {
                document.getElementById(objToValidate.getAttribute("ErrObjId")).innerText = '';
               }
               else
               {
                document.getElementById(objToValidate.getAttribute("ErrObjId")).textContent = '';
               }
                document.getElementById(objToValidate.getAttribute("ErrObjId")).style.display = 'none';
           }
        }
   
        return true;
      }
      //there were Errors
      if(objToValidate.getAttribute("alert")!=null && objToValidate.getAttribute("strErr")!=null )
      {
        alert(objToValidate.getAttribute("strErr"));
      }
      else
      {
       
        if(objToValidate.getAttribute("ErrObjId")!=null && objToValidate.getAttribute("strErr")!=null)
        {
            if(document.getElementById(objToValidate.getAttribute("ErrObjId"))!=null)
            {
               var message = objToValidate.getAttribute("strErr");
             var browserCheck = (document.all) ? 1 : 0; 
        
              if( browserCheck > 0 )  
               {
                document.getElementById(objToValidate.getAttribute("ErrObjId")).innerText = message;
               }
               else
               {
                document.getElementById(objToValidate.getAttribute("ErrObjId")).textContent = message;
               }
           
                document.getElementById(objToValidate.getAttribute("ErrObjId")).style.display = 'block';
           }
        }
      }
      
    }//end function 
    
    function CheckValidation(InputObj,strRegExPattern)
    {
        var vRegEx = strRegExPattern;
        if(vRegEx.test(InputObj.value) == false)
        {
           
            return false;
        }
        return true;
    }
/* END Validation */
function createdSearchForm(containerId,formName, formAttributes,inputsAttributes, submitName, clickSubmitBtn) {
    debugger;
    // set the form attributes
    var frm = document.createElement('form');		
    frm.setAttribute("name",formName);    	
    var arrFormAttributes = formAttributes.split("$");
    var nameVal, i, valFormAtt;
    for(i=0; i<arrFormAttributes.length; i++)
    {
	    nameVal = arrFormAttributes[i].split("=");
	    valFormAtt = arrFormAttributes[i].substring(nameVal[0].length+1,arrFormAttributes[i].length)
	    frm.setAttribute(nameVal[0], valFormAtt);
    }
    frm.setAttribute("method", "post");
    // set the inputs attributes
    var arrInputsAttributes = inputsAttributes.split("$");
    var inputHidden;
    for(i=0; i<arrInputsAttributes.length; i++)
    {
	    nameVal = arrInputsAttributes[i].split("=");
        inputHidden = document.createElement("input");		
        inputHidden.setAttribute("name",nameVal[0]);
	    inputHidden.setAttribute("type", "hidden");
	    var val1 = arrInputsAttributes[i].substring(nameVal[0].length+1,arrInputsAttributes[i].length);
	    inputHidden.setAttribute("value", val1);
	    frm.appendChild(inputHidden);		
    }

    // set the submit button
    var submitBtn = document.createElement("input");
    submitBtn.setAttribute("name", submitName);
    submitBtn.setAttribute("type", "submit");
    submitBtn.setAttribute("value", "");
    frm.appendChild(submitBtn);
	
    // add the form to the document
    var contId = document.getElementById(containerId);
    if(contId == null)
	    {
	        document.body.appendChild(frm);
	    }
    else
        {
	        contId.appendChild(frm);
	    }
	
    // submit the form
    if(clickSubmitBtn == true)
    {
       submitBtn.click();	
    }
    else
	    frm.submit();
	    
    // remove the form
    if (frm.parentNode)
    {
        frm.parentNode.removeChild(frm);
    }
}

/** added by linoy **/
/***********************************************************************************************************************/

/******************************    Add Items to folders    ****************************/

/**************        public variables        *************************/
var cpLinkItem = null;
var cpTitleItem = null;
var cpWebId = null;
var cpListId = null;
var cpItemId = null;
var cpActionType = null;

var cpContactId = null;
var cpSerachItemId = null;

/*************************    GetItemFromList    ************************/

function GetItemFromList(WebId, ListId, ItemId, ItemTitle, ItemLink, elementId) 
{
    
    var addItemLayer = document.getElementById('AddItemLayer');    
    var icon = document.getElementById(elementId);
    var inputCoords = getAbsolutePosition(icon);

    //Determine the PopUp Window Coordination
    if (addItemLayer != null && addItemLayer.style.display == 'none') 
    {
        addItemLayer.style.display = '';
        addItemLayer.style.position = "absolute";
        var coorLeft = inputCoords.x - 250;
        addItemLayer.style.left = coorLeft + "px";
        var coorTop = inputCoords.y + 60
        addItemLayer.style.top = coorTop + "px";

    }

    cpWebId = WebId;
    cpListId = ListId;
    cpItemId = ItemId;
    cpLinkItem = ItemLink;
    cpTitleItem = ItemTitle;

    cpActionType = "AddItem";

}

/*************************    GetContactDetails  ************************/
function GetContactDetails(contactId, element) 
{

    var addItemLayer = document.getElementById('AddItemLayer');
    
    //hide "note text" in PopUp layer
    var noteTxt = document.getElementById("txtUserNote");
    var noteLbl = document.getElementById("lblUserNote");
    noteLbl.style.display = 'none';
    noteTxt.style.display = 'none';
   
   
    var inputCoords = getAbsolutePosition(element);

    //Determine the PopUp Window Coordination
    if (addItemLayer != null && addItemLayer.style.display == 'none') {
        addItemLayer.style.display = '';
        addItemLayer.style.position = "absolute";
        var coorLeft = inputCoords.x - 280;
        addItemLayer.style.left = coorLeft + "px";
        var coorTop = inputCoords.y + 40
        addItemLayer.style.top = coorTop + "px";

    }
    
    cpContactId = contactId;
    cpActionType = "AddContact";
}

/*************************    GetSearchQueryDetails  **************************/
var cpKeyWord = null;
var cpResultNumber = null;
var cpSearchTitle = null;
var cpSearchLink = null;
var cpSearchType = null;
var cpScopes = null;
var cpMateTagName = null;

function GetSearchQueryDetails(keyWord, resultNumber, searchTitle, searchType, sScopes, metaTagName, element) 
{
   
    var addItemLayer = document.getElementById('AddItemLayer');
    
    //hide "note text" in PopUp layer
    var noteTxt = document.getElementById("txtUserNote");
    var noteLbl = document.getElementById("lblUserNote");
    noteLbl.style.display = 'none';
    noteTxt.style.display = 'none';

    var inputCoords = getAbsolutePosition(element);

    //Determine the PopUp Window Coordination
    if (addItemLayer != null && addItemLayer.style.display == 'none') {
        addItemLayer.style.display = '';
        addItemLayer.style.position = "absolute";
        var coorLeft = inputCoords.x + 50;
        addItemLayer.style.left = coorLeft + "px";
        var coorTop = inputCoords.y + 40
        addItemLayer.style.top = coorTop + "px";

    }

    cpKeyWord = keyWord;
    cpResultNumber = resultNumber;
    cpSearchTitle = searchTitle;
    cpSearchType = searchType;
    cpScopes = sScopes;
    cpMateTagName = metaTagName;

    cpActionType = "AddSearchQuery";

}

/*************************    GetSearchQueryDetails  **************************/
function GetSearchItem( searchTitle, searchLink, element) 
{
   
    var addItemLayer = document.getElementById('AddItemLayer');

    //show "note text" in PopUp layer
    var noteTxt = document.getElementById("txtUserNote");
    var noteLbl = document.getElementById("lblUserNote");
    noteLbl.style.display = '';
    noteTxt.style.display = '';
    
    var inputCoords = getAbsolutePosition(element);

    //Determine the PopUp Window Coordination
    if (addItemLayer != null && addItemLayer.style.display == 'none') {
        addItemLayer.style.display = '';
        addItemLayer.style.position = "absolute";
        var coorLeft = inputCoords.x - 280;
        addItemLayer.style.left = coorLeft + "px";
        var coorTop = inputCoords.y + 40
        addItemLayer.style.top = coorTop + "px";

    }

    cpLinkItem = searchTitle;
    cpTitleItem = searchLink;
    
    cpActionType = "AddItem";
}

/**********************    end of Add Items to folders    **********************/
/************************************* getAbsolutePosition **************************************/
/*** get absolute position of element ***/
function getAbsolutePosition(element) {

    var r = { x: element.offsetLeft, y: element.offsetTop };
    if (element.offsetParent) {
        var tmp = getAbsolutePosition(element.offsetParent);
        r.x += tmp.x;
        r.y += tmp.y;
    }
    return r;

}
 
/***********************    createdSearchForm       ****************************/
/** end added by linoy **/

function createdSearchForm(containerId, formName, formAttributes, inputsAttributes, submitName, clickSubmitBtn) {

    // set the form attributes
    var frm = document.createElement('form');
    frm.setAttribute("name", formName);
    var arrFormAttributes = formAttributes.split("$");
    var nameVal, i, valFormAtt;
    for (i = 0; i < arrFormAttributes.length; i++) {
        nameVal = arrFormAttributes[i].split("=");
        valFormAtt = arrFormAttributes[i].substring(nameVal[0].length + 1, arrFormAttributes[i].length)
        frm.setAttribute(nameVal[0], valFormAtt);
    }
    frm.setAttribute("method", "post");
    // set the inputs attributes
    var arrInputsAttributes = inputsAttributes.split("$");
    var inputHidden;
    for (i = 0; i < arrInputsAttributes.length; i++) {
        nameVal = arrInputsAttributes[i].split("=");
        inputHidden = document.createElement("input");
        inputHidden.setAttribute("name", nameVal[0]);
        inputHidden.setAttribute("type", "hidden");
        var val1 = arrInputsAttributes[i].substring(nameVal[0].length + 1, arrInputsAttributes[i].length);
        inputHidden.setAttribute("value", val1);
        frm.appendChild(inputHidden);
    }

    // set the submit button
    var submitBtn = document.createElement("input");
    submitBtn.setAttribute("name", submitName);
    submitBtn.setAttribute("type", "submit");
    submitBtn.setAttribute("value", "");
    frm.appendChild(submitBtn);

    // add the form to the document
    var contId = document.getElementById(containerId);
    if (contId == null) {
        document.body.appendChild(frm);
    }
    else {
        contId.appendChild(frm);
    }

    // submit the form
    if (clickSubmitBtn == true) {
        submitBtn.click();
    }
    else
        frm.submit();

    // remove the form
    if (frm.parentNode) {
        frm.parentNode.removeChild(frm);
    }
}

function CP_GoToPage(url) 
{   
    location.href = url;
    
}

$(document).ready(function(){
    $("table[id$=TopNavigationMenu] table:first").hide()
})