var theAlfaChar="alt_"; 
var fullMonthsArray_lt    = [ "sausio" , "vasario" , "kovo" , "balandþio" , "geguþës", "Birþelio", "Liepos", "rugpjûèio", "rugsëjo" , "spalio", "lapkrièio", "gruodþio" ];
var abrMonthsArray_lt    = [ "sausio" , "vasario" , "kovo" , "balandþio" , "geguþës", "Birþelio", "Liepos", "rugpjûèio", "rugsëjo" , "spalio", "lapkrièio", "gruodþio" ];
var abrDaysArray_lt    = [ "S" , "P" , "A" , "T" , "K", "P"  , "Ð" ];
var fullDaysArray_lt    = [ "Sekamdienis" , "Pirmadienis" , "Antradienis" , "Treèiadienis" , "Ketvirtadienis" , "Penktadienis", "Ðeðtadienis"];

var fullMonthsArray_ru    = [ "Январь", "Февраль","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"];
var abrMonthsArray_ru    = [ "ÿíó", "ôåâ", "Ìàð", "Àëð", "Ìàé", "Þíè", "Þëè", "Àâã", "Ñåï", "Îêò", "Íîå", "Äåê"];
var fullDaysArray_ru= ["Íåäåëÿ" ,"Ïîíåäåëíèê" ,"Âòîðíèê","Ñðÿäà","×åòâúðòúê","Ïÿòíèê","Ñîáîòà"];
var abrDaysArray_ru    = [ "Í" , "Ï" , "Â" , "Ñ" , "×", "Ï"  , "Ñ" ];

var abrMonthsArray_uk    = [ "Jan" , "Feb" , "Mar" , "Apr" , "May", "Jun", "Jul", "Aug", "Sep" , "Oct", "Nov", "Dec" ];
var fullMonthsArray_uk    = [ "January" , "February" , "March" , "April" , "May", "June", "July", "August", "September" , "October", "November", "December" ];
var abrDaysArray_uk    = [ "Sun" , "Mon" , "Tue" , "Wed" , "Thu", "Fri"  , "Sat" ];
var fullDaysArray_uk    = [ "Sunday" , "Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday", "Saturday"];
var titles_uk = [ 'This Morning','Today' , 'This Evening', 'Tm.night' , 'Tm. Morn' , 'Tm. Day' ];
var titles_lt = [ 'Ši Ryt','Šiandien' , 'Ši vakar','Šia nakt.' , 'Rytoj Ryt' , 'Rytoj diena.' ];
var titles_ru = [ 'утро','день' , 'вечер' ,'ночь' , 'зв.утром' , 'зв.день ' ];

var titles = titles_uk;



var hit_online_now;
var hit_total_unq;
var hit_total_vstrs;

var subMenuObj;
var isMSIE;
var mx;
var my;
var dx;
var dy;
var lastMenuIdx=null;
var mouseIsDown;
var global_xoffset = 0;
 var hCursor = "pointer";

var x=document.getElementsByTagName("meta")[2];
try{
    if( x.content.indexOf( "windows-1257" ) != -1 ){
        currentCountry = "lt";
        }
    if( x.content.indexOf(  "windows-1251") != -1 ){
        currentCountry = "ru";
        }
    if( x.content.indexOf(  "windows-1252") != -1 ){
        currentCountry = "uk";
        }
    }
    catch(er){}
                        
if (window.ActiveXObject){
        var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
        var xmlLibDoc=new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async=false;
    xmlLibDoc.async=false;
    isMSIE=true;
        }
      else if (document.implementation && document.implementation.createDocument){
          isMSIE=false;
         xmlDoc=document.implementation.createDocument("","",null)
         xmlLibDoc=document.implementation.createDocument("","",null)
          }
          

/**
*
*  MD5 (Message-Digest Algorithm)
*  http://www.webtoolkit.info/
*
**/
 
