
function openWindowMain(new_opener_url) {
     if ( window.opener ) {
	 //             alert("Opening old window at : " + new_opener_url);
             window.opener.location.href = new_opener_url;
     } else {
	 //             alert("Opening new window at : " + new_opener_url);
             window.open(new_opener_url,location);
    }
};




      var WindowObjectReference = null; // global variable
      function openWindow(url, help) {
                        
      if(WindowObjectReference == null || WindowObjectReference.closed)
           /* if the pointer to the window object in memory does not exist
              or if such pointer exists but the window was closed */
 
       {

//	alert("Opening new window");
         WindowObjectReference = window.open(url, help, "width=820,height=900,top=100,left=390,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=1,resizable=yes,location=0,scrollbars=1,copyhistory=0");
         WindowObjectReference.focus();

         /* then create it. The new window will be created and
            will be brought on top of any other window. */
       }
      else
       {
//	alert("Opening old window");
         WindowObjectReference.focus();
         WindowObjectReference = window.open(url, help, "width=820,height=900,top=100,left=390,alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=1,resizable=yes,location=0,scrollbars=1,copyhistory=0");


         /* else the window reference must exist and the window
            is not closed; therefore, we can bring it back on top of any other
            window with the focus() method. There would be no need to re-create
            the window or to reload the referenced resource. */
      };
    }

function expandSection(sectionId)
{
    var field;
    field = document.getElementById(sectionId);
    if(field != null)
        field.style.display = (field.style.display != "block")? "block" : "none";
}

// For registration opening and closing twisty sections
function SectionDisplay(sectionId, value)
{
  //   alert("Display:"+sectionId+" To:" + value);
  var field = document.getElementById(sectionId);

  if(field != null) {
    field.style.display = value;
  }

}

function register_show(thisoption)
{


 SectionDisplay("Option Initial", "");

 for (i = 0; i < thisoption.length; i++) {
   if ( i != thisoption.selectedIndex ) {
     // Hide it when not selected
     SectionDisplay("Option "+thisoption.options[i].value, "none");
   } else {
     // Display it when selected
     SectionDisplay("Option "+thisoption.options[i].value, "");
   }
 }

var x=document.getElementById("RegisterForm");
var y=thisoption.options[thisoption.selectedIndex].value;
var z="";
  if ( -1 != y.indexOf('Purchase') ) {
       	z = 'purchase';
  } 

  if ( -1 != y.indexOf('Sell') ) {
       	z = 'sell';
  } 

  if ( -1 != y.indexOf('Personal') ) {
       	z = 'personal';
  } 

  if ( -1 != y.indexOf('Academic') ) {
       	z = 'academic';
  } 

x.action="home/"  + z;


}

// For saving cookie of referrer on new users, because openwindow.js is used by so many static pages
// Store the referrer for later use, when they register save how they originally found page.

if( "" == ReadCookieX('save_referrer') ) {
        var ref = escape(document.referrer);
	SetCookieX('save_referrer',  document.referrer , 10);
}

function SetCookieX(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function ReadCookieX(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return "";
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length;
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}




function movepic(img_name,img_src) {
    document[img_name].src=img_src;
}

