try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} 
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function setHomepage()
{
   document.body.style.behavior='url(#default#homepage)';
   document.body.setHomePage(window.location.href);
}

function set_topbanners()
{
	var baner = $("#TopBannerL");
	var width = $(window).width();
	if(width < 1085)
	{
		var cont = $('#MainBody');
		leftPos = cont.offset().left;
		cont.css("margin-left", baner.width() + 10 + "px");
	}
	baner.show();
}
function perform_search() 
{
	href = $('#subID').val(); 
	if(href != "")
		window.location = href;
	else
		alert(' יש לבחור קטגוריה ');
}
	
function check_custom_form(frm)
{
	var ret = true;
	var elems = $(frm).find('[class=Required]');
	elems.each(function()
	{
		if(this.type == "checkbox" && !this.checked)
		{
			check_field(this);
			ret = false;
			return false;
		}
		else if(this.value == "")
		{
			check_field(this);
			ret = false;
			return false;
		}
	});
	return ret;
}
function check_field(obj)
{
	alert(' נא מלה את כל השדות המסומנים כוכבית ');
	obj.focus();
}
function ImposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}
function TrimMaxLength(obj, MaxLen)
{
	if(obj.value.length > MaxLen)
	{
		alert(' המודעה קוצרה ל 500 תווים ');
		obj.value = obj.value.substr(0, MaxLen);
	}
}
function open_window(nav, w, h)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = "top="+wint+", left="+winl+", resizable=yes, scrollbars=yes, width="+w+", height="+h;
	window.open(nav, "new_window", winprops);
}

function GetRadioValue(id)
{
	var radio = document.getElementsByName(id);
	for (var j = 0; j < radio.length; j++)
	{
		if (radio[j].checked) {
			val = radio[j].value;
			break;
		}
	}
	return val;
}

function fill_combo(obj, tarID, Num)
{
	$('#' + tarID).attr("length", Num);
	$.get('getdata.asp?'+obj.name+'='+obj.value, function(data) {
			if(data != "")
			{
				$('#' + tarID).attr("disabled", false);
				$('#' + tarID).append(data);
			}
			else
				$('#' + tarID).attr("disabled", true);
		});
}

function fixPNG(myImage, url) 
{
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"><img src='images/spacer.gif' style='width:" + myImage.width + "px; height:" + myImage.height + "px; cursor:pointer;' onclick=\"window.location.href='" + url + "'\" /></span>"
	   myImage.outerHTML = strNewHTML  
    }
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    }
	
}
//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}