//////////////////////////////////
//  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 displayWindowByName(url,windowName,width,height) 
{
   window.Win = window.open(url,windowName,'width=' + width + ',height=' + height + ',screenX=0,screenY=0,top=0,left=0,resizable,scrollbars,location=0,status=1');
}
	
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 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 changeStars(val){

    
    for (i = 1; i<=5;i++)
    {
        
        if (i <= val){
            
            document.getElementById('imgRatingStar'+ i.toString()).src = "/images/software/star.png";
            
        }else{
            
            document.getElementById('imgRatingStar'+ i.toString()).src = "/images/software/star_empty.png";
            
        }
    }
}
function resetStars()
{
 var val = document.getElementById('hdRated').value;
 
 if(val == '0'){
    changeStars(0);
 }else{
    changeStars(val);
 }
}

function setStars(val){
 document.getElementById('hdRated').value = 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); 
    } 
}

function SetHelpful(val){
    document.getElementById('hdRated').value = val;
}