﻿function $(id){
    return document.getElementById(id);
};

// dynamically load and add this .js file
function googleAds(){
    loadjscssfile('http://pagead2.googlesyndication.com/pagead/show_ads.js', 'js');
    //var t=setTimeout("loadjscssfile('http://pagead2.googlesyndication.com/pagead/show_ads.js', 'js');", 100);
};

function loadjscssfile(filename, filetype){
    if(filetype=="js"){ //if filename is a external JavaScript file
          var fileref=document.getElementsByTagName('script');
          fileref.setAttribute("type","text/javascript");
          fileref.setAttribute("src", filename);
    }
    else if(filetype=="css"){ //if filename is an external CSS file
          var fileref=document.getElementsByTagName("link");
          fileref.setAttribute("rel", "stylesheet");
          fileref.setAttribute("type", "text/css");
          fileref.setAttribute("href", filename);
    }
    if(typeof fileref!="undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref);
};

function lf(){
    var fle="http://www.beok.co.il/bnr.ashx?dTypeId=10&sp=Banners_Banner_GENERIC&w=520&h=60&tg=banner52060";
    var r=document.createElement('script');
    r.setAttribute("type","text/javascript");
    r.setAttribute("src", fle);

    if(typeof r!="undefined"){
        document.getElementsByTagName("head")[0].appendChild(r);
    }
};


//var counter=0;
//function Giliotina(maxLen, txtId, infoSpanId, submitButId, quota){
//	Msg = $(txtId).value;
//	Msglen = Msg.length;
//	counter++;
//	if(counter>=maxLen){
//        alert();
//	}
//    
//    var my_array = new Array();
//    my_array = Msg.split(' ');
//    
//    for(var i = 0; i < my_array.length; i++)
//    {
//        if (my_array[i].length > quota)
//        {
//            my_array[i] = my_array[i].substring(0,quota);
//		    $(txtId).value = my_array.join(' ');
//            $(submitButId).disabled = true;
//		    $(infoSpanId).innerHTML = "<span style='color:#ff0000;font-size:11px;font-weight:bold;'>נא לא להכניס יותר מ-" + quota + " תווים ברצף</span>";
//        }
//        else if (my_array[i].length <= quota)
//        {
//	        if (Msglen > maxLen) 
//	        {
//		        $(infoSpanId).innerHTML 	= "<span style='color:#ff0000;font-size:11px;font-weight:bold;'>נא לא להכניס יותר מ-" + maxLen + " תווים</span>";
//		        $(txtId).value = Msg.substring(0,maxLen);
//		        $(submitButId).disabled = true;
//	        }
//	        else if (Msglen <= maxLen)
//	        {
//		        $(infoSpanId).innerHTML = maxLen-Msglen + " תווים";
//		        $(submitButId).disabled = false;
//	        }
//        }
//    }
//};

// ----- Start of AutoComple

function ShowHint(str,d){
    clearTimeout(y);
    if(str.length==0){
        $(d).innerHTML='';
        $(d).style.visibility='hidden';
        $(d).style.display='none';
        return;
    }
    else{
        $(d).innerHTML='';
        var v;var cu=0;var maxf=10;
        for(var i=0;i<t.length;i++){
            v=t[i][1].toUpperCase();
            if(str==v.substring(0,str.length || v.match(str))){
                if(cu==maxf){
                    return;
                }
                else{
                    $(d).innerHTML+="<a href='http://www.beok.co.il/SelectedForum.aspx?ForumId="+t[i][0]+"' title='פורום "+t[i][1]+"' class='aC'>"+t[i][1]+"</a><br/>"; cu++;
                    $(d).style.visibility='visible';
                    $(d).style.display='block';
                    $(d).style.overflowY='scroll';
                }
            }
        }
    }
};

function flMOver(d){
    clearTimeout(y);
    $(d.id).style.visibility='visible';
    $(d.id).style.display='block';
};
var y;
function flMOut(d){
    y=setTimeout("Hided("+d.id+");",1000);
};

function Hided(o){
    $(o.id).style.visibility='hidden';
    $(o.id).style.display='none';
};


// ----- End of AutoComple

function inconer(field,icon,max){
    var len=(icon.length+2) + document.getElementById(field).value.length;
    if(len>max){
        alert('עד ' + max + ' תווים');
        return;
    }
  	eval("document.forms[0]."+field+".focus();");
    var sel=document.selection.createRange();
	sel.text="|"+icon+"| ";
  	return;
};

function colorRow(o){
    var x=document.getElementById(o.id);
    if(x.style.backgroundColor!="#FFFF99"){
        x.style.backgroundColor="#FFFF99";
        //x.style.fontWeight="bold";
        //x.style.cursor="pointer";
    }
};

function backToOrig(o,color){
    var x=document.getElementById(o.id);
    x.style.backgroundColor=color;
    //x.style.fontWeight="normal";
    x.style.cursor="arrow";
};

function OpenMessageBody(oId, messageId){
	 if (document.all)
     {
        if ($(oId).style.display == 'block'){
		    $(oId).style.display='none';
		    $(oId).style.visibility='hidden';
	    }
	    else{
		    $(oId).style.display = 'block';
		    $(oId).style.visibility='visible';
	    }
	 }
	 else
	 {
        if ($(oId).style.display == 'table-row'){
		    $(oId).style.display='none';
		    $(oId).style.visibility='hidden';
	    }
	    else{
		    $(oId).style.display = 'table-row';
		    $(oId).style.visibility='visible';
	    }        
	}
};
