function chatpop()
{
	WTonReady();
}

function isNonblank(s) { 
   var isNonblank_re    = /\S/; 
   return String (s).search (isNonblank_re) != -1 
}

function regIsEmail(fData) 
  { 
      var reg = new RegExp("^[0-9a-zA-Z\.]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$"); 
      return reg.test(fData); 
  }

function set_cookie(name, value)
{

var expdate = new Date (); // pre-set to the current time and date
expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * 24 * 365); // add one year to it 
//365 days/year * 24 hours/day * 60 minutes/hour * 60 seconds/minute * 1000 milliseconds/second
// = howevermany milliseconds/year. So this adds one year, it'll expire in one year.

document.cookie = name + "=" + escape(value) + "; expires=" + expdate.toGMTString() + "; path=/";
}

function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
 // In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
 var win = window.open(url,
  name,
  'width=' + w + ', height=' + h + ', ' +
  'location=yes, menubar=no, ' +
  'status=no, toolbar=no, scrollbars=yes, resizable=yes');
 win.resizeTo(w, h);
 win.focus();
}

testStatus = function () 
{
if (chat.status === "ready") 

{
	document.getElementById("ctch").style.display = "block";
	}
else
	{
	wopen('/en-us/customerservice/contactus/chatcontactus.aspx?a=|','popup',400,500);
	}
};

function WTonReady () {
chat = Wt.chat.PublicChat;
chat.init ({
statusCallback: testStatus,
startOptions: {
window: {
top: 100,
left: 100,
width: 425,
height: 600,
cssUrl: 'http://www.jockey.com/css/chat.css',
logoUrl: 'http://www.jockey.com/images/livehelp/HeadlineImage.jpg',
title: 'Chat with a Live Representative!'
}
}
});
}

function WTfname()
{
return document.Form1.wt_first.value;
}

function WTlname()
{
return document.Form1.wt_last.value;
}

function WTemail()
{
return document.Form1.wt_email.value;
}

function WTinittest()
{
return document.Form1.init_text.value;
}

btnChatNow_onClick = function () 
{
document.getElementById("emlb").style.display = "none";
document.getElementById("msgb").style.display = "none";

if (isNonblank(document.Form1.wt_email.value))
{
	if (!regIsEmail(document.Form1.wt_email.value))
	{
	document.getElementById("emlb").style.display = "block";
	return;
	}
}

if (!isNonblank(document.Form1.init_text.value))
{
document.getElementById("msgb").style.display = "block";
return;
}

if (document.Form1.wt_first.value == '')
 set_cookie ( "WTFirst", "null");
else	
 set_cookie ( "WTFirst", document.Form1.wt_first.value);
if (document.Form1.wt_last.value == '')
 set_cookie ( "WTLast", "null");
else 
 set_cookie ( "WTLast", document.Form1.wt_last.value);
if (document.Form1.wt_email.value == '')
 set_cookie ( "WTEmail", "null");
else
 set_cookie ( "WTEmail", document.Form1.wt_email.value);
 
 set_cookie ( "WTtxt", document.Form1.init_text.value);
 	chat.start({
    	initialText: 'message',
        info: {
            'Name_First': WTfname(),
            'Name_Last': WTlname(),
            'email': WTemail(),
            'message' : WTinittest()
           
        }
    });
 document.getElementById("ctch").style.display = "none";
}

