//////////////////////////////////
//  New Window
//////////////////////////////////
function displayWindow(url,width,height) {
   //if(window.Win){
   //   window.Win.close();
   //}
   
	window.Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',screenX=0,screenY=0,top=0,left=0,resizable,scrollbars,location=0,status=1');
	//this.focus();
}

	
function displayWindowDetail(url,width,height) {
   //if(window.Win){
   //   window.Win.close();
   //}
   window.Win = window.open(url,"displayWindowDetail",'width=' + width + ',height=' + height + ',left=300,top=300,location=0,status=0');
   window.Win.focus();
}

//////////////////////////////////
//  Close New Window
//////////////////////////////////
function closeWin(){
   if(window.Win){
      window.Win.close();
   }
}

function findentry(pattern, list){
	
   // look for the pattern at the beginning of the word
   pattern = new RegExp("^" + pattern, "i");

    //spin through the list and look for a match
    // when you find one exit the loop
    for (n=0;n<list.length;n++){
       if(pattern.test(list[n].text)){
          list.selectedIndex=n;
          n=list.length;

       }
    }
}

function Hilite(name,over)
{
	if(window.document.images) 
	{
		if (over)
		window.document.images[name].src = "/OLEA/images/" + name + "_ov.gif";
		else
		window.document.images[name].src = "/OLEA/images/" + name + ".gif";
	}
}


function disappear(obj,name) {

  if (obj.style.display == "none") {

    obj.style.display = "";

    window.document.images[name].src = "/OLEA/images/collapse3.gif";

  }

  else {

    obj.style.display = "none";

    window.document.images[name].src = "/OLEA/images/expand.gif";

  }

}

function GetElement(id)
{
	var objects = document.all;
	
	for(i=0; i<objects.length; i++)
	{
		if(objects[i].id != null && objects[i].id.indexOf(id) >= 0 &&
				objects[i].id.length == objects[i].id.indexOf(id) + id.length)
			return objects[i];
	}

	return null;
}

function SelectRadioButton(buttonID, button)
{
	var objects = document.getElementsByTagName('input')
	
	// first turn off all of the radio buttons
	for(i=0; i<objects.length; i++)
	{
		if(objects[i].id != null && objects[i].id.indexOf(buttonID) >= 0 &&
				objects[i].id.length == objects[i].id.indexOf(buttonID) + buttonID.length)
			objects[i].checked = false;
	}
	
	button.checked = true;
}

function submitOnKeydown(buttonid, e)
{
	var btn = document.getElementById(buttonid);

	if (typeof btn == 'object')
	{
		if (e.keyCode == 13)
		{
			btn.focus();
			return false;
		}
	}
} 

function focusElement(id)
{
	var obj = document.getElementById(id);
	
	if (obj)
		obj.focus();
}
function mailpage()
{
	mail_str = "mailto:?subject=Check out this article - " + document.title;
	mail_str += "&body=I thought you might be interested with this article, " + document.title;
	mail_str += ". You can view it at, " + location.href; 
	location.href = mail_str;
}
function bookmark(url,title){
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	window.external.AddFavorite(url,title);
	} else {
	alert("Press Ctrl+D (Firefox) or Ctrl+T (Opera) to bookmark");
	}
}


function changeRate(val){

    var a = parseInt(val*2);
    for (i = 1; i<=10;i++)
    {
        
        if (i <= a){
            if ((i % 2)==0){
            document.getElementById('imgStar'+ i.toString()).src = "/Images/star-filled-half2.png";
            }
            else{
            document.getElementById('imgStar'+ i.toString()).src = "/Images/star-filled-half.png";
            }
        }else{
            var a = i % 2
            if (a == 0){
            document.getElementById('imgStar'+ i.toString()).src = "/Images/star-empty-half2.png";
            
            }
            else{
            document.getElementById('imgStar'+ i.toString()).src = "/Images/star-empty-half.png";
            
            }
        }
    }
}
function resetRate(){
 var val = document.getElementById('StarRated').value;
 val.toString();
 if(val == "")
    changeRate('0')
 else
    changeRate(val)
}

function is_child_of(parent, child) {
			if( child != null ) {			
				while( child.parentNode ) {
					if( (child = child.parentNode) == parent ) {
						return true;
					}
				}
			}
			return false;
		}

function fixOnMouseOut(element, event, JavaScript_code) { 
    //alert("fix"); 
    var current_mouse_target = null; 
    if( event.toElement ) { 
    current_mouse_target = event.toElement; 
    } else if( event.relatedTarget ) { 
    current_mouse_target = event.relatedTarget;
    } 
    if( !is_child_of( element, current_mouse_target) && element != current_mouse_target ) { 
    eval(JavaScript_code); 
    } 
}