var MD5 = function (string) {
 
	function RotateLeft(lValue, iShiftBits) {
		return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
	}
 
	function AddUnsigned(lX,lY) {
		var lX4,lY4,lX8,lY8,lResult;
		lX8 = (lX & 0x80000000);
		lY8 = (lY & 0x80000000);
		lX4 = (lX & 0x40000000);
		lY4 = (lY & 0x40000000);
		lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
		if (lX4 & lY4) {
			return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
		}
		if (lX4 | lY4) {
			if (lResult & 0x40000000) {
				return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
			} else {
				return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
			}
		} else {
			return (lResult ^ lX8 ^ lY8);
		}
 	}
 
 	function F(x,y,z) { return (x & y) | ((~x) & z); }
 	function G(x,y,z) { return (x & z) | (y & (~z)); }
 	function H(x,y,z) { return (x ^ y ^ z); }
	function I(x,y,z) { return (y ^ (x | (~z))); }
 
	function FF(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function GG(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function HH(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function II(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function ConvertToWordArray(string) {
		var lWordCount;
		var lMessageLength = string.length;
		var lNumberOfWords_temp1=lMessageLength + 8;
		var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
		var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
		var lWordArray=Array(lNumberOfWords-1);
		var lBytePosition = 0;
		var lByteCount = 0;
		while ( lByteCount < lMessageLength ) {
			lWordCount = (lByteCount-(lByteCount % 4))/4;
			lBytePosition = (lByteCount % 4)*8;
			lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
			lByteCount++;
		}
		lWordCount = (lByteCount-(lByteCount % 4))/4;
		lBytePosition = (lByteCount % 4)*8;
		lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
		lWordArray[lNumberOfWords-2] = lMessageLength<<3;
		lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
		return lWordArray;
	};
 
	function WordToHex(lValue) {
		var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
		for (lCount = 0;lCount<=3;lCount++) {
			lByte = (lValue>>>(lCount*8)) & 255;
			WordToHexValue_temp = "0" + lByte.toString(16);
			WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
		}
		return WordToHexValue;
	};
 
	function Utf8Encode(string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	};
 
	var x=Array();
	var k,AA,BB,CC,DD,a,b,c,d;
	var S11=7, S12=12, S13=17, S14=22;
	var S21=5, S22=9 , S23=14, S24=20;
	var S31=4, S32=11, S33=16, S34=23;
	var S41=6, S42=10, S43=15, S44=21;
 
	string = Utf8Encode(string);
 
	x = ConvertToWordArray(string);
 
	a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
 
	for (k=0;k<x.length;k+=16) {
		AA=a; BB=b; CC=c; DD=d;
		a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
		d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
		c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
		b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
		a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
		d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
		c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
		b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
		a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
		d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
		c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
		b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
		a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
		d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
		c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
		b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
		a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
		d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
		c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
		b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
		a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
		d=GG(d,a,b,c,x[k+10],S22,0x2441453);
		c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
		b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
		a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
		d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
		c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
		b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
		a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
		d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
		c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
		b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
		a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
		d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
		c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
		b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
		a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
		d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
		c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
		b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
		a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
		d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
		c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
		b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
		a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
		d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
		c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
		b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
		a=II(a,b,c,d,x[k+0], S41,0xF4292244);
		d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
		c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
		b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
		a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
		d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
		c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
		b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
		a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
		d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
		c=II(c,d,a,b,x[k+6], S43,0xA3014314);
		b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
		a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
		d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
		c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
		b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
		a=AddUnsigned(a,AA);
		b=AddUnsigned(b,BB);
		c=AddUnsigned(c,CC);
		d=AddUnsigned(d,DD);
	}
 
	var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
 
	return temp.toLowerCase();
};


downloadFiles = function(file_names,zip_name ){

    tmpScriptFrame0=document.getElementById("dataFrame");
    if((typeof zip_name)!='undefined'){

        tmpScriptFrame0.src='home/zip_down.php?temp_p=./documents/&files='+file_names+'&zip=' + zip_name;        
        }
        else{
        
            tmpScriptFrame0.src='home/download_mgr.php?temp_p=./documents/&file='+file_names;                
            }
    }
    
function getInnerText(o){
    var txt='';
    for(var i=0; i<o.childNodes.length; i++){
        switch(o.childNodes[i].nodeType){
            case 1 : txt +=getInnerText(o.childNodes[i]); break
            case 3 : txt +=o.childNodes[i].nodeValue; break
            case 8 : txt +="\n"; break
            }
        }
    return txt;
    }
counterRefresh = function(){

    var hit_cntr_data  = getInnerText( frames[ "counterFrame" ].document.documentElement );    

    var tmpAr = hit_cntr_data.split(":");
    
    hit_online_now=tmpAr[0];
    hit_total_unq=tmpAr[1];
    hit_total_vstrs=tmpAr[2];

    }
   

init = function(){
try{
	$(".fancy_group").fancybox({
		     imgPath:"home/images/",
		     imgGoLeft:"gel_orange_left.png",
		     imgGoRight:"gel_orange_right.png",
		     titlePos:{top:30,left:100},
		     closeButtonImage:"fancy_close_orange.png",
		     titleBgPrefix:"gel_title_orange_"
		    });
}catch(er){};
try{  
$("."+theAlfaChar.substr(0,4)+"content").css({position:"absolute",top:"-1500px"})   
}catch(er){};
if ($.browser.msie && $.browser.version < 6.9999) {

    hCursor = "hand";         
}
    
$('#navigationPage').css({display:"block"})               
$('.main_content').css({display:"block"})  
                       
 
var tmp_page_name = page_name;   
 
var pgTag = 'span';
if(  $('#currentFormInstance').attr('pageName') != null ){
    tmp_page_name = 'currentFormInstance';  
    
    }
var vOffs = 0;
try{
    vOffs = Number( $('#' + tmp_page_name).children().get(1).getAttribute("_y")) - 35 ;          
    }
    catch(er){}
 
        
        if( $('#' + page_name).attr('pg_fullscreen') == "TRUE" ){

            var bgH = screen.availHeight;
            var bgW = screen.availWidth;
            if( bgW <= 1300 ){
            
               // bgH = document.body.scrollHeight + vOffs; 
                bgW = null; 
                }
            $('#background_' + page_name + '_0').find('#bgDiv').css({height: bgH + "px"});
            if(bgW != null ){
                $('#background_' + page_name + '_0').find('#bgDiv').css({width:bgW + "px"});
                }       
            $('#background_' + page_name + '_0').css({display:"block"}).appendTo('body');  //height:document.body.scrollHeight
           
            }       
        
           else if( $('#' + overlay_name).attr('pg_fullscreen') == "TRUE" ){

                var bgH = screen.availHeight;
                var bgW = screen.availWidth;
                if( bgW <= 1300 ){
                
                   // bgH = document.body.scrollHeight + vOffs; 
                    bgW = null; 
                    }
                $('#background_' + overlay_name + '_0').find('#bgDiv').css({height: bgH + "px"});
                if(bgW != null ){
                    $('#background_' + overlay_name + '_0').find('#bgDiv').css({width:bgW + "px"});
                    }       
                $('#background_' + overlay_name + '_0').css({display:"block"}).appendTo('body');  //height:document.body.scrollHeight
               
                } 
                        
                else{
                   
                    $('#background_' + page_name + '_0').css({display:"block"} ); //,left:"50%",marginLeft:"-" + 0.5*( Number($('#'  + tmp_page_name).attr('originalWidth') ) + 22 ) + "px"}); //.appendTo('body');
                    }
 

        
     var bgLeft = (parseInt($('div[isBg="yes"]').css("left"))  );
     if( isNaN(bgLeft ))   {
        bgLeft = 0;
        } 
     if(mainAlign == "CENTER"){
    
        $('#footerDivElement').css({display:"block",top:$('.footerDivElement:last').css('top'),left:(bgLeft -33) + "px"}); 
        $('div[isBg="yes"]').css({display:"block",left:parseInt($('div[isBg="yes"]').css("left"))  });
         
        if($('#' + tmp_page_name).attr('pg_fullscreen') == "FALSE"){
            $('#' + tmp_page_name).css({display:"block",left:"50%",marginLeft:"-" + 0.5*Number(screenWidth)  + "px"}); //.appendTo('body');    
            }
            else{
                $('#' + tmp_page_name).css({display:"block",top:"-" + vOffs + "px",left:"50%",marginLeft: 0.5*(Number($('#'  + tmp_page_name).attr('extremeLeft') ) + Number(screenWidth) - 2*(Number($('#'  + tmp_page_name).attr('extremeRight') )-Number($('#'  + tmp_page_name).attr('extremeLeft') )))+ "px"}).appendTo('body');      
                }
        
        $('#navigationPage').css({display:"block",left:"50%",marginLeft:"-" + 0.5*Number(screenWidth )  + "px"}).appendTo('body').appendTo('body');    
                  
        // $(pgTag + '#background_' + page_name + '_0').remove();
        }
        else{
            var footerPos = $('#'+overlay_name).find('.footerDivElement:last').css('top');
          //  if(footerPos==null){
            var footerPos2 = $('#'+page_name).find('.footerDivElement:last').css('top');     
         //      }
            if(footerPos2>footerPos){
                footerPos=footerPos2;
                };
            if($('#' +  overlay_name).next().css('top') != null && (footerPos == null || footerPos == "auto" || footerPos == "") && $('#' +  overlay_name).next().css('top') != "auto"){
                footerPos =  $('#' + overlay_name).next().css('top');
                }
            if(footerPos==null){
                footerPos =  $('.lastDiv:last').css('top');
             
               
                var tp = parseInt($('#background_' + page_name + '_0').next().next().css('top'));
                if(tp!=null && isNaN(tp)==false){
                   footerPos = ( parseInt(footerPos) + tp ) + "px";
                   }
                }       
     
            $('#footerDivElement').css({display:"block",top:footerPos,left:(bgLeft ) + "px"});  
               
            $('#' + page_name).css({display:"block"});      
            $('#' + tmp_page_name).css({display:"block"});
            $('#' + overlay_name).css({display:"block"});      
            }
    var m_m = document.getElementById("main_menu");
    mlm = 0
 
    switch(menu_effect){ 
        case "FOLLOW":
            
          $("#main_menu").menufx({
            fx: "backout",
            rightmargin: ( 0.5 * Number(mainSpacing) + Number( mlm )  ),
            padding:   0.5 * Number(mainSpacing) ,
            speed: 700,
            bgimage:  menu_effect_img,
            imageheight:  menu_effect_height,
            click: function(event, menuItem) {
                return false;
            }
             });
             
        break;
            
       }
if(isMSIE){
if(m_m!=null){
    m_m.style.marginLeft = "3px";
};
  // $('#main_menu').appendTo($('#navigationPage' )) ;
   
    $('div[isBg="yes"]').css({left:(parseInt($('div[isBg="yes"]').css("left")) -3) + "px"}).appendTo($('#' + tmp_page_name));
    $('#navigationPage').find('div[isBg="yes"]').remove();
    }
    
var objects = new Object();
var alltags=document.body.innerHTML;
var obsAr = alltags.split(' id=');
for(var j=1; j<obsAr.length;j++){
    var nm_end = obsAr[j].indexOf(' ');
    var id_name = obsAr[j].substr(0,nm_end);
    var nm_end2 = id_name.indexOf('>');
    if(nm_end2!=-1){
        nm_end=nm_end2;
        id_name = obsAr[j].substr(0,nm_end);
        }

    id_name=id_name.split('"').join('');

    var lst_str=obsAr[j-1].lastIndexOf("<");
    var lst_end=obsAr[j].indexOf("<");    
    var attrib_str = obsAr[j-1].substr(lst_str,obsAr[j-1].length)+ ' id="' + id_name + '" ' + obsAr[j].substring(nm_end,lst_end);
    attrib_str = attrib_str.split('; ').join(';');
    attrib_str = attrib_str.split(': ').join(':');
    attrib_str = attrib_str.split("( '").join("('");
    var tmpAr = attrib_str.split(' ');
    objects[id_name] = new Object();

    for(var k=1; k<tmpAr.length;k++){
        if( tmpAr[k].length>1 ){

            var tmpAr2 = tmpAr[k].split('="');
            if((typeof tmpAr2[1])!='undefined'){
                var tmpAr3=tmpAr2[1].split('"')
                objects[id_name][tmpAr2[0]] = tmpAr3[0];
                }
            }        
        }
    }

if( m_m != null){

for( var j = 0; j <  m_m.childNodes.length  ; j++){
    
    try{
        var mm = document.getElementById("mainMenu" + j);
    
    
        for( var t in objects["mainMenu" + j] ){
            
            //alert(t);
            var t1 = String(t);
            if( t1 != "style" ){
                mm[t1] = objects["mainMenu" + j][t1];
                }
            }
 
    mm["mainRolloverFontColor"] = toValidColor(mm["mainrolloverfontcolor"]);
    
    mm["menuBarFontColor"] = toValidColor(mm["menubarfontcolor"]);
    mm["background_color"] = toValidColor(mm["background_color"]);
    mm["highlight_color"] = toValidColor(mm["highlight_color"]);    
     if(mm.default_image != null ){
        mm.style.backgroundImage = "url(" + mm.default_image + ")";
        }   
        
    mm.onmouseover=function(){    
               
         if(this.hover_image != null ){
            this.style.backgroundImage = "url(" + this.hover_image + ")";
            }    
        if(    this.mainRolloverFontColor != undefined && this.mainRolloverFontColor != "NaN"){
            this.style.color= this.mainRolloverFontColor;
            }        

        if( this.unhilite == 1 ){
            try{    
                if(    this.menuBarFontColor !=undefined && this.menuBarFontColor !="NaN"){
                    eval(lastMenuItem).style.color= this.menuBarFontColor;
                    }    
                if( this.background_color!=undefined && this.background_color !="NaN"){
                    eval(lastMenuItem).style.backgroundColor=this.background_color;
                    }
                    else{
                        eval(lastMenuItem).style.backgroundColor='transparent';
                        }
                }catch(er){
                    if(    this.mainRolloverFontColor !=undefined && this.mainRolloverFontColor !="NaN"){
                        this.style.color= this.mainRolloverFontColor;
                        }
                    }
                }

        if( this.highlight_color !="NaN"){
            this.style.backgroundColor=this.highlight_color;
            }
            else{
    
                this.style.backgroundColor='transparent';
                }
            

        if(this.linktype=="subMenu"){

/*
            hideBaseMenu();
            var t_pos=parseInt(this.style.top);
            var l_pos=parseInt(this.style.left);
            if(menu_alignment.toUpperCase()=="VERTICAL"){
                l_pos=parseInt(this.style.left)  + parseInt(this.style.width);
                t_pos=parseInt(this.style.top)  - parseInt(this.style.height);
                }
                */
            drawSubMenu(this.indx ,   this.cntry ,    this.l_pos  ,  this.t_pos);
            }
            else{
                    hideSubMenu();
                    hideBaseMenu();
                    }                    
        try{    
            if(lastMenuItem.substr(0,8)==  "mainMenu"){
                var idx=Number(lastMenuItem.substr(8,lastMenuItem.length));
    
                navRoot.children[0].children[idx].style.backgroundColor=this.background_color;
                            
                navRoot.children[0].children[idx].style.color= menuBarFontColor;

                }
            }catch(er){}
    
        lastMenuItem = this;

        }
 
    mm.onmouseout=function(){
        
        if( this.unhilite == null || this.unhilite == 0 ){
             if(this.default_image != null ){
                this.style.backgroundImage = "url(" + this.default_image + ")";
                }
            this.style.color= this.menuBarFontColor;
        
            if( this.background_color!=undefined && this.background_color !="NaN"){
                this.style.backgroundColor=this.background_color;
                }
                else{
                    this.style.backgroundColor='transparent';
                    }
                }
        /*
        if(linktype !="subMenu"){
                hideSubMenu();
                hideBaseMenu();
                }
            */
        }
    mm.onmouseup=function(){        


        this.linklist = this.linklist + htmlExtension;
        hideSubMenu();
        hideBaseMenu();    
        if(this.linktype=="subMenu"){
            var t_pos=parseInt(this.style.top);
            var l_pos=parseInt(this.style.left);
            if(menu_alignment.toUpperCase()=="VERTICAL"){
                l_pos=parseInt(this.style.left)  + parseInt(this.style.width);
                t_pos=parseInt(this.style.top)  - parseInt(this.style.height);
                }
            drawSubMenu(this.indx , this.cntry , this.l_pos  , this.t_pos);
            }
            else{
                location = this.linklist;
                }
            }        
    mm.onmousedown=function(){    
                     if(this.press_image != null ){
                this.style.backgroundImage = "url(" + this.press_image + ")";
                }
        window.status = "Loading selected page.. Please wait.";
        if ( isMSIE ){
            this.style.cursor = "wait";
            }
            else{
                document.styleSheets[0].cssRules[0].style.cursor = 'wait';
                }
        }
        }
        catch(er){
         // alert(er);
        };    
                           
    }

   
}  

    
hideSubMenu=function(){
    try{
        subMenuObj.style.display='none';
        subMenuObj._visible=false;
        }
        catch(er){
            }
    }
    
drawSubMenu=function(idx , country , leftPos, topPos){

    subMenuObj = document.getElementById("sub_menu_" + idx );
    subMenuObj.style.display = 'block';
    var subs = subMenuObj.getElementsByTagName("li");

    for( var j = 0; j <  subs.length  ; j++){
        

        try{
        var sm = subs[j];
        
            if(!isMSIE){
                for( var attrib in sm.attributes ){
                    
                    if(attrib!="style"){
                        try{
                            sm[sm.attributes[attrib].name] = sm.attributes[attrib].value
                            }
                            catch(er){}

                        //alert("sm["+sm.attributes[attrib].name+"] =" + sm[sm.attributes[attrib].name]  );
                        }
                    }
                }


            sm["submenu_highlightcolor"] = toValidColor(sm["submenu_highlightcolor"]);
            sm["mainmenurollover"] = toValidColor(sm["mainmenurollover"]);

            sm["submenu_backcolor"] = toValidColor(sm["submenu_backcolor"]);
            sm["mainmenufontcolor"] = toValidColor(sm["mainmenufontcolor"]);
        
            sm.onclick=function(){
                if(this.linktype=="subMenu"){
                    //drawBaseMenu(indx , cntry , this.style.left  ,   this.style.top);
                    }
                    else{
                        hideSubMenu();
                        //hideBaseMenu();
                        location =  this.linklist + htmlExtension;
                        }
                }
            sm.onmouseover=function(){

                if(this.submenu_highlightcolor.substr(0 , 1)=="#"){
                    this.style.backgroundColor=this.submenu_highlightcolor;
                    this.style.color=toValidColor(this.mainmenurollover);
                    }
                /*
                if(linktype=="subMenu"){
                    drawBaseMenu(indx , cntry , this.style.left  ,  this.style.top);
                    }
                    else{
                            hideBaseMenu();
                            }
                            */
                }
            sm.onmouseout=function(){
                this.style.backgroundColor=this.submenu_backcolor;
                this.style.color=this.mainmenufontcolor;
                }
            }
            catch(er){}    

        }
    }
    
changeBackground = function (_width , _height, _backColor , bodyBackString, screenColor){    
    if(screenColor==null||screenColor==""||screenColor.toUpperCase()=="NONE"){
        screenColor='transparent';
        };
    document.body.style.backgroundColor=screenColor;
    if(bodyBackString !=undefined && bodyBackString.length>0){
 
        globalBackgroundProperties=bodyBackString.split(":");
        globalBackgroundImage=globalBackgroundProperties[0];
        if(globalBackgroundImage==undefined){
            globalBackgroundImage="";
            }
        globalBackgroundLeft=globalBackgroundProperties[1];
        if(globalBackgroundLeft==undefined){
            globalBackgroundLeft=0;
            }
        globalBackgroundTop=globalBackgroundProperties[2];
        if(globalBackgroundTop==undefined){
            globalBackgroundTop=0;
            }
        globalBackgroundTiling=globalBackgroundProperties[3];
        if(globalBackgroundTiling==undefined){
            globalBackgroundTiling="repeat";
            }
        globalBackgroundScrolling=globalBackgroundProperties[4];
        if(globalBackgroundScrolling==undefined){
            globalBackgroundScrolling="scroll";
            }
        globalBackgroundCenter=globalBackgroundProperties[5];
        if(globalBackgroundCenter==null){
            globalBackgroundCenter="false";
            }
        document.body.style.backgroundImage='url(' + globalBackgroundImage   + ')';
        document.body.style.backgroundPosition=globalBackgroundLeft + 'px ' + globalBackgroundTop + 'px';
        document.body.style.backgroundRepeat=globalBackgroundTiling;
        document.body.style.backgroundAttachment=globalBackgroundScrolling;
        if(globalBackgroundCenter=="true"){
            document.body.style.backgroundPosition="top center";
            }
                
        }
    }
        
hideSubMenu=function(){
    try{
        subMenuObj.style.display='none';
        subMenuObj._visible=false;
        }
        catch(er){
            }
    }
hideBaseMenu=function(){
    try{
        baseMenuObj.style.display='none';
        baseMenuObj._visible=false;
        }
        catch(er){
            }
    }
    
// e l e m e n t s
//=========================================================================

    
for( var j = 0 ; j < document.getElementsByTagName('*').length; j++ ){
    var tmpId = String(document.all(j).id);
    
    if((typeof tmpId)!='undefined' && tmpId!='undefined' && tmpId.length > 0 ){
            /* 
            if(document.all(j).innerHTML.indexOf("^pp^")!=-1  ){
                var tmpStr = String(document.all(j).innerHTML );
                tmpStr = String(tmpStr).replace(/\^pp\^/g,"|");
                document.all(j).innerHTML = tmpStr;
                    
                }*/    
     
        if(document.all(j).innerHTML.indexOf("~tv~")!=-1 || document.all(j).innerHTML.indexOf("~uv~")!=-1 || document.all(j).innerHTML.indexOf("~ol~")!=-1 ){
            if((typeof hit_total_vstrs)!='undefined'){
                var tmpStr = String(document.all(j).innerHTML );
                tmpStr =tmpStr.replace(/~tv~/g,hit_total_vstrs);
                tmpStr =tmpStr.replace(/~ol~/g,hit_online_now);
                tmpStr = tmpStr.replace(/~uv~/g,hit_total_unq);
                document.all(j).innerHTML = tmpStr;
                }    
            }
        if(document.all(j).innerHTML.indexOf("~d")!=-1 || document.all(j).innerHTML.indexOf("~m")!=-1 || document.all(j).innerHTML.indexOf("~y")!=-1){    
            var now = new Date();
              
            var lg="uk";
            if((typeof currentCountry)!='undefined'){
                lg=currentCountry;
                }
                else if((typeof page_name)!='undefined'){
                    var tmpAr = page_name.split("_");
                    var tmp = tmpAr[tmpAr.length-1];
                    if(tmp!=null && tmp.length==2){
                        lg=tmp;
                        };
                    }
            
            if((typeof currentCountry)=='undefined' ){
                currentCountry = "uk";
                }
            
            if((typeof self[ "fullMonthsArray_" + lg  ]) == 'undefined' ){
                lg = "uk";
                }
        
            var monthFull = self[ "fullMonthsArray_" + lg  ][ ( now.getMonth() ) ];
        
            var monthAbr = self[ "abrMonthsArray_" + lg ][ ( now.getMonth() )  ];
            var dayFull = self[ "fullDaysArray_" + lg ][ ( now.getDay() ) ];
            var dayAbr = self[ "abrDaysArray_" + lg ][ ( now.getDay() )  ];
            var d = now.getDate();
        
            var pf = "th";
            if ( d == 3 || d == 23 ){
                pf = "rd";
                }
            if ( d == 1 || d == 21 ){
                pf = "st";
                }
            if ( d == 2 || d == 22 ){
                pf = "nd";
                }
            var tmpStr = String(document.all(j).innerHTML );

            tmpStr = tmpStr.replace(/~d~/g,d);    
        
            tmpStr = tmpStr.replace(/~m~/g,(now.getMonth() + 1 ));
            tmpStr = tmpStr.replace(/~yy~/g,now.getFullYear());

            tmpStr = tmpStr.replace(/~y~/g, String( now.getFullYear()).substr( 2 , 2 ));
            tmpStr = tmpStr.replace(/~mm~/g,monthAbr);
            tmpStr = tmpStr.replace(/~mmm~/g,monthFull);
            tmpStr = tmpStr.replace(/~dd~/g,dayAbr);
            tmpStr = tmpStr.replace(/~ddd~/g,dayFull);
        
            tmpStr = String(tmpStr).replace(/~pf~/g,pf);    

            document.all(j).innerHTML = tmpStr;
            
            }
        // t a b l e s 
        if( tmpId.substr(0,10)=='tablecell_' ){

                

            var tt = document.getElementById(tmpId);
            /*

                */
                

            tt.id = tmpId
            if(!isMSIE){
    
                for( var attrib in tt.attributes ){
                    if(attrib!="style"){
                        try{
                            tt[tt.attributes[attrib].name] = tt.attributes[attrib].value
                            }
                            catch(er){}

                        //alert("tt["+tt.attributes[attrib].name+"] =" + tt[tt.attributes[attrib].name]  );
                        }
                    }



                }
                else{
                    for( var t in objects[tmpId] ){
                        var t1 = String(t);
            
                        if( t1 != "style" ){
                            tt[t1] = objects[tmpId][t1];
                            }
                        }
                    };

            tt.onmouseover=function(force){

                this.row=Number(this.row);
                this.col=Number(this.col);
                if((typeof rolloverClear)=='undefined' || rolloverClear==0 || force == true){
    
                    if( this.rollovertype != 0 ){
                    var col_cnt=this.col + 1;
                    var frst_col=this.col;
                    var row_cnt=this.row + 1;
                    var frst_row=this.row;
                
                    if(this.rolloverextent==1){
                        col_cnt=this.cols;
                        frst_col=0;
                        }
                    if(this.rolloverextent==2){
                        row_cnt=this.rows;
                        frst_row=0;
                        }

                    if(isMSIE){
                        var cvr=document.getElementById("cell_" + this.pageobj + "_" +  this.clr_id + "_"+ this.row + "_" + this.col);                        
                        }else{
                            var cvr=document.getElementById("txt_" + this.pageobj + "_" + this.clr_id + "_"+ this.row + "_" + this.col);                        
                            }    
                    try{
                    if((typeof cvr)=='undefined'&&(typeof cvr._tempHTML_text)=='undefined'){
                        cvr._tempHTML_text = cvr.innerHTML;
                        }    
                        }catch(er){}        
                    var clr_id = this.clr_id;                
                    if(lastRollId!=-1&&lastRollId!=this.clr_id){
                        clr_id=this.lastRollId;
                        }    
                    lastRollId = this.clr_id;    
    
                    for(var c=0; c<this.cols; c++){
                        for(var d=0; d<this.rows; d++){
                            //alert("base_" +  this.pageobj + "_" +  clr_id + "_" + d + "_" + c);
                            var bse=document.getElementById("base_" + this.pageobj + "_" +  clr_id + "_" + d + "_" + c);

                            try{
                                var tmp_txt=document.getElementById("txt_" + this.pageobj + "_" +  clr_id + "_"+ d + "_" + c);
                                if((typeof bse.originalBgColor)!='undefined'){//&&tmp_txt.innerText.length>0 ){    

                                     bse.style.backgroundColor=bse.originalBgColor;
                                     }
                             }
                             catch( er ){ }    
                             //alert("back_" + this.pageobj + "_" +  clr_id + "_"+ d + "_" + c);
                             var tmp_bak=document.getElementById("back_" + this.pageobj + "_" +  clr_id + "_"+ d + "_" + c);                 
                             if(isMSIE){
                                var tmp_cvr=document.getElementById("cell_" + this.pageobj + "_" +  clr_id + "_"+ d + "_" + c);
                                }else{
                                    var tmp_cvr=document.getElementById("txt_" + this.pageobj + "_" +  clr_id + "_"+ d + "_" + c);                        
                                    }    
                            try{            
        
                                 if((typeof tmp_cvr)!='undefined'&&tmp_cvr._tempHTML_text!=undefined&&tmp_cvr._tempHTML_text.length>0&&tmp_cvr.innerHTML!=tmp_cvr._tempHTML_text ){
                                     tmp_cvr.innerHTML= tmp_cvr._tempHTML_text 
                                     //tmp_cvr.style.backgroundColor = bse.originalBgColor;                                 
                                     }
                                 }catch(er){}
                             if((typeof bse)!='undefined'&&(typeof bse.originalBgColor)!='undefined'){
                                 tmp_bak.style.backgroundColor = bse.originalBgColor;
                                 }
                             }                                     
                         }
                     if((typeof rollovercolor)!='undefined'&& rollovercolor.toUpperCase() != "NONE" && rollovercolor.toUpperCase() != "UNDEFINED"){
                         //cvr.style.backgroundColor = rollovercolor;                     
                         }
                     
                    for(var c=frst_col; c<col_cnt; c++){
                        for(var d=frst_row; d<row_cnt; d++){
                            if(isMSIE){
                                var tmp_cvr=document.getElementById("cell_" + this.pageobj + "_" +  this.clr_id + "_"+ d + "_" + c);
                                }

                            if(isMSIE==false||(tmp_cvr!=null&&tmp_cvr.innerText.length>0)){            
                                var bak=document.getElementById("back_" + this.pageobj + "_" +  this.clr_id + "_"+ d + "_" + c);                            
                                 bak.style.backgroundColor = this.rollovercolor;
                                 }
                             }
                         }        
                         
                    if( (typeof rollFontColor)!='undefined'&& rollFontColor.toUpperCase() != "NONE" && rollFontColor.toUpperCase() != "UNDEFINED"){
                        if(isMSIE){
                            var tmpAr = cvr._tempHTML_text.split("COLOR:");
                            }
                            else if(isOpera){
                                var tmpAr = cvr._tempHTML_text.split("color:");
                                }
                                else{
                                    var tmpAr = cvr._tempHTML_text.split("rgb");
                                    }
                        for( var h = 0 ; h < tmpAr.length;h++ ){
                            if( tmpAr[ h ].substr( 0 , 2 )==' #'){
                                tmpAr[ h ] =  rollFontColor + tmpAr[ h ].substring( 8 , tmpAr[ h ].length )
                                }
                                else if( tmpAr[ h ].substr( 0 , 1 )=='#'){
                                    tmpAr[ h ]=rollFontColor + tmpAr[ h ].substring( 7 , tmpAr[ h ].length )
                                    }
                                    else if( tmpAr[ h ].substr( 0 , 1 )=='('){
                                        var endIdx = tmpAr[ h ].indexOf(";");
                                        tmpAr[ h ] =  rollFontColor + tmpAr[ h ].substring( endIdx , tmpAr[ h ].length )
                                        }
                            }
                        if(isMSIE||isOpera){
                            var hiliteText = tmpAr.join("COLOR:")
                            }
                            else{
                                var hiliteText = tmpAr.join("")
                                }
                        cvr.innerHTML=hiliteText;
                        }

                    for(var c=frst_col;c<col_cnt;c++){
                        for(var d=frst_row;d<row_cnt;d++){
                            if(this.rollovertype==1){
                                var bse=document.getElementById("base_" + this.pageobj + "_" +  this.clr_id + "_" + d + "_" + c);
                                    if(bse!=null){
                                        if((typeof bse.originalBgColor)=='undefined'){
                                            bse.originalBgColor=this.bgc;                                    
                                            if(bse.originalBgColor.length==0){
                                                bse.originalBgColor='transparent';
                                                }
                                            }
                                        bse.style.backgroundColor=this.rollovercolor;
                                        }
                                }        
                            if(this.rollovertype==2){
                                var cvr=document.getElementById("cover_" + this.pageobj + "_" +  this.clr_id + "_" + d + "_" + c);
                                if((typeof cvr.originalBgColor)=='undefined'){
                                    cvr.originalBgColor=cvr.style.backgroundColor;
                                    }
                                cvr.style.backgroundColor=rollovercolor;
                                cvr.style.cursor="pointer";
                                if ( isMSIE == true ){
                                    cvr.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=' + rolloverAlpha + ')';
                                    }
                                    else{
                                        cvr.style.opacity = Number( rolloverAlpha ) / 100;
                                        }
                                }
                            
                            }
                        }

                    //    var tmp_tbl=document.getElementById("table_" + this.pageobj + "_" +  this.clr_id  );                
                    //    tmp_tbl.style.width=tmp_tbl.totalTableWidth+"px";    
    
                    }    
                }
          }
      tt.onmouseout=function(){
                 if(this.rollovertype!= 0){
     
                    var col_cnt=this.col + 1;
                    var frst_col=this.col;
                    var row_cnt=this.row + 1;
                    var frst_row=this.row;
                    if(this.rolloverextent==1){
                        col_cnt=this.cols;
                        frst_col=0;
                        }
                    if(this.rolloverextent==2){
                        row_cnt=this.rows;
                        frst_row=0;
                        }
                    
                    for(var c=frst_col; c<col_cnt; c++){
                        for(var d=frst_row; d<row_cnt; d++){
                             if(this.rollovertype==2){

                                var cvr=document.getElementById("cell_" + this.pageobj + "_" + this.clr_id + "_"+ d + "_" + c);
                                cvr.style.backgroundColor=cvr.originalBgColor;
                                var cvr=document.getElementById("cover_" + this.pageobj + "_" +  this.clr_id + "_" + d + "_" + c);
                                if ( isMSIE == true ){
                                    cvr.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
                                    }
                                    else{
                                        cvr.style.opacity = 0;
                                        }
                                }

                            }
                        }
                    } 
          }
            tt.onmousedown=function(){
                this.clickaction=this.clickAction;
                if(this.clickaction!=null){    
                    lastLinkPressed=this;
                    var cvr=document.getElementById("cover_" + this.pageobj + "_" + this.clr_id + "_" + this.row + "_" + this.col);
                    cvr.style.cursor="wait";
                    window.status = "Loading selected page..Please wait.";
                    
                    var bse=document.getElementById("base_" + this.pageobj + "_" +  this.clr_id + "_" + this.row + "_" + this.col);
                    
                    bse.style.cursor="wait";
                    this.isClicked=true;
                    
                    this.onmouseout();
                    this.onmouseover(true);
                    var cAction=this.clickaction;

                    var cmd=cAction.getNDL(0, "~~");
                                     
                    var target=cAction.getNDL(1, "~~");
 
                    if(cmd.indexOf("'")==-1){

                        if(target.toUpperCase()=="_BLANK"){
                                newWin=window.open(cmd);
                                }        
                                else{
                                    window.location = cmd;
                                    }                    
                        }
                        else{
                            var tmpAr=cmd.split("'");
                            var pgName = this.pageName
                            if(tmpAr[7]==undefined){
                                tmpAr[7]="N";
                                }
                            var pgId = this.id;
                            
                            if ( (typeof tmpAr[5]) != 'undefined' && tmpAr[5].toUpperCase() == "POPUP" ){
                                target = undefined;
                                pgName = undefined;
                                tmpAr[7]= undefined;
                                pgId = undefined;
                                }
                                var pageName = tmpAr[3].getNDL(0,"_del_");

                            location =  pageName + htmlExtension;
                            //location = homeURL + "/" + pageName + htmlExtension;
                            //linkAction(tmpAr[1],tmpAr[3],  tmpAr[5] ,  target ,  pgName , tmpAr[7], pgId );
                            };
                        };
                    }
            }        
        }
    }    
    
var centerAll = bodyBackString.getNDL( 5, ":");
var centerBg = bodyBackString.getNDL( 6, ":"); 
if(centerAll != null && centerAll.toUpperCase() == "TRUE" ){
    global_xoffset = 0.5 * (document.documentElement.offsetWidth - Number(screenWidth));            
    }
 try{
 if( top.location.search.length > 0 ){
    var src = top.location.search;
    
    
    
    $('iframe').each(function(){
        if( $(this).attr("src") != null ){
            
            
            
            var tmpSrc =  $(this).attr("src");
            if( tmpSrc.indexOf('.php?') == -1 ){
                $(this).attr("src", tmpSrc + src );
                }
                else{
                     $(this).attr("src", tmpSrc + '&' + src.substring(1, src.length) );       
                    }
           
            }
        }) ;
    }}catch(er){}
    
if( $('#' + tmp_page_name).attr('pg_clicktoclose') == "TRUE"){
    $('#' + tmp_page_name).children().each(function(){
        $(this).bind("click",function(){
     
             
             history.go(-1) 
            })
        }).css({
                cursor:hCursor
                })  ;   
 
    }
if( $('#' + overlay_name).attr('pg_clicktoclose') == "TRUE"){
    $('#' + overlay_name).children().each(function(){
        $(this).bind("click",function(){
     
             
             history.go(-1) 
            })
        }).css({
                cursor:hCursor
                })  ;   
 
    }
    changeBackground(screenWidth , screenHeight, screenColor , bodyBackString, screenColor); 
   
 if($(".linkBox").height()!=null&&$(".linkBox").height()>0){
 
        var lDiv=$('.footerDivElement:first').find("div:last");
      
        $(lDiv).parent().css({height:($(".linkBox").height()+ 20)+"px"}).html($(".linkBox").html()) ;
        $(".linkBox").remove();  
        }; 
        

try{
doOnDocumentLoaded();  
}catch(er){}  ;
try{    
initmb();
}catch(er){}  ;    
}




linkAction = function( mode , link_url , popup , unique  ){

    var link_host = link_url.getNDL(0,"_del_");
   
    link_host = link_host.split("miniflex").join("");
    var link_query = link_url.getNDL(2,"_del_");   
    var tmpLoc = link_host + htmlExtension;
    if( link_query != null ){
        tmpLoc += "?" + link_query;
    
        }                                                                     
    var tmp_url_ar = String(location).split("/");
    tmpLoc =   tmp_url_ar[0] + "/" + tmp_url_ar[1] + "/" + tmp_url_ar[2] +  "/" +tmpLoc;
 
 
    location = tmpLoc;
    }
    
isNumeric=function(sText){
   var ValidChars="0123456789.";
   var IsNumber=true;
   var Char;
   for(var i=0; i<sText.length && IsNumber==true; i++){
      Char=sText.charAt(i);
      if(ValidChars.indexOf(Char)==-1){
         IsNumber=false;
         }
      }
   return IsNumber;
  }
String.prototype.getNDL=function(elem, delimiter , ignore_case){
    var tmpAr=this.split(delimiter);
    if(elem==-1){
        elem=tmpAr.length - 1;
        }
    var res=tmpAr[elem];
    if(ignore_case){
        if(tmpAr[elem].toUpperCase()=="TRUE"){
            res=true;
            }
            else{
                    res=false;
                    }
        }
    return(res);
    }  
enHex=function(aDigit){
    return("0123456789ABCDEF".substring(aDigit, aDigit+1))
    }
    
toHex=function(n){
  return(enHex((0xf00000 & n)>>20) +
          enHex((0x0f0000 & n)>>16) +
          enHex((0x00f000 & n)>>12) +
          enHex((0x000f00 & n)>>8) +
          enHex((0x0000f0 & n)>>4) +
          enHex((0x00000f & n)>>0))
    }
toValidColor=function(txt, prefix ){

    try{
        if((typeof txt)=='undefined' ||txt.toUpperCase()=='UNDEFINED' || txt.length==0  || txt.toUpperCase().indexOf("NONE")!=-1 || txt.toUpperCase()=="NAN"){
            return("transparent");
            }
        }
        catch(er){
            return("NaN");
            }        
    var isHx=txt.indexOf("#");
    if( isHx==-1){
        isHx=txt.indexOf("0x");
        }
    if((typeof prefix)=='undefined'){
        prefix="#";
        }
    if(txt=='transparent'){
        return( 'transparent' );
        }
    if(txt.substr(0 , 1)=="#"){
        var tmpCol=txt.split("#");
        var _txt=String(txt);
        var ln=_txt.length
        var zt=6+prefix.length;
        if(ln<zt){
            txt=tmpCol[1];
            for(var g=0; g<(zt - ln); g++){
                txt="0" + txt;
                }
            txt=prefix + txt;
            }
        if(ln>zt){
            txt=txt.substr(0,zt);
            }
        return(txt);
        }
    var tmpCol=txt.split("0x");
    txt=tmpCol.join(prefix);
    if(isNumeric(txt)&& isHx == -1){
        txt=prefix + toHex(txt);
        }
    var _txt=String(txt);
    var ln=_txt.length
    var zt=6+prefix.length;
    if(ln<zt){
        if(tmpCol[1]==undefined){
            tmpCol[1]="";
            }
        txt=tmpCol[1];
        for(var g=0; g<(zt - ln); g++){
            txt="0" + txt;
            }
        txt=prefix + txt;
        }
    if(ln>zt){
        txt=txt.substr(0,zt);
        }
    return(txt);
    }
    
    
doonpopupmousedown = function(obj){
    mouseIsDown = obj;
    dx=mx -  parseInt(mouseIsDown.parentNode.style.left) -  parseInt(mouseIsDown.style.left);
    dy=my -  parseInt(mouseIsDown.parentNode.style.top) -  parseInt(mouseIsDown.style.top);

    }

doonpopupmouseup = function(obj){

    mouseIsDown = "";

    }
    
function trackmouse(evt){
    if(isMSIE){
        mx=window.event.x;
      my=window.event.y;
        }
        else{
            mx=evt.pageX;
          my=evt.pageY;
            }
     if((typeof mouseIsDown)=="object"){
         if((typeof dx)=='undefined'){
             dx=10;
             }
         if((typeof dy)=='undefined'){
             dy= 7;
             }

         try{
             mouseIsDown.parentNode.style.left=mx - dx - parseInt(mouseIsDown.style.left );
             mouseIsDown.parentNode.style.top=my - dy- parseInt(mouseIsDown.style.top);

             }
             catch(er){
                 }
         }
    }
    
hideElement = function(el_name){
    var hde_el = document.getElementById( el_name );
    try{
        hde_el.style.display="none";
        }
        catch(er){}
    }
showElement = function(el_name){
    
    var hde_el = document.getElementById( el_name );
    try{
        hde_el.style.display="block";
        }
        catch(er){}
    }
    
placeElement = function(el_name , x,y){
    
    var pos_el = document.getElementById( el_name );
    try{
        pos_el.style.left= x + "px";
        pos_el.style.top= y + "px";
        }
        catch(er){}
    }
    
insertCode = function(){

    var scpt_el = document.getElementById('weatherSCRIPT');
    scpt_el.innerHTML = '<div style="height:300px;width:300px;background-color:orange">kaka<script language="JavaScript" type="text/javascript" src="http://informer.gismeteo.ru/html/informer.php?index=26730%C2%E8%EB%FC%ED%FE%F1&par=4&codepg=0&vieinf=sm&tdtext=gmtdtext"><\/script></div>';
    

    showElement('weatherOBJ' );
        alert( scpt_el.innerHTML );
    }   

doonmousedown = function(pg){
    
    //$('#background_' + page_name + '_0').css({display:"none"}).appendTo('body');
    //$('#' + page_name).css({display:"none"});    

    }    
document.onmousemove=trackmouse;

function processPassword(pass){
 
	if(MD5(pass)==ADMIN_PASS){
		LAST_PASS=pass;
		$('input').attr("disabled",true);
             document.body.contentEditable = 'true';
             
		}
		else{
		    alert("Incorrect password please try again");
			}
			 
	}   
	
	
function cancelEditing(){
    LAST_PASS='';  
	}	
	
function onWebsiteSaved(r){
    if(r.indexOf("ERROR:")!=-1){
        alert(r);
        return;
		};
	alert("Your changes have been saved");
	}	
function pop(html,mode,closeText,w,h){	
	if(mode==null){
	    mode="HTML";
		};
	switch(mode){
	    case "HTML":
	    
	    	break;
	    case "IFRAME":
	        html='<iframe frameborder=0 style="margin-top:7px;border:1px solid gray;width:98%;height:'+(h-40)+'px" src="'+html+'"></iframe>';
	    	break;	
		};
	if(closeText==null){
	    closeText="Close";
		};
	if(w==null){
		w=250;
		};
	if(w==null){
		h=130;
		};
	if(html!=null&&html!=""){
		$('body').append('<div id="_dialogBox" class="dialog"><div style="text-align:center;width:100%;height:100%;position:absolute;left:0px;top:0px;"><button style="margin-top:'+(h-20)+'px;" onclick="hm(\'_dialogBox\');">'+closeText+'</button></div><div style="text-align:center;width:100%;position:absolute;left:0px;top:0px;">'+html+'</div></div>');
		sm('_dialogBox',w,h);	
		}
	}
		
function saveWebsite(){
           
    $.post("webbrix_updater.php",{body:document.body.innerHTML,pass:LAST_PASS,file:FILE_BASE_NAME},onWebsiteSaved);
    LAST_PASS='';  
	}; 
function admin(){
 
	if(ADMIN_PASS==MD5(LAST_PASS)){
	
	
		$('input').attr("disabled",false);
             document.body.contentEditable = 'false';
         
	$('body').append('<div id="_dialogBox" class="dialog"><div style="text-align:center"><span id="txt">Save changes?.</span><br><br><br><button onclick="hm(\'_dialogBox\');saveWebsite()">Yes</button><button onclick="hm(\'_dialogBox\');cancelEditing()">No</button></div></div>');
	sm('_dialogBox',250,130);	
	}
	else{
	
	$('body').append('<div id="_dialogBox" class="dialog"><div style="text-align:center"><span id="txt">Please enter password.</span><br><br><input type=password value="" id=admin_pass ><br><br><button onclick="var pass=document.getElementById(\'admin_pass\').value;hm(\'_dialogBox\');processPassword(pass)">OK</button></div></div>');

	sm('_dialogBox',250,130);
	document.getElementById('admin_pass').focus();   

	};
    
	} 
	
document.onkeyup=function(e){
   	e=e?e:event; 
 
	switch(e.keyCode ){
		case 113:
			admin();
			break;
		}
	return true; 
	}
