var host = window.location.href;

// Review dashboard menu bar tabs Functions
// TODO: REMOVE THIS
$(".rv-db-menu-tabs").on("click",function(){
  var text = $(this).text();
  $(".rv-db-menu-tabs").removeClass("active");
  $(this).addClass("active");
  if(text.indexOf("Project Solutions")>=0){
    var target = "solutions_l.php?edit=true&id=" + G_PROJECT_ID;
    var win = window.open(target,"_self");

 }
  else if(text.indexOf("Summary")>=0){
    var target = "project_summary.php?edit=true&id=" + G_PROJECT_ID;
    var win = window.open(target,"_self");
  }
  else if(text.indexOf("Preliminary Review")>=0){
    var target = "project_feedback.php?edit=true&id=" + G_PROJECT_ID;
    var win = window.open(target,"_self");
  }
  else if(text.indexOf("Full Review")>=0){
    var target = "projectfullreview.php?edit=true&id=" + G_PROJECT_ID;
    var win = window.open(target,"_self");
  }
});

var is_solution = host.indexOf(SOLUTIONS_PAGE) >= 0;
var is_udcert = host.indexOf(IS_UD_CERT_PAGE) >= 0; 
var is_prel_review = host.indexOf(PRELIMINARY_REVIEW_PAGE) >=0;  
var is_full_review = host.indexOf(FULL_REVIEW_PAGE) >=0;
if(is_solution || is_udcert || is_prel_review || is_full_review) {
    $("#solutions-title-bar")[0].style.display = "inline-block";
}    

$(document).ready(function () {
    if(is_solution) {$("#title-bar-solutions").addClass("solutions-active-link");}
    if(is_udcert) {$("#title-bar-isUD-cert").addClass("solutions-active-link");}
    if(is_prel_review) {$("#title-bar-prem-review").addClass("solutions-active-link");}
    if(is_full_review) {$("#title-bar-full-review").addClass("solutions-active-link");}
});

$(".solutions-title-bar-items").on("click", function(){
    var text = $(this).text();
    $(".solutions-title-bar-items").removeClass("solutions-active-link");
    $(this).addClass("solutions-active-link");
    // console.log(text)
    
  if(text.indexOf("Solutions")>=0){
    var target = SOLUTIONS_PAGE + "?edit=true&id=" + G_PROJECT_ID;
    var win = window.open(target,"_self");
 }
  else if(text.indexOf("isUD Certified")>=0){
    var target = IS_UD_CERT_PAGE + "?edit=true&id=" + G_PROJECT_ID;
    var win = window.open(target,"_self");
  }
  else if(text.indexOf("Preliminary Review")>=0){
    var target = PRELIMINARY_REVIEW_PAGE +"?edit=true&id=" + G_PROJECT_ID;
    var win = window.open(target,"_self");
  }
  else if(text.indexOf("Full Review")>=0){
    var target = FULL_REVIEW_PAGE + "?edit=true&id=" + G_PROJECT_ID;
    var win = window.open(target,"_self");
  }
    
});;