function onImgErrorSmall(source)
{
source.src = "/images/no-image-100px.gif";
// disable onerror to prevent endless loop
source.onerror = "";
return true;
}

function onImgErrorSmall50(source)
{
source.src = "/images/nophoto_50.jpg";
// disable onerror to prevent endless loop
source.onerror = "";
return true;
}

function stringFormat(str)
{
  for(i = 1; i < arguments.length; i++)
  {
    str = str.replace("{" + (i - 1) + "}", arguments[i]);
  }
  return str;

}

function textboxMultilineMaxNumber(txt,maxLen)
{  
    try
    {  
        if(txt.value.length > (maxLen-1))return false;  
    }
    catch(e)
    {  
    }  
}  

function IncrementFavorites(postType)
{
    var link = document.getElementById(postType + 'FavoritesLink')
    if (link != null)
	   link.innerText = parseInt(link.innerText) + 1;
}

function DecrementFavorites(postType)
{
    var link = document.getElementById(postType + 'FavoritesLink')
    if (link != null)
	   link.innerText = parseInt(link.innerText) - 1;
}


 function ClickButtonOnReturnKey(e, elemId) 
 {
        var elem = document.getElementById(elemId);                
        var intKey 

        if(e && e.which){ //if which property of event object is supported (NN4)                
            intKey = e.which //character code is contained in NN4's which property
        }
        else{               
            intKey = event.keyCode //character code is contained in IE's keyCode property
        }
       
        if(intKey == 13) {                
            if(elem == null)
                alert('Unable to submit');
            else 
                elem.click();
        }
}


function selectAll(el) {
    el.select();
    if (document.all && copytoclip == 1) {
        therange = el.createTextRange()
    }
}