
   $("#agreepolicy, #textpolicy").click( function(e){
		e.preventDefault();
        termsofusepop(this.id);
      $('.close-policy').click( function(){
          $('.submission-container').hide();
      }).mouseover( function() {
          $(this).attr('src',($.browser.msie && $.browser.version == "6.0" ? "/images/ie6-gray-close-btn-red.gif" : "/images/gray-close-red.png"));
      }).mouseout( function() {
          $(this).attr('src',($.browser.msie && $.browser.version == "6.0" ? "/images/ie6-gray-close-btn-gray.gif" : "/images/gray-close.png"));
      });
    });


$("#subject_area_select").change( function() {
         if( $(this).val() == "Other") {
                $("#subject_area").val('').show();
        } else {
		 $("#subject_area").val($(this).val()).hide();
        }
});



/* get jQuery cookie
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie !== '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


function termsofusepop(id)
{
  var divID = id+'terms';

  if ( $('#'+divID).length != 0 ){
    $('#'+divID).css("display","block");
    return;
  }

/*Build popup HTML elements*/

  var html = '';
   html+='<div id="'+divID+'" class="submission-container">';
        html+=  '<div class="submission-top"></div>';
        html+=  '<div class="submission-close"><img class="close-policy" src="' + ($.browser.msie && $.browser.version == "6.0" ? "/images/ie6-gray-close-btn-gray.gif" : "/images/gray-close.png") + '" alt="Close" title="Close"/></div>';
        html+=  '<div class="submission-mid">';
        html+=          '<img src="/images/submission-policy-header.gif" alt="Content Submission Policy" title="Content Submission Policy"/>';
        html+=          '<p>When you submit a fact, set of facts, dataset, formula, or any other information to be considered for incorporation Wolfram|Apha,'
                        +' you are giving it to Wolfram Alpha LLC ("we"/"us") free and clear, to do with anything and everything we choose.  '
			+'Your submission has to include a transfer/disclaimer of all intellectual property rights because all the information in'
			+' Wolfram|Alpha is merged and processed by automated software systems, and may end up presented in completely different forms on any'
			+' number of different pages. We can\'t place any limits on how or for how long the information you submit is used, how it will be'
			+' stored, or any specific attribution requirements.';

        html+=          '<p>If you can\'t or don\'t want to agree to this, then we regretfully can\'t accept your submissions. In particular, it\'s important '
			+'that you not submit anything that you don\'t have the legal right to give to us.'
                        +' Do not submit any trade secrets, classified information, copyrighted text, or information that you have acquired'
                        +' through any violation of any law, contract, or terms of use of a company, publisher, government agency, or other organization.'
                        +'  Do not submit any information that violates anyone\'s right to privacy, or that is false, libelous, misleading,'
                        +'  biased, or designed to advance an agenda.  When you submit something to Wolfram|Alpha'
                        +' you are telling us that you have not done any of these things, and that, to the best of your knowledge,'
                        +' the data is correct, fair, and legal.</p>';

	html+= 		'<p>You should be aware that misrepresentations of your rights to your submission can create'
			+' legal liability to you for any problems that arise from us incorporating'
			+' your submission into Wolfram|Alpha.  You acknowledge that you will'
			+' reimburse us for any such liability we incur because of any'
			+' misrepresentation on your part.</p>';

        html+=  '</div>';
        html+=  '<div class="submission-bot"></div>';
        html+='</div>';

  $('#popanchor').append( $(html) );
  
/*find position of 'parent' which is the results pod clicked*/
  var pos = $('#'+id).offset();

  $('#'+divID).css('top',pos.top-167);
  $('#'+divID).css('left',pos.left-40);
}

