/**
 * Things to do for a user after they successfully register
 */
function login_success(){
    var tags=document.getElementsByTagName("a");
    for(var i=0; i < tags.length; i++){
	if(tags[i].className=="ctListingLink"){
	    var href=tags[i].getAttribute("hidden_href");
	    if(href){
		tags[i].setAttribute("href",href);
	    }
	}
    }
    //delete login notification area if exists
    var note=document.getElementById("trial_listing_login_container");
    if(note){
	var parent=document.getElementById("trial_listing_login_notification");
	parent.removeChild(note);
    }
}

/**
 * Things to do for unregistered user who comes to page
 */
function login_fail(){
    var tags=document.getElementsByTagName("a");
    for(var i=0; i < tags.length; i++){
	if(tags[i].className=="ctListingLink"){
	    var href=tags[i].getAttribute("href");
	    tags[i].setAttribute("hidden_href",href);
	    tags[i].setAttribute("href","javascript:login_click();");
	}
    }
	

    //look for login notification area
    var note=document.getElementById("trial_listing_login_notification");
    if(note){
	//container
	var container=document.createElement("div");
	container=note.appendChild(container);
	container.id="trial_listing_login_container";
	container.style.border="1px solid black";
	container.style.padding="2px";
	container.style.backgroundColor="#ececec";

	//text
	var text=document.createTextNode("Please ");
	container.appendChild(text);

	//register link
	var link=document.createElement("a");
	link=container.appendChild(link);
	link.onclick=login_click;
	link.style.cursor="pointer";
	link.style.textDecoration="underline";
	var text=document.createTextNode("REGISTER");
	link.appendChild(text);

	//more text
	var text=document.createTextNode(" to view details of these listings.  Registration is FREE and is completely secure.  We value your privacy.  Your details will never be sold or shared without your permission. Read our ");
	container.appendChild(text);

	//privacy policy link
	var link=document.createElement("a");
	link=container.appendChild(link);
	link.setAttribute("href","/privacy-security-policy.html");
	link.style.cursor="pointer";
	link.style.textDecoration="underline";
	var text=document.createTextNode("PRIVACY");
	link.appendChild(text);

	//more text
	var text=document.createTextNode(" policy.");
	container.appendChild(text);


    }
}
