﻿var $j = jQuery.noConflict();

function queryString($ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i=0;i<gy.length;i++) {
        ft = gy[i].split("=");
        if (ft[0] == $ji) {
            return ft[1];
        }
    }
}
function getCookie($c_name){
    if (document.cookie.length>0){
        c_start=document.cookie.indexOf($c_name + "=");
        if (c_start!=-1) { 
            c_start=c_start + $c_name.length+1; 
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        }
        else{//window.location="dashboard.aspx?"+window.location.search.substring(1);
        }
    }
    else{//window.location="dashboard.aspx?"+window.location.search.substring(1);
    }
    return "";
}

// Chat With Us Function
var emailform = 'form_email';
var nameform = 'form_name';
var commentform = 'form_comment';


function send_wantachat() {
    if (document.getElementById(emailform).value.length > 0) {
        i=document.getElementById(emailform).value.indexOf("@")
        j=document.getElementById(emailform).value.indexOf(".",i)
        k=document.getElementById(emailform).value.indexOf(",")
        kk=document.getElementById(emailform).value.indexOf(" ")
        jj=document.getElementById(emailform).value.lastIndexOf(".")+1
        len=document.getElementById(emailform).value.length

        if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) {
            //alert("ok");
        } 
        else {
            alert("Please enter a correct email address.\n" +
            document.getElementById(emailform).value + " is invalid.");
            return false;
        }
    }
    if (document.getElementById(nameform).value.length == 0) {
        alert("Do you have a name?\n");
        return false;
    }
    if (document.getElementById(emailform).value.length == 0) {
        alert("Did you enter email correctly?\n");
        return false;
    }
    if (document.getElementById(commentform).value.length == 0) {
        alert("Please enter some comments for us to reply.\n");
        return false;
    }
    //var button = document.getElementById('btnSubmit');button.click();
    $get("form_submit").onclick = function() {};
    $get("form_submit").disabled = true;
    $get("form_submit").value = "Processing...";
    Webfuse.AJAXSendEmail($get(nameform).value,$get(emailform).value,$get(commentform).value,function(result) {if(result==1){$get("form_submit").value = "Sent!";}});
}

function $get(id) {return document.getElementById(id);}
function addfav(url,title)
{
    if (window.sidebar) { // firefox
         window.sidebar.addPanel(document.title,document.location.href,"");
         alert("Firefox user please use CTRL+D to bookmark this page.");
    } 
    else if(document.all) { //MSIE
        window.external.AddFavorite(document.location.href,document.title);
    }
    else if(window.opera && window.print){ // Opera
        var elem = document.createElement('a');
        elem.setAttribute('href',url);
        elem.setAttribute('title',title);
        elem.setAttribute('rel','sidebar');
        elem.click();
    } 
}

function $getHour()
{
   var d = new Date();
   var c_hour = d.getHours();
   return c_hour;
}
