$(document).ready(
	function()
	{

		//Slide-down loginbox
		$('.loginbox h3 a').toggle(
		      function () {
				$(this).parent().next('.login').slideDown('slow');
				/*$(this).animate({ paddingTop:"160px", text:"cheese"}, 500);*/
				$(this).css({backgroundImage:"url(/images/redx.gif)"});
				$(this).text('Close Window');
				return false;
		      },
		      function () {
				$(this).parent().next('.login').slideUp('slow');
				/*$(this).animate({ paddingTop:"10px"}, 500);*/
				$(this).css({backgroundImage:"url(/images/redraquo.gif)"});
				$(this).text('Borrower Login');
				return false;
		      }
	    );

	    // Hide form on click...
        $('.loginbtn').click(function () {$('.loginbox h3 a').trigger('click');});


		// Find links with rel="external".
		// If they have class="popup" make them do that.
		// If they don't, open them with target="_blank"
		$("a[@rel='external']").filter('.popup').click(
			function(){
				var width;
				var height;
				var x;
				var y;
				var w;  //IWD-80
				var menu;
				//Added menu variable and menubar option to pop up window for I-745.  Track-it# 12983.  COMPJP
				menu = 0;
				if ($(this).attr('href').indexOf('I745') > -1)
				{
				  menu = 1;
				}
				width = 800;
				height = 600;
				x = (640 - width)/2;
				y = (480 - height)/2;
				if (x < 0)
				{
					x = 0;
				}
				if (y < 0)
				{
					y = 0;
				}
				if (screen)
				{
					y = (screen.availHeight - height)/2;
					x = (screen.availWidth - width)/2;
				}
				w=window.open($(this).attr('href'),'popup','titlebar=no,status=yes,width='+width+',height='+height+',left='+x+',top='+y+',screenX='+x+',screenY='+y+',resizable=0,scrollbars,menubar='+menu+',toolbar=0');
				w.focus();  //IWD-80
				return false; 
			}
		).end()
		.filter(":not('.popup')").click(
			function(){
				this.target = "_blank";
			}
		);	

	}
);

//Added for login function from Content site to secure site. COMPJP
function redirectOutput(myform)
{
    var width;
    var height;
    var x;
    var y;
    width = 800;
    height = 600;
    x = (640 - width)/2;
    y = (480 - height)/2;
    if (x < 0)
    {
    	x = 0;
    }
    if (y < 0)
    {
    	y = 0;
    }
    if (screen)
    {
    	y = (screen.availHeight - height)/2;
    	x = (screen.availWidth - width)/2;
    }
    var w=window.open('/Log_In.htm','secure','titlebar=no,status=yes,width='+width+',height='+height+',left='+x+',top='+y+',screenX='+x+',screenY='+y+',resizable=0,scrollbars=1,toolbar=0');
    w.focus();  //IWD-80 - set focus on secure window
    myform.target='secure';
    myform.txtUser.value = myform.inputUser.value;
    myform.txtPWD.value = myform.inputPWD.value;
    myform.inputUser.value = "";
    myform.inputPWD.value = "";    
    return true;
}

//Added for 1K Giveaway page. COMPJP
// Function numOnly(e) is to only allow numbers to be typed in certain fields.
function numOnly(e)
{
  if(window.event) // IE
  {
    kc = e.keyCode
  }
  else if(e.which) // Netscape/Firefox/Opera
  {
    kc = e.which
  }
    if (((kc >= 96) && (kc <= 105)) || ((kc >= 48) && (kc <= 57)) || (kc == 46) || (kc == 8) || (kc == 9) || (kc == 37) || (kc == 39) || (kc == 189))
		return true;
	else
		return false;
}

//Added for 1K Giveaway page. COMPJP
function auto_tab(field_val, field_len, next, e)
{
   var key = window.event ? e.keyCode : e.which;
   if (key != 9 && key != 16)
   {
     f_new_field = f_new_field || (last_next != next) ;
     last_next = next ;

     if (!f_new_field)
     {
       if (field_val.length >= field_len)
       {
         f_new_field = true ;
         eval(next) ;
       }
     }
     else
     {
       f_new_field = false ;
     }
   }
}
