// This script is a part of Niversoft's Spid skin
// Copyright © 2004 Niversoft idées logicielles

function getBase64Code(str,pos)
{var code=str.charCodeAt(pos);if((code>=65)&&(code<=90)){return code-65;}
if((code>=97)&&(code<=122)){return code-71;}
if((code>=48)&&(code<=57)){return code+4;}
if(code==43){return 62;}
if(code==47){return 63;}
return 0;}
function decodeBase64(str)
{var txt="";for(var i=0;i<str.length;i+=4)
{var chs=[getBase64Code(str,i+0),getBase64Code(str,i+1),getBase64Code(str,i+2),getBase64Code(str,i+3)];var tot0=((chs[0]<<2)+(chs[1]>>4))%256;var tot1=((chs[1]<<4)+(chs[2]>>2))%256;var tot2=((chs[2]<<6)+(chs[3]>>0))%256;txt+=(tot0>0?String.fromCharCode(tot0):"")+(tot1>0?String.fromCharCode(tot1):"")+(tot2>0?String.fromCharCode(tot2):"");}
return txt;}
function getBase64Encode(code)
{if(code<26){return String.fromCharCode(code+65);}
if(code<52){return String.fromCharCode(code+71);}
if(code<62){return String.fromCharCode(code-4);}
if(code==62){return String.fromCharCode(43);}
if(code==63){return String.fromCharCode(47);}
return 0;}
function encodeBase64(str)
{var txt="";for(var i=0;i<str.length;i+=3)
{var chs=[str.charCodeAt(i),(str.length>i+1)?str.charCodeAt(i+1):-1,(str.length>i+2)?str.charCodeAt(i+2):-1];var tot0=(chs[0]>>2)%64;var tot1=(((chs[0]<<6)>>2)+(chs[1]>0?(chs[1]>>4):0))%64;var tot2=(((chs[1]<<6)>>4)+(chs[2]>0?(chs[2]>>6):0))%64;var tot3=((chs[2]<<2)>>2)%64;txt+=getBase64Encode(tot0);txt+=getBase64Encode(tot1);txt+=(chs[1]>0)?getBase64Encode(tot2):"=";txt+=(chs[2]>0)?getBase64Encode(tot3):"=";}
return txt;}
function decodeUTF7(str)
{if(str.indexOf("&")<0){return str;}
var matches=str.match(/&[^-]*-/g);for(var i=0;i<matches.length;i+=1)
{var txt=matches[i].replace(/&amp;/gi,"&");str=str.replace(new RegExp(matches[i]),decodeBase64(txt.substr(1,txt.length-2)));}
return str;}
function decodeUTF8(str)
{var out="";for(var i=0;i<str.length;i+=1)
{var cc=str.charCodeAt(i);if(cc<0x7f)
{out+=String.fromCharCode(cc);}
else
{var tmp=cc;var byten=0;while(tmp&0x80)
{byten+=1;tmp<<=1;}
cc&=0xFF>>(byten+1);for(var b=1;b<byten;b+=1)
{cc=(cc<<6)|(str.charCodeAt(i+b)&0x3F);}
out+=String.fromCharCode(cc);i+=b-1;}}
return out;}
function createCookie(name,value,days)
{if(!days){days=30;}
var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();var thecookie=name+"="+encodeBase64(value.toString())+expires+"; path=/; domain="+window.location.hostname;document.cookie=thecookie;}
function readCookie(name)
{var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i+=1)
{var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1,c.length);}
if(!c.indexOf(nameEQ)){return decodeBase64(c.substring(nameEQ.length,c.length));}}
return null;}
function eraseCookie(name)
{createCookie(name,"",-1);}
var testcookie='SSCookieTest=valid';document.cookie=testcookie;var cookiesEnabled=document.cookie.indexOf(testcookie)!=-1;document.cookie=testcookie+';expires='+new Date(0).toGMTString();
