





var metroRegURL = "https://register.metro.co.uk/MetroRegWebApp";
var anmRegURL = "https://register.anm.co.uk";
var regBloggingPath = "/loginTopicalBlog";
var regMoviesPath = "/loginYourMovies";
var regPhotosPath = "/loginYourPhotos";
var regVideosPath = "/loginYourVideos";
var regMusicPath = "/loginYourMusic";
var regMolePath = "/loginMetroMoleCompetition";
var szUserid=getCookie("userid");

function doLogon(doc) {
   doc.logon.action=  metroRegURL  + "/login?redirectPath="+encodeURIComponent(doc.URL);
   doc.logon.redirectPath.value=document.URL;
   doc.logon.submit();
}
function doLogout(in_redirect_url){
   var protectedUrl = false ;
   
   deleteCookie("userid","/","metro.co.uk") ;
   deleteCookie("subuserid","/","metro.co.uk") ;
   deleteCookie("email","/","metro.co.uk") ;
   
   if (protectedUrl) {
      v_redirect_url = location.protocol + "//" + location.host + "/" ;
   } else {
      v_redirect_url = in_redirect_url;   
   }
   window.location = v_redirect_url;
}
function getLogonFunction(doc) {
   if(szUserid) {
      doLogout(doc.URL) ;
   }
   else {
      doLogon(doc) ;
   }
}
function doBlogTopicLogon(doc) {
   var redirU = location.protocol + "//" + location.host + "/blog-topic" ;
   if (szUserid) {
	   window.location = redirU;
   } else {
      doc.action = metroRegURL + regBloggingPath;
      doc.redirectPath.value = redirU;
      doc.submit();   
   }
}
function doMoviesLogon(doc) {
   var redirU = location.protocol + "//" + location.host + "/your-movies" ;
   if (szUserid) {
	   window.location = redirU;
   } else {
      doc.action = metroRegURL + regMoviesPath;
      doc.redirectPath.value = redirU;
      doc.submit();   
   }
}
function doPhotoLogon(doc,redir) {
   var redirU =  location.protocol + "//" + location.host + redir;
   if (szUserid) {
	   window.location = redirU;
   } else {
      doc.action = metroRegURL + regPhotosPath;
      doc.redirectPath.value = redirU;
      doc.submit();   
   }
}

function doArtLogon(doc,redir) {
   var redirU =  location.protocol + "//" + location.host + redir;
   if (szUserid) {
	   window.location = redirU;
   } else {
      doc.action = metroRegURL + "/login";
      doc.redirectPath.value = redirU;
      doc.submit();   
   }
}

function doVideoLogon(doc,redir) {
   var redirU =  location.protocol + "//" + location.host + redir;
   if (szUserid) {
	   window.location = redirU;
   } else {
      doc.action = metroRegURL + regVideosPath;
      doc.redirectPath.value = redirU;
      doc.submit();   
   }
}
function doMusicLogon(doc) {
   var redirU = location.protocol + "//" + location.host + "/your-music" ;
   if (szUserid) {
	   window.location = redirU;
   } else {
      doc.action = metroRegURL + regMusicPath;
      doc.redirectPath.value = redirU;
      doc.submit();   
   }
}
function doMoleLogon(doc,comp_id) {
   var v_compid=comp_id;
   if (szUserid) {
	   window.location = anmRegURL + "/register/comp.htm?in_userid=" + szUserid + "&in_competition_id=" + comp_id ;
   } else {
      doc.action = metroRegURL + regMolePath;
      doc.EntryPath.value= anmRegURL + "/register/comp.htm";
      doc.CompId.value=v_compid;
      doc.submit();   
   }
}
function doCompLogon(doc,comp_id){
   var v_compid=comp_id;
   if (szUserid) {
      window.location = anmRegURL + "/register/comp.htm?in_userid=" + szUserid + "&in_competition_id=" + comp_id ;
   } else {
      doc.action = metroRegURL + "/loginCompetition";
      doc.EntryPath.value = anmRegURL + "/register/comp.htm";
      doc.CompId.value=v_compid;
      doc.submit();
   }
}
function docomp(doc,comp_id) {
   doCompLogon(doc,comp_id) ;
}

function doBookLogon(doc,comp_id){
   var v_compid=comp_id;
   if (szUserid) {
      window.location = anmRegURL + "/register/comp.htm?in_userid=" + szUserid + "&in_competition_id=" + comp_id ;
   } else {
      doc.action = metroRegURL + "/loginBooks";
      doc.EntryPath.value = anmRegURL + "/register/comp.htm";
      doc.CompId.value=v_compid;
      doc.submit();
   }
}
function dobook(doc,comp_id) {
   doBookLogon(doc,comp_id) ;
}
