from django import template
from django.http import HttpRequest
from django.template import RequestContext


register = template.Library()

@register.simple_tag


def tabs(current_page, hq_mode=False):

    if hq_mode:
        tabs = _hq_tabs()
    else:
        tabs = _doctor_tabs()
    

    t = '<div class="buttons">'
    
    for i in tabs:
        bgcolor = "#c3d9ff" if i == current_page else "#fff"
        #t+= '<a href="/intel/%s" style="background-color: %s">%s</a>\n' % (i, bgcolor, tabs[i]["text"])
        but = '<a href="/intel/%s" style="background-color: %s"><img class="left" src="%s"/><span style="vertical-align:top">%s</span></a>' % (i, bgcolor, tabs[i]["icon"], tabs[i]["text"])

        # if i == current_page or current_page == "home":
        #     t += but 
        t+=but

    if current_page != "home":
        t += '<a href="/intel/" style="float: right; width: 90px"><img src="/static/intel/img/icons/home-icon.png" /></a>'
    t += "</div>"
    
    # if tabs.has_key(current_page): 
        # t += '<script type="text/javascript">$("#header").css("border-bottom-color", "%s");</script>' % tabs[current_page]["color"]

    return t



def _doctor_tabs():
    return { "all" : 
                {
                    "text" : "Pregnant Mothers",
                    # "color": "#ff6100",
                    "icon" : "/static/intel/img/icons/preg-icon.png"
                },

             "risk":  
                {
                    "text" : "High Risk",
                    # "color": "#82c700",
                    "icon" : "/static/intel/img/icons/risk-icon.png"
                },
              "chart": 
                {
                    "text" : "Program Trends",
                    # "color": "#0099ff",
                    "icon" : "/static/intel/img/icons/trends-icon.png"
                }
            }

def _hq_tabs():
    return { "hq_risk":  
                {
                    "text" : "High Risk",
                    # "color": "#82c700",
                    "icon" : "/static/intel/img/icons/risk-icon.png"
                },
              "hq_chart": 
                {
                    "text" : "Program Trends",
                    # "color": "#0099ff",
                    "icon" : "/static/intel/img/icons/trends-icon.png"
                }
            }
    
@@ -352,19 +352,35 @@
     
-bgcolor = %22
+style = %22border: solid 4px 
 #c3d
@@ -415,119 +415,10 @@
 se %22
-#fff
 %22%0A
-        #t+= '%3Ca href=%22/intel/%25s%22 style=%22background-color: %25s%22%3E%25s%3C/a%3E%5Cn' %25 (i, bgcolor, tabs%5Bi%5D%5B%22text%22%5D)%0A
     
@@ -459,26 +459,8 @@
 le=%22
-background-color: 
 %25s%22%3E
@@ -545,15 +545,13 @@
 (i, 
-bgcolor
+style
 , ta
@@ -583,16 +583,73 @@
 ext%22%5D)%0A%0A
+        # uncomment to show only the currnent page icon %0A
         
@@ -702,32 +702,8 @@
 e%22:%0A
-        #     t += but %0A
     

change icons border instead of background