var erecapUserId = dojo.cookie("erecapUser");
var queryObj = dojo.queryToObject(location.search.substring(1));

var signInContent = 
'<script>function loadFunc (data, ioArgs) {if (dojo.cookie.isSupported() == false) {alert(\'Cookies are not supported so could not login!\'); return};dojo.cookie(\'erecapUser\', dojo.byId(\'erecapUser\').value, {expires: 730}); dojo.cookie(\'authorization\', data, {expires: 730});if (!queryObj.user == false) {delete queryObj.user}/*strip out login prams*/;if (!queryObj.password == false) {delete queryObj.password}/*strip out login prams*/; window.location = \'listing.htm?\'+ dojo.objectToQuery(queryObj);}; function errorFunc (data, ioArgs) {alert(\'Incorrect User or Password!!\')} </script>' +
'	<form action="cgi-bin/erecapsrest.dll/login" method="post" style="float:right; clear:right" >'+
'		<span><input type="text"  size="20" id="erecapUser" name="user"><br/>Username or Email:</span>'+
'		<span><input type="password" id="erecapPassword" size="8" name="password"><br/>Password:</span>'+
'		<span><input type="button" id="signInBtn" value="Sign In" onclick="dojo.xhrGet({url:\'cgi-bin/erecapsrest.dll/login\',content: {user: dojo.byId(\'erecapUser\').value, password: dojo.byId(\'erecapPassword\').value},load:loadFunc,error:errorFunc, handleAs:\'text\',timeout: 90000})"></span>'+
//'		<input type="hidden" name="redirectok" value="../../../listing.htm">'+
//'		<input type="hidden" name="redirectfail" value="../../../signinhelp.htm">'+
'	</form>'+
'	<div style="float:right; margin-top:-5px;clear:right "><a href="registration.htm">or register</a></div>'+
'';

var signedInContent =
'<script>function erecapsLogOut () {dojo.cookie(\'authorization\', \'\', {expires: -1}); dojo.cookie(\'erecapUser\', \'\', {expires: -1}); window.location.reload();} </script>' +
'	<div style="float:right; margin-top:10px;clear:right;">'+
'		Welcome '+
'		<a href="../../../listing.htm?sellerid='+ erecapUserId +'" title="Show all of my Erecaps">'+ erecapUserId +'</a> | '+
//'		<a href="cgi-bin/erecapsrest.dll/manage" title="Manage my Erecaps">My Erecaps</a> |'+ 
'		<a href="#" onClick="erecapsLogOut()">Sign Out</a> '+
'	</div>'+
'';

if (!dojo.cookie("authorization")) {
	document.write('<div id="signinbox">'+ signInContent +'</div>');
} else {
	document.write('<div id="signinbox">'+ signedInContent +'</div>');
};



