
function reloadParent() {
  window.opener.location.href = window.opener.location.href;
  window.focus();
  //window.close();
}

function comparisonLoading() {
  	var allComparison = document.getElementById('allComparison');
  	allComparison.setAttribute('style', 'background: black;');
}  	


function popup(url, windowName, width, height){
    PopupWin = window.open("" +url+ "","" + windowName + "","width=" + width + ",height=" + height + ",location=0,menubar=0,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=0,screenX=50,left=50,screenY=50,top=50");
    PopupWin.focus();
}

var insideShowTab = false;

function validate_required( field, alternate, alerttxt ) {
  with (field) {
    if ( value==null || value=="" || value==alternate ) {
  	alert(alerttxt);
	return false;
    } else {
        callUrchin('/search/simple');
        return true;
    }
  }
}

function findObj(n, d) { //v4.01
    var p,i,x; 
    if(!d) d=document; 
    if( (p=n.indexOf("?")) > 0 && parent.frames.length ) {
	d=parent.frames[n.substring(p+1)].document; 
	n=n.substring(0,p);
    }
    if(!(x=d[n])&&d.all) 
	x=d.all[n]; 
    for (i=0;!x&&i<d.forms.length;i++) 
	x=d.forms[i][n];
    
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
	x=MM_findObj(n,d.layers[i].document);
    
    if(!x && d.getElementById) 
	x=d.getElementById(n); 
    return x;
}

function validate_3required( field1, field2, field3, alerttxt ) {
  if( ( field1.value==null || field1.value=="" ) &&
      ( field2.value==null || field2.value=="" ) &&
      ( field3.value==null || field3.value=="" ) ) {

    alert(alerttxt);
    return false;

  }

  callUrchin('/search/advanced');
  return true;
}

function showTab( tabName ) {
  if( insideShowTab ) {
    return false;
  } 

  insideShowTab = true;
  tabElement = document.getElementById( tabName );
  
  if( tabElement == null ) {
     new Ajax.Request('/search/form/tab/'+tabName, {
     	  method:'get',
     
          onSuccess:function(req){
	          node = document.createElement( "div" );
	          node.innerHTML = req.responseText;
              document.getElementById( 'searchHolder' ).appendChild( node );
              document.getElementById( 'searchHolder' ).className = tabName; 
              insideShowTab = false;
          }
        });

  } else {
     document.getElementById('searchHolder').className = tabName; 
     insideShowTab = false;
  }

  callUrchin( '/tabs/'+tabName );
  return false;
}