using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class Controls_header : System.Web.UI.UserControl
{
public bool LoginRequired
{
get
{
if (ViewState["LoginRequired"] == null)
ViewState["LoginRequired"] = false;
return (bool)ViewState["LoginRequired"];
}
set
{
ViewState["LoginRequired"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
AddChatScript();
ShowMeChat();
if (SelectedButton != null)
{
HtmlAnchor a;
switch (SelectedButton)
{
case SelectedButtons.Marketing: a = topnav_marketing; break;
case SelectedButtons.ContactUs: a =topnav_contact; break;
case SelectedButtons.Green: a =topnav_green; break;
case SelectedButtons.Home: a = topnav_home; break;
case SelectedButtons.None: a = null; break;
case SelectedButtons.Prices: a = topnav_prices; break;
case SelectedButtons.Products: a = topnav_products; break;
case SelectedButtons.Services: a = topnav_services; break;
case SelectedButtons.Quotes: a = topnav_quotes; break;
case SelectedButtons.Templates: a = topnav_templates; break;
default: a = null; break;
/// Home, Products, Services, Marketing, Quotes, Templates, Prices, Green, ContactUs
}
if (a != null)
a.Attributes.Add("class", "selected");
}
if (IsPostBack)
{
string et = Request.Form["__EVENTTARGET"];
if (!String.IsNullOrEmpty(et) && (et == "login_link"))
{
Account.ActiveAccount = null;
if (LoginRequired)
Response.Redirect("~/login.aspx");
}
}
else
{
if (LoginRequired && (Account.ActiveAccount == null))
Response.Redirect("~/login.aspx");
}
}
private void AddChatScript()
{
string chatScript = "\r\n";
chatScript += "\r\n";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "openChat", chatScript);
string chatInitScript = "\r\n";
chatInitScript += "\r\n";
chatInitScript += "\r\n";
//chatInitScript += "\r\n\r\n";
chatInitScript += "\r\n\r\n";
Page.ClientScript.RegisterStartupScript(this.GetType(), "chatInit", chatInitScript);
}
private void ShowMeChat()
{
HyperLink a1 = new HyperLink();
a1.Attributes.Add("style", "position:relative;");
a1.Attributes.Add("OnClick", "openChat(); return false;");
a1.ID = "_lpChatBtn";
a1.NavigateUrl = "#";
HtmlImage img = new HtmlImage();
img.Src = "http://server.iad.liveperson.net/hc/4481995/?cmd=repstate&site=4481995&channel=web&ver=1&imageUrl=http://" + HttpContext.Current.Request.Url.Host.ToString() + "/images/chat";
img.ID = "hcIcon";
img.Border = 0;
a1.Controls.Add(img);
ChatImage.Controls.Add(a1);
}
public enum SelectedButtons {None, Home, Products, Services, Marketing, Quotes, Templates, Prices, Green, ContactUs};
private SelectedButtons _SelectedButton;
public SelectedButtons SelectedButton {
get { return _SelectedButton; }
set { _SelectedButton = value; }
}
protected void Page_Init(object Src, EventArgs E)
{
HttpRequest cr = HttpContext.Current.Request;
if (cr.QueryString["cc"] != null)
ShoppingCart.ActiveCart.CouponCode = cr.QueryString["cc"];
}
}