function setClass( hEl, sClass )
    {
    	hEl.className = sClass
    }
	
 function changeFont(inc,id){
   var p=document.getElementById(id);
     if(p.style.fontSize){
      var size=parseFloat(p.style.fontSize.replace("px",""));
     }else{
      var size=12;  //tuk slagame default stoinosta da se vidi ot css faila :)
     }
    if(!inc)  size=12;
    if((size+inc)<= 26 && (size+inc)>=8)
      p.style.fontSize=size+inc + 'px';
    }	


function loadFile(FileName){


        var phpScript = document.createElement( "script"  );

        phpScript.src = FileName;

        document.body.appendChild( phpScript  );


   }


   function startReload(FileName){

     loadFile(FileName)
     reloader = setTimeout( "startReload('"+FileName+"')" , 30000  )


   }

   function startReload2(FileName){

     loadFile(FileName)
     reloader = setTimeout( "startReload2('"+FileName+"')" , 30000  )


   }

function loadContent( urlToLoad, whereToLoad, whereImgLoad )
{

    var container = $( whereToLoad );
    var imgLoad   = $( whereImgLoad );

    if( imgLoad )
    {
       imgLoad.innerHTML = "<div style=\" text-align: center;\"><img src=\"include/img/loader.gif\" border=\"0\"></div>";
//	imgLoad.innerHTML = "<img src=\"include/img/loader.gif\" vspace=\"0\" hspace=\"0\"  border=\"0\">";
    }


    
    new Ajax.Request( urlToLoad,
                     {
                      method   : "get",
                      parameters   : "ajx=1&upd=" + whereToLoad,
		      evalScripts: 1,
                      onSuccess: function( trans ){
		                                       if( container )
						       {
                                                          container.innerHTML = trans.responseText;
                                                       }    
                                                  }
                     }
                    );
		    
    return false;		    
}


function submitForm( whatToUpdate, formName, noLoading, action, height )
{

       var params  = Form.serialize( formName );
      
       var mainContent = $( whatToUpdate );
       
       if( action )
       {
            var url = action;
       }
       else
       {
            var url = $( formName ).action;
       }

       if( mainContent )
       {
            if( noLoading == true)
            {
	    }
	    else if( $( noLoading ) )
	    {
		  
		  if( !height )
		  {
		       height = 200;
		  }

	          $( noLoading ).innerHTML =  "<div style=\" text-align: center;\"><img src=\"include/img/loader.gif\" border=\"0\"></div>";
	    }
	    else
	    {
              mainContent.innerHTML = "<div style=\" text-align: center;\"><img src=\"include/img/loader.gif\" border=\"0\"></div>";
            }
       }
       params = params + "&ajx=1&upd=" + whatToUpdate,

       new Ajax.Updater( whatToUpdate, url, 
                                          {
					     method: "post",
					     postBody: params,
					     evalScripts: 1
					   });
    
       return false;
}





 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 ca = document.cookie.split(';');
         var nameEQ = name + "=";
         for(var i=0; i < ca.length; i++) {
                 var c = ca[i];
                 while (c.charAt(0)==' ') c = c.substring(1, c.length);  //delete spaces
                 if (c.indexOf(nameEQ) == 0) return  c.substring(nameEQ.length, c.length);
         }
         return null;
 }

 function eraseCookie(name) {
         createCookie(name, "", -1);
 }

 function anketapopup() {
         var cdays = 1;
         var CVal = readCookie('anketa1');
         if (CVal) return;
         window.open("http://www.economedia.bg/oditpoll/", "anketa",  "width=790,height=500,scrollbars=1,resizable=1,status=0,toolbar=0,location=0,menubar=0,directories=0");
         createCookie('anketa1', '1', cdays);
 }

function vbaneriwodit(section) {
	var banurl, datetime = new Date();
	
	if (!banners[section]) {
		return false;
	}
	
	if (showban1 == 1) {
		document.write(singleBanner(banners[section]['banid'], section, banners[section]['url'], banners[section]['alt'], banners[section]['banfile'], banners[section]['x'], banners[section]['y'], banners[section]['bantype'], banners[section]['linktype'], banners[section]['banorderposid'], banners[section]['banorderid']));
		
		banurl = 'http://pban.odit.info/ban/?posid=' + banners[section]['posid'] + '&banid=' + banners[section]['banid'] + '&banorderposid=' + banners[section]['banorderposid'] + '&ipcountry=' + ipcountry + '&ipcity=' + ipcity + '&t=' + datetime.getTime() + '&js=1';
		
		document.write('<script src="' + banurl + '"><\/script>');
	}
}
 
function vbaneri2(section, htmlstart, htmlend) {
	if (typeof(banners) == 'undefined') return false;
	if (!banners[section]) return false;
	if (showban1==1) {
		document.write(htmlstart);
		vbaneriwodit(section);
		document.write(htmlend);
	}
}

function vbaneripagelogodit() {
	var banurl, datetime = new Date();
	
	if (!banpageid) {
		return;
	}
	
	banurl = 'http://pban.odit.info/page/?pid=' + banpageid + '&hash=' + userhash + '&ipcountry=' + ipcountry + '&ipcity=' + ipcity + '&t=' + datetime.getTime() + '&js=1';

	document.write('<script src="' + banurl + '"><\/script>');
}


function voteForText(type, textid, tid, fid) {
	
	var val;
	var res;
	
	if (type == 1) {
		val = 1;
	} else if (type == 0) {
		val = -1;
	}
	
	jQuery('.cvote' + textid).hide();
    jQuery('.vWait' + textid).show();

    
    //~ alert("s=54&textid=" + textid + "&i=" + tid + "&f=" + fid + "&val=" +val);
    
    jQuery.get(	"/index.php", 
    		"s=54&textid=" + textid + "&i=" + tid + "&f=" + fid + "&val=" +val, 
    		function(data){
     			res = data.split(';');   
			    jQuery('.vWait' + textid).hide();
			    jQuery('.voteText'+textid).html('одобрение <strong style="font-size: 12px;">' + res[1] + '</strong> от ' + res[0] + ' гласа' );
			    
			    if (res[0] > 14) {
				    if(res[0] == 0) {
	                        modRate = 0;
	                } else {
	                        modRate = res[1]/res[0];
	                }
	                
					classis = false;
	                if(modRate <= -0.66) {
	                        classis = 'greyPost';
	                } else if(modRate >= 0.66) {
	                        classis = 'yellowPost';
	                }
	                
	                if (classis) {
						jQuery('#post-'+textid+' .pbody').addClass(classis);
					}
	                
	            }
   			});
    
    return false;
}

