function PreserveValues()
{
    try
    {
        document.getElementById("ctl03_ctl05_hPosition").value = document.getElementById("ctl03_ctl05_txtPosition").value;
    }
    catch(err)
    {
        document.getElementById("ctl03_ctl05_hPosition").value = "";
    }
    try
    {
        document.getElementById("ctl03_ctl05_hTelephone").value = document.getElementById("ctl03_ctl05_txtTelephone").value;
    }
    catch(err)
    {
        document.getElementById("ctl03_ctl05_hTelephone").value = "";
    }
    try
    {
        document.getElementById("ctl03_ctl05_hCPR").value = document.getElementById("ctl03_ctl05_txtCPR").value;
    }
    catch(err)
    {
        document.getElementById("ctl03_ctl05_hCPR").value = "";
    }
    try
    {
        document.getElementById("ctl03_ctl05_hNotes").value = document.getElementById("ctl03_ctl05_txtNotes").value;
    }
    catch(err)
    {
        document.getElementById("ctl03_ctl05_hNotes").value = "";
    }
    try
    {
    len = document.forms[0].ctl03$ctl05$rbOption.length
    }
    catch(err)
    {
    len=0;
    }
    if(len>0)
    {
        for (i = 0; i <len; i++)
         {
            if (document.forms[0].ctl03$ctl05$rbOption[i].checked) 
            {
                document.getElementById("ctl03_ctl05_hOption").value = document.forms[0].ctl03$ctl05$rbOption[i].value;
            }
         }
    }

 }


function Print()
{
    var qs;
    var URL;
    
    if(window.location.toString().indexOf("?") < 0)
    {
       URL =  window.location.toString()+"?lg=print";
    }
    else
    {
        URL = window.location.toString()+"&lg=print";
    }
    window.open (URL,"mywindow","status=1,toolbar=1");
    //window.location = URL;
}

function changeKalenderFilter()
{
    qs = "?p="+ document.getElementById('ddProfileFilter').options[document.getElementById('ddProfileFilter').selectedIndex].value+"&t="+document.getElementById('ddEventType').options[document.getElementById('ddEventType').selectedIndex].value+"&r=";
    if(document.getElementById('ddRegion').options[document.getElementById('ddRegion').selectedIndex].value != '0')
    {
        qs= qs+document.getElementById('ddRegion').options[document.getElementById('ddRegion').selectedIndex].value;
    }
    locationUrl = window.location.toString();
    url = locationUrl.substring(0,locationUrl.indexOf("?"))+qs;
    window.location = url;
}

function Show(Id)
{
   
    var founded = false; 
    if((Id != "allevents") && (Id != "allwerecommend")&& (Id != "allvisitorsrecommend"))
    {
     selectedValue = document.getElementById(Id).options[document.getElementById(Id).selectedIndex].value;
    }
    else 
    {
        if(Id == "allevents")
        {
            selectedValue = "0";
        }
        else
        {
            if(Id == "allwerecommend")
            {
                selectedValue = "all";
            }
            else
            {
                if(Id == "allvisitorsrecommend")
                {
                    selectedValue = "all";
                }
            }
        }
    }
    var newQSParam = "";
    
    var str = window.location.toString();
        
    try
    {
        oldQueryString = str.split("?")[1].toString();
    }
    catch(ex)
    {
        oldQueryString = "";
    }        
     
     
    var arrQS = oldQueryString.split("&");
    
    var QS = "";
    switch(Id.toString())
    {
        case "allwerecommend" : newQSParam = "weid" ;
        break;
        case "ddFrontpageWeRecommend" : newQSParam = "weid" ;
        break;
        case "allvisitorsrecommend" : newQSParam = "viid";
        break;
        case "ddFrontpageVisitorsRecommend" : newQSParam = "viid";
        break;
        case "allevents" :newQSParam = "id";
        break;
        case "ddEventsGroup": newQSParam = "id";
        break;
        case "ddRigthTWeRecommend" :newQSParam="rwrID";
        break;
        case "ddRigthTVisitorRecommend": newQSParam="rvrID";
        break;
        case "ddLeftTWeRecommend" :newQSParam="lwrID";
        break;
        case "ddLeftTVisitorRecommend" :newQSParam="lvrID";
        break;
        case "ddProfileFilter" : newQSParam="p";
        break;
        case "ddEventType" : newQSParam="t";
        break;
        case "ddRegion":newQSParam="r";
        break;
    }
     
    if(oldQueryString =="")
     {
        window.location = str.split("?")[0].toString()+"?"+newQSParam+"="+selectedValue;
        return;
     }
     
    var j = 0;
    for(j = 0; j < arrQS.length; j++)
    {
     var group = arrQS[j].toString().split("=");
            
      if(group[0].toString() == newQSParam)
      {
        if(group[1].toString() != selectedValue)
          {
            arrQS[j] = newQSParam+"="+selectedValue;
          } 
          founded = true; 
      }
      
    }
    if(founded == false)
    {
       QS =  arrQS.join("&")+"&"+newQSParam+"="+selectedValue;
    }
    else
    
    {
       QS =  arrQS.join("&");
    }
    
    window.location = str.split("?")[0].toString()+"?"+QS;
}

function changeProfile(nbOfDays)
{

profile             = document.getElementById('ddProfile').options[document.getElementById('ddProfile').selectedIndex].value;
if(nbOfDays < 0)
{
    profile         = 'none';
    nbOfDays        = 190;
}

if(document.getElementById('profileSave').checked == true)
{
    document.cookie     = createCookie('profile',profile,nbOfDays);
}
else
{
    if(profile == 'none')
    {
        document.cookie     = createCookie('profile',profile,nbOfDays);
    }
    else
    {
        document.cookie     = createCookie('profile',profile,0);
    }
}
//alert(createCookie('profile',profile,nbOfDays));
var redirectURL     = window.location.toString();
window.location     = redirectURL; 
}

function createCookie(name,value,expires)
{

var today = new Date();
today.setTime( today.getTime() );
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
var coockieString = name + "=" +escape( value ) +( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ";path=/";
return coockieString;
}
function ReadCookie(cookieName) 
{
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName == "") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1 == -1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
