﻿//Visualalized and Developed by Salvatore Joseph Aiello
//Dested@gmail.com
//7/01/08 v3.22
var $_ = function(id){
    return document.getElementById(id);
}
var HTML = {
    TEXT : function(id,value,text){
        var div=HTML.DIV();
        if(text)
            HTML.APPEND(div,HTML.SPAN(text));
        
        var d=document.createElement('input');
        d.setAttribute('type','text');
        if(id) d.setAttribute('id',id);
        if(value) d.setAttribute('value',value);    
        HTML.APPEND(div,d);
        return div;    
    },
    HIDDEN : function(id,value){ 
        var d=document.createElement('input');
        d.setAttribute('type','hidden');
        if(id) d.setAttribute('id',id);
        if(value) d.value=value;    
        return d;    
    },
    DIV : function(id){
        var d=document.createElement('div');
        if(id) d.setAttribute('id',id);
        d.style.display='inline';
        return d;
    },
    SPAN : function(text){
        var d=document.createElement('span');
        if(text) d.innerHTML=text;
        return d;
    },
    SUBMIT : function(id,text,onclick){ 
        
        var d=document.createElement('input');
        d.setAttribute('type','submit');
        if(id) d.setAttribute('id',id);
        if(text) d.setAttribute('value',text);    
        if(onclick) d.setAttribute('onclick',onclick);    
        return d;    
    },
    APPEND : function(a,b){
        a.appendChild(b);
    },
    LINK : function(href, text, onclick){
        var a=document.createElement('a');
        a.href=href;
        a.innerHTML=text;
        if(onclick)
            a.setAttribute('onclick',onclick);        
        return a;
    },
    RADIO : function(id,selected,value,name,onclick){
        var rad=document.createElement('input');
        rad.setAttribute('type','radio');
        if(id) rad.setAttribute('id',id);
        if(name) rad.setAttribute('name',name);
        if(selected) rad.setAttribute('checked',selected?'checked':'');
        if(value) rad.setAttribute('value',value);
        if(onclick) rad.setAttribute('onclick',onclick);
        return rad;
    },
    FOR : function(for_,text){
        var rad=document.createElement('label');
        rad.setAttribute('for',for_);
        rad.innerHTML=text;
        return rad;
    },
    BR : function(){
        return document.createElement('br');
    },
    RADIOLIST : function(id,text,items,default_){
        var div=HTML.DIV();
        HTML.APPEND(div,HTML.SPAN(text));        

        var table=document.createElement('table');
        table.setAttribute('id',id);
        var count=0;
        var tr=document.createElement('tr');
        for(var i=0;i<items.length;i++) {
            var item=items[i];
            var td=document.createElement('td');
            var r=HTML.RADIO(id.replace('Field','')+"_"+count,item.selected,item.value,id,item.onclick);
            var f=HTML.FOR(r.id,item.text);
            HTML.APPEND(td,r);
            HTML.APPEND(td,f);
            HTML.APPEND(tr,td);
            count++;
        }
        HTML.APPEND(table,tr);
        HTML.APPEND(div,table);
        return div;
    }
}


var WorkBlastJavaScript = {
    CurrentGUID: null,
    CurrentSessionGUID: null,
    Init: function() {
        WorkBlastJavaScript.Animation.Carousel.Carousels = new Array();
        WorkBlastJavaScript.Animation.Accordion.Accordions = new Array();
    },
    Login: {
        JobSeeker: {
            Login: function(aUsername, aPassword) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                var username = document.getElementById(aUsername).value;
                var password = document.getElementById(aPassword).value;
                WorkBlast.WebServices.WorkBlast.Login.LoginJobSeeker(username, password, WorkBlastJavaScript.Login.JobSeeker.LoginSucceed, WorkBlastJavaScript.Fail);
            },
            LoginSucceed: function(result) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();

                if (result == "-1") {
                    document.getElementById('theError').innerHTML = "Password Was Incorrect";
                    return;
                }
                if (result == "0") {
                    document.getElementById('theError').innerHTML = "User Does Not Exists";
                    return;
                }
                var GUID = result;
                WorkBlastJavaScript.CurrentGUID = GUID;

                window.location = "JobSeeker_Admin.aspx?GUID=" + GUID;
                //WorkBlast.WebServices.WorkBlast.Login.LoadJobSeekerInfo(GUID,WorkBlastJavaScript.AjaxContent.LoadLoginSucceed,WorkBlastJavaScript.Fail);
                //dosomething
            },
            Logout: function() {
                WorkBlast.WebServices.WorkBlast.Login.LogoutJobseeker(WorkBlastJavaScript.CurrentGUID, function(v) { window.location = 'Home.aspx'; });
            }
        },
        Employer: {
            Login: function(aUsername, aPassword) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                var username = document.getElementById(aUsername).value;
                var password = document.getElementById(aPassword).value;
                WorkBlast.WebServices.WorkBlast.Login.LoginEmployer(username, password, WorkBlastJavaScript.Login.Employer.LoginSucceed, WorkBlastJavaScript.Fail);
            },
            LoginSucceed: function(result) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();

                if (result == "-1") {
                    document.getElementById('theError').innerHTML = "Password Was Incorrect";
                    return;
                }
                if (result == "0") {
                    document.getElementById('theError').innerHTML = "User Does Not Exists";
                    return;
                }
                var GUID = result;
                WorkBlastJavaScript.CurrentGUID = GUID;

                window.location = "Employer_Admin.aspx?GUID=" + GUID;
                //   WorkBlast.WebServices.WorkBlast.Login.LoadEmployerInfo(GUID,WorkBlastJavaScript.AjaxContent.LoadLoginSucceed,WorkBlastJavaScript.Fail);
                //dosomething
            },
            Logout: function() {
                WorkBlast.WebServices.WorkBlast.Login.LogoutEmployer(WorkBlastJavaScript.CurrentGUID, function(v) { window.location = 'Home.aspx'; });
                window.location = 'Home.aspx';
            }
        },
        Advertiser: {
            Login: function(aUsername, aPassword) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                var username = document.getElementById(aUsername).value;
                var password = document.getElementById(aPassword).value;
                WorkBlast.WebServices.WorkBlast.Login.LoginAdvertiser(username, password, WorkBlastJavaScript.Login.Advertiser.LoginSucceed, WorkBlastJavaScript.Fail);
            },
            LoginSucceed: function(result) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                if (result == "-1") {
                    document.getElementById('theError').innerHTML = "Password Was Incorrect";
                    return;
                }
                if (result == "0") {
                    document.getElementById('theError').innerHTML = "User Does Not Exists";
                    return;
                }
                var GUID = result;
                WorkBlastJavaScript.CurrentGUID = GUID;
                if (window.location.href.indexOf('Advertise.aspx') >= 0)
                    LoadTab('Admin');
                else
                    window.location = ('Advertise.aspx?GUID=' + GUID)

            },
            Logout: function() {
                WorkBlast.WebServices.WorkBlast.Login.LogoutAdvertiser(WorkBlastJavaScript.CurrentGUID, function(v) { window.location = 'Home.aspx'; });
            }
        }
    },
    Master: {
        HeaderImageReset: function(that, new_, eh) {
            document.getElementById('theWhatIs').src = 'assets/images/btn_whatis.jpg';
            document.getElementById('theSearch').src = 'assets/images/btn_search.jpg';
            document.getElementById('theBlog').src = 'assets/images/btn_blog.jpg';
            document.getElementById('theRefer').src = 'assets/images/btn_refer.jpg';
            document.getElementById('theStore').src = 'assets/images/btn_store.jpg';
            document.getElementById('theMedia').src = 'assets/images/btn_media.jpg';
            document.getElementById('theJoin').src = 'assets/images/btn_join.jpg';
            document.getElementById('theAdvertise').src = 'assets/images/btn_advertise.jpg';
            that.src = new_;
            if (!eh)
                document.getElementById('theHomePicture').style.display = 'none';
        }

    },
    JobSeeker_Master: {
        HeaderImageReset: function(that, new_) {
            document.getElementById('theSearch').src = 'assets/images/js_btn_search.jpg';
            document.getElementById('theBlog').src = 'assets/images/js_btn_blog.jpg';
            document.getElementById('theRefer').src = 'assets/images/js_btn_refer.jpg';
            document.getElementById('theStore').src = 'assets/images/js_btn_store.jpg';
            document.getElementById('theMedia').src = 'assets/images/js_btn_media.jpg';
            document.getElementById('theAdvertise').src = 'assets/images/js_btn_advertise.jpg';
            that.src = new_;
        }
    },
    SignUp: {
        JobSeeker: {
            CheckEducation: function(that, ctr) {
                if (that.value == '4' || that.value == '5')
                    document.getElementById(ctr).style.display = 'block';
                else
                    document.getElementById(ctr).style.display = 'none';
            },
            SignUp: function() {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                var xml = '<JobSeeker><Property Name="UserName" Value="' + document.getElementById('theUsername').value + '" />';
                xml += '           <Property Name="Password" Value="' + document.getElementById('thePasswordCheck').value + '" />';
                /*                xml   += '           <Property Name="FirstName" Value="'+document.getElementById('theFirstName').value+'" />';
                xml   += '           <Property Name="LastName" Value="'+document.getElementById('theLastName').value+'" />';
                xml   += '           <Property Name="Address1" Value="'+document.getElementById('theAddress1').value+'" />';
                xml   += '           <Property Name="Address2" Value="'+document.getElementById('theAddress2').value+'" />';
                xml   += '           <Property Name="Phone" Value="'+document.getElementById('thePhone').value+'" />';
                xml   += '           <Property Name="StateName" Value="'+document.getElementById('theState').value+'" />';
                xml   += '           <Property Name="CityName" Value="'+document.getElementById('theCity').value+'" />';
                xml   += '           <Property Name="ZipcodeNumber" Value="'+document.getElementById('theZipcode').value+'" />';*/
                xml += '</JobSeeker>';
                WorkBlast.WebServices.WorkBlast.SignUp2.PostJobSeekerSignupInfo(xml, WorkBlastJavaScript.SignUp.JobSeeker.SignUpSucceed, WorkBlastJavaScript.Fail);
            },
            SignUpSucceed: function(v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();

                window.location = "JobSeeker_Admin.aspx?GUID=" + v;
                // WorkBlastJavaScript.Helper.LoadContent("SignUpConfirm");
            },
            CheckPassword: function(v, v2, note) {
                var pass1 = document.getElementById(v).value;
                var pass2 = document.getElementById(v2).value;
                if (pass1 != pass2) document.getElementById(note).innerHTML = 'Passwords do not match';
                if (pass1 == pass2 && pass1 != '') document.getElementById(note).innerHTML = 'Passwords Match';
            },
            UserName: {
                ShouldCheckUsername: new Array(),
                ResetCheckUsername: function() {
                    WorkBlastJavaScript.SignUp.JobSeeker.UserName.ShouldCheckUsername.push(false);
                },
                CheckUsername: function() {
                    WorkBlastJavaScript.SignUp.JobSeeker.UserName.ShouldCheckUsername.shift();
                    setTimeout('WorkBlastJavaScript.SignUp.JobSeeker.UserName.StillCheckUsername()', 1100);
                },
                StillCheckUsername: function() {
                    if (WorkBlastJavaScript.SignUp.JobSeeker.UserName.ShouldCheckUsername.length == 0) {
                        var username = document.getElementById('theUsername').value;
                        if (username == '') return;
                        WorkBlast.WebServices.WorkBlast.SignUp2.CheckUsername(username, WorkBlastJavaScript.SignUp.JobSeeker.UserName.CheckUsernameSucceed, WorkBlastJavaScript.Fail);
                    }
                },
                CheckUsernameSucceed: function(exists) {
                    if (exists == true) document.getElementById('theUsernameNote').innerHTML = "This Username Is Available";
                    else document.getElementById('theUsernameNote').innerHTML = "This Username Is Taken";
                }
            },
            ChooseType: function(that) {
                var id = that.id ? that.id : that;
                if ("JS" == WorkBlastJavaScript.Helper.GetRadioButtonSelected(id)) {
                    document.getElementById('theQuestions').style.display = "block";
                } else {
                    document.getElementById('theQuestions').style.display = "none";
                }
            },
            UpdatePhone: function(Phone, note) {
                var phone = document.getElementById(Phone).value;
                //    alert(phone);
                for (var i = 1; i <= 10; i++) {
                    if (phone.length < i) phone += ' ';
                    else if (WorkBlastJavaScript.Helper.TryParseInt(phone.substring(i - 1, i), 0) == 0) phone = phone.substring(0, i - 1);
                }
                var phoneReal = '(' + phone.substring(0, 3) + ')';
                phoneReal += '' + phone.substring(3, 6) + '-';
                phoneReal += '' + phone.substring(6, 10) + '';
                document.getElementById(note).innerHTML = phoneReal;
            }
        },
        Employer: {
            CheckEducation: function(that, ctr) {
                if (that.value == 'D' || that.value == 'E')
                    document.getElementById(ctr).style.display = 'block';
                else
                    document.getElementById(ctr).style.display = 'none';
            },
            SignUp: function() {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                var xml = '<Employer><Property Name="UserName" Value="' + document.getElementById('theUserNameE').value + '" />';
                xml += '           <Property Name="Password" Value="' + document.getElementById('thePasswordCheckE').value + '" />';
                /*    xml   += '           <Property Name="CompanyName" Value="'+document.getElementById('theCompanyNameE').value+'" />';
                xml   += '           <Property Name="Address1" Value="'+document.getElementById('theAddress1E').value+'" />';
                xml   += '           <Property Name="Address2" Value="'+document.getElementById('theAddress2E').value+'" />';
                xml   += '           <Property Name="Phone" Value="'+document.getElementById('thePhoneE').value+'" />';
                xml   += '           <Property Name="StateName" Value="'+document.getElementById('theStateE').value+'" />';
                xml   += '           <Property Name="CityName" Value="'+document.getElementById('theCityE').value+'" />';
                xml   += '           <Property Name="ZipcodeNumber" Value="'+document.getElementById('theZipcodeE').value+'" />';*/
                xml += '</Employer>';
                WorkBlast.WebServices.WorkBlast.SignUp2.PostEmployerSignupInfo(xml, WorkBlastJavaScript.SignUp.Employer.SignUpSucceed, WorkBlastJavaScript.Fail);
            },
            SignUpSucceed: function(v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                //dosomething
                window.location = "Employer_Admin.aspx?GUID=" + v;

                WorkBlastJavaScript.Helper.LoadContent("SignUpConfirm");
            },
            CheckPassword: function(v, v2, note) {
                var pass1 = document.getElementById(v).value;
                var pass2 = document.getElementById(v2).value;
                if (pass1 != pass2) document.getElementById(note).innerHTML = 'Passwords do not match';
                if (pass1 == pass2 && pass1 != '') document.getElementById(note).innerHTML = 'Passwords Match';
            },
            UserName: {
                ShouldCheckUsername: new Array(),
                ResetCheckUsername: function() {
                    WorkBlastJavaScript.SignUp.Employer.UserName.ShouldCheckUsername.push(false);
                },
                CheckUsername: function() {
                    WorkBlastJavaScript.SignUp.Employer.UserName.ShouldCheckUsername.shift();
                    setTimeout('WorkBlastJavaScript.SignUp.Employer.UserName.StillCheckUsername()', 1100);
                },
                StillCheckUsername: function() {
                    if (WorkBlastJavaScript.SignUp.Employer.UserName.ShouldCheckUsername.length == 0) {
                        var username = document.getElementById('theUserNameE').value;
                        if (username == '') return;
                        WorkBlast.WebServices.WorkBlast.SignUp2.CheckEmployerUsername(username, WorkBlastJavaScript.SignUp.Employer.UserName.CheckUsernameSucceed, WorkBlastJavaScript.Fail);
                    }
                },
                CheckUsernameSucceed: function(exists) {
                    if (exists == true) document.getElementById('theUsernameNoteE').innerHTML = "This Username Is Available";
                    else document.getElementById('theUsernameNoteE').innerHTML = "This Username Is Taken";
                }
            },
            ChooseType: function(that) {
                var id = that.id ? that.id : that;
                if ("JS" == WorkBlastJavaScript.Helper.GetRadioButtonSelected(id)) {
                    document.getElementById('theQuestions').style.display = "block";
                } else {
                    document.getElementById('theQuestions').style.display = "none";
                }
            },
            UpdatePhone: function(Phone, note) {
                var phone = document.getElementById(Phone).value;
                //    alert(phone);
                for (var i = 1; i <= 10; i++) {
                    if (phone.length < i) phone += ' ';
                    else if (WorkBlastJavaScript.Helper.TryParseInt(phone.substring(i - 1, i), 0) == 0) phone = phone.substring(0, i - 1);
                }
                var phoneReal = '(' + phone.substring(0, 3) + ')';
                phoneReal += '' + phone.substring(3, 6) + '-';
                phoneReal += '' + phone.substring(6, 10) + '';
                document.getElementById(note).innerHTML = phoneReal;
            }
        }
    },
    Animation: {
        WidgetSlider: {
            UpRotateImage: null,
            DownRotateImage: null,
            RunSpeed: 2,
            CountPer: 9,
            StartAnimateDownInit: function(that, ctr, id, DownRotate, UpRotate) {
                if (!document.getElementById(ctr))
                    alert(ctr);
                var height = document.getElementById(ctr).offsetHeight;

                document.getElementById(ctr).style.display = "block";
                document.getElementById(ctr).style.height = 0 + "px";
                //             document.getElementById(that).href="../Usercontrols/JobSeeker_Admin.aspx?Edit=true";
                if (document.getElementById(that))
                    document.getElementById(that).childNodes[0].setAttribute('onclick', "WorkBlastJavaScript.Animation.WidgetSlider.StartAnimateUp('" + that + "','" + ctr + "'," + height + "," + id + "); return false;");
                if (document.getElementById(that))
                    document.getElementById(that).href = "javascript:WorkBlastJavaScript.Animation.WidgetSlider.StartAnimateUp('" + that + "','" + ctr + "'," + height + "," + id + ")";
                document.getElementById(ctr).style.height = (0) + "px";
                WorkBlastJavaScript.Animation.WidgetSlider.DownRotateImage = DownRotate;
                WorkBlastJavaScript.Animation.WidgetSlider.UpRotateImage = UpRotate;

                WorkBlastJavaScript.Animation.WidgetSlider.AnimateDown(ctr, height, -10);
            },
            StartAnimateUpInit: function(that, ctr, id, DownRotate, UpRotate) {
                var height = document.getElementById(ctr).offsetHeight;
                document.getElementById(ctr).style.display = "block";
                //                document.getElementById(that).href="../Usercontrols/JobSeeker_Admin.aspx?Edit=true";
                if (document.getElementById(that))
                    document.getElementById(that).childNodes[0].setAttribute('onclick', "WorkBlastJavaScript.Animation.WidgetSlider.StartAnimateDown('" + that + "','" + ctr + "'," + height + "," + id + "); return false;");
                if (document.getElementById(that))
                    document.getElementById(that).href = "javascript:WorkBlastJavaScript.Animation.WidgetSlider.StartAnimateDown('" + that + "','" + ctr + "'," + height + "," + id + ")";
                //             document.getElementById(that).childNodes[0].onclick="WorkBlastJavaScript.Animation.WidgetSlider.StartAnimateDown('"+that+"','" + ctr + "'," + height + ","+id+");";
                document.getElementById(ctr).style.height = (height) + "px";
                WorkBlastJavaScript.Animation.WidgetSlider.DownRotateImage = DownRotate;
                WorkBlastJavaScript.Animation.WidgetSlider.UpRotateImage = UpRotate;
                WorkBlastJavaScript.Animation.WidgetSlider.AnimateUp(ctr, height, -10);
            },
            StartAnimateDown: function(that, ctr, height, id) {
                // PageMethods.OpenMenu(that,id,function (result,a,b){  })
                document.getElementById(ctr).style.display = "block";
                document.getElementById(ctr).style.height = 0 + "px";
                document.getElementById(that).childNodes[0].setAttribute('onclick', "WorkBlastJavaScript.Animation.WidgetSlider.StartAnimateUp('" + that + "','" + ctr + "'," + height + "," + id + "); return false;");
                document.getElementById(that).href = "javascript:WorkBlastJavaScript.Animation.WidgetSlider.StartAnimateUp('" + that + "','" + ctr + "'," + height + "," + id + ")";
                if (WorkBlastJavaScript.Animation.WidgetSlider.DownRotateImage)
                    document.getElementById(that).childNodes[0].src = WorkBlastJavaScript.Animation.WidgetSlider.DownRotateImage;
                document.getElementById(ctr).style.height = (0) + "px";
                WorkBlastJavaScript.Animation.WidgetSlider.AnimateDown(ctr, height, -10);
            },
            StartAnimateUp: function(that, ctr, height, id) {
                //PageMethods.CloseMenu(that,id,function (result,a,b){  })
                document.getElementById(ctr).style.display = "block";
                document.getElementById(that).childNodes[0].setAttribute('onclick', "WorkBlastJavaScript.Animation.WidgetSlider.StartAnimateDown('" + that + "','" + ctr + "'," + height + "," + id + "); return false;");
                document.getElementById(that).href = "javascript:WorkBlastJavaScript.Animation.WidgetSlider.StartAnimateDown('" + that + "','" + ctr + "'," + height + "," + id + ")";
                document.getElementById(ctr).style.height = (height) + "px";

                if (WorkBlastJavaScript.Animation.WidgetSlider.UpRotateImage)
                    document.getElementById(that).childNodes[0].src = WorkBlastJavaScript.Animation.WidgetSlider.UpRotateImage;
                WorkBlastJavaScript.Animation.WidgetSlider.AnimateUp(ctr, height, -10);
            },
            AnimateDown: function(ctr, aHeight, i) {
                var height = parseInt(document.getElementById(ctr).style.height.replace("px", ""));
                if (i > 200) i -= WorkBlastJavaScript.Animation.WidgetSlider.CountPer;
                i += WorkBlastJavaScript.Animation.WidgetSlider.CountPer;

                if (height + i < aHeight) {
                    if (height + i >= 0)
                        document.getElementById(ctr).style.height = (height + i) + 'px';
                    setTimeout("WorkBlastJavaScript.Animation.WidgetSlider.AnimateDown('" + ctr + "'," + aHeight + "," + i + ")", WorkBlastJavaScript.Animation.WidgetSlider.RunSpeed);
                }
                else {
                    //                    document.getElementById(ctr).style.height=aHeight+"px";
                    document.getElementById(ctr).style.height = "auto";
                }

            },
            AnimateUp: function(ctr, aHeight, i) {
                var height = parseInt(document.getElementById(ctr).style.height.replace("px", ""));
                if (i > 200) i -= WorkBlastJavaScript.Animation.WidgetSlider.CountPer;
                i += WorkBlastJavaScript.Animation.WidgetSlider.CountPer;
                if (height - i > 0) {
                    document.getElementById(ctr).style.height = (height - i) + "px";
                    setTimeout("WorkBlastJavaScript.Animation.WidgetSlider.AnimateUp('" + ctr + "'," + aHeight + "," + i + ")", WorkBlastJavaScript.Animation.WidgetSlider.RunSpeed);
                }
                else {
                    document.getElementById(ctr).style.height = 0 + "px";
                }
            }
        },
        SearchSlider: {
            RunSpeed: 2,
            CountPer: 4,
            StartAnimateDownInit: function(that, ctr, h) {
                var height;
                if (!h)
                    height = document.getElementById(ctr).offsetHeight;
                else height = h;

                document.getElementById(ctr).style.display = "block";
                document.getElementById(ctr).style.height = 0 + "px";
                if (document.getElementById(that))
                    document.getElementById(that).setAttribute('onclick', "WorkBlastJavaScript.Animation.SearchSlider.StartAnimateUp('" + that + "','" + ctr + "'," + height + "); return false;");
                if (document.getElementById(that))
                    document.getElementById(that).href = "javascript:WorkBlastJavaScript.Animation.SearchSlider.StartAnimateUp('" + that + "','" + ctr + "'," + height + ")";
                document.getElementById(ctr).style.height = (0) + "px";
                WorkBlastJavaScript.Animation.SearchSlider.AnimateDown(ctr, height, -10);
            },
            StartAnimateUpInit: function(that, ctr, h) {
                var height;
                if (!h)
                    height = document.getElementById(ctr).offsetHeight;
                else height = h;

                document.getElementById(ctr).style.display = "block";

                if (document.getElementById(that))
                    document.getElementById(that).setAttribute('onclick', "WorkBlastJavaScript.Animation.SearchSlider.StartAnimateDown('" + that + "','" + ctr + "'," + height + "); return false;");
                if (document.getElementById(that))
                    document.getElementById(that).href = "javascript:WorkBlastJavaScript.Animation.SearchSlider.StartAnimateDown('" + that + "','" + ctr + "'," + height + ")";
                //             document.getElementById(that).childNodes[0].onclick="WorkBlastJavaScript.Animation.SearchSlider.StartAnimateDown('"+that+"','" + ctr + "'," + height + ","+id+");";
                document.getElementById(ctr).style.height = (height) + "px";
                WorkBlastJavaScript.Animation.SearchSlider.AnimateUp(ctr, height, -10);
            },
            StartAnimateDown: function(that, ctr, height) {
                // PageMethods.OpenMenu(that,id,function (result,a,b){  })
                document.getElementById(ctr).style.display = "block";
                document.getElementById(ctr).style.height = 0 + "px";
                document.getElementById(that).setAttribute('onclick', "WorkBlastJavaScript.Animation.SearchSlider.StartAnimateUp('" + that + "','" + ctr + "'," + height + "); return false;");
                document.getElementById(that).href = "javascript:WorkBlastJavaScript.Animation.SearchSlider.StartAnimateUp('" + that + "','" + ctr + "'," + height + ")";
                document.getElementById(ctr).style.height = (0) + "px";
                WorkBlastJavaScript.Animation.SearchSlider.AnimateDown(ctr, height, -10);
            },
            StartAnimateUp: function(that, ctr, height) {
                //PageMethods.CloseMenu(that,id,function (result,a,b){  })
                document.getElementById(ctr).style.display = "block";
                document.getElementById(that).setAttribute('onclick', "WorkBlastJavaScript.Animation.SearchSlider.StartAnimateDown('" + that + "','" + ctr + "'," + height + "); return false;");
                document.getElementById(that).href = "javascript:WorkBlastJavaScript.Animation.SearchSlider.StartAnimateDown('" + that + "','" + ctr + "'," + height + ")";
                document.getElementById(ctr).style.height = (height) + "px";

                WorkBlastJavaScript.Animation.SearchSlider.AnimateUp(ctr, height, -10);
            },
            AnimateDown: function(ctr, aHeight, i) {
                var height = parseInt(document.getElementById(ctr).style.height.replace("px", ""));
                if (i > 200) i -= WorkBlastJavaScript.Animation.SearchSlider.CountPer;
                i += WorkBlastJavaScript.Animation.SearchSlider.CountPer;

                if (height + i < aHeight) {
                    if (height + i >= 0)
                        document.getElementById(ctr).style.height = (height + i) + 'px';
                    setTimeout("WorkBlastJavaScript.Animation.SearchSlider.AnimateDown('" + ctr + "'," + aHeight + "," + i + ")", WorkBlastJavaScript.Animation.SearchSlider.RunSpeed);
                }
                else {
                    //                    document.getElementById(ctr).style.height=aHeight+"px";
                    document.getElementById(ctr).style.height = "auto";
                }

            },
            AnimateUp: function(ctr, aHeight, i) {
                var height = parseInt(document.getElementById(ctr).style.height.replace("px", ""));
                if (i > 200) i -= WorkBlastJavaScript.Animation.SearchSlider.CountPer;
                i += WorkBlastJavaScript.Animation.SearchSlider.CountPer;
                if (height - i > 0) {
                    document.getElementById(ctr).style.height = (height - i) + "px";
                    setTimeout("WorkBlastJavaScript.Animation.SearchSlider.AnimateUp('" + ctr + "'," + aHeight + "," + i + ")", WorkBlastJavaScript.Animation.SearchSlider.RunSpeed);
                }
                else {
                    document.getElementById(ctr).style.height = 0 + "px";
                }
            }
        },
        Carousel: {
            Carousels: new Array(),
            LoadCarousel: function(carouselName) {
                for (var i = 0; i < WorkBlastJavaScript.Animation.Carousel.Carousels.length; i++)
                    if (WorkBlastJavaScript.Animation.Carousel.Carousels[i] == carouselName)
                    return;
                WorkBlastJavaScript.Animation.Carousel.Carousels.push(carouselName);
                new UI.Carousel(carouselName);
            }
        },
        Accordion: {
            Accordions: new Array(),
            LoadVerticalAccordion: function(containerName, toggle, toggle_active, content, width, height, speed) {
                for (var i = 0; i < WorkBlastJavaScript.Animation.Accordion.Accordions.length; i++)
                    if (WorkBlastJavaScript.Animation.Accordion.Accordions[i] == containerName)
                    return;
                WorkBlastJavaScript.Animation.Accordion.Accordions.push(containerName);

                if (!width) width = 125;
                if (!height) height = 0;
                if (!speed) speed = 8;

                var nestedVerticalAccordion = new accordion(containerName, {
                    resizeSpeed: speed,
                    classNames: {
                        toggle: toggle,
                        toggleActive: toggle_active,
                        content: content
                    }, defaultSize: {
                        width: width,
                        height: height
                    }
                });

                // Open first one
                nestedVerticalAccordion.activate($$('#' + containerName + ' .' + toggle + '')[0]);

                var verticalAccordions = $$('.' + toggle + '');
                verticalAccordions.each(function(accordion) {
                    $(accordion.next(0)).setStyle({
                        height: '0px'
                    });
                });
            }
        }
    },
    AjaxContent: {
        Cart: {
            CartGuid: '',
            CartName: '',
            Start: function(guid, cartName) {
                alert(guid);
                CartName = cartName;
                CartGuid = guid;
            },
            AddItem: function(name) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlast.WebServices.WorkBlast.Store.AddItemToCart(WorkBlastJavaScript.AjaxContent.Cart.CartGuid, name, function(v) { WorkBlastJavaScript.AjaxContent.Cart.UpdateItem(name, v); });
            },
            UpdateItem: function(name, v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();

            }
        },
        HomePageReferFriend: function(yourname, theirname, theiremail) {
            WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            WorkBlast.WebServices.LoadControl.HomePageReferFriend($_(yourname).value, $_(theirname).value, $_(theiremail).value, function(v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); $_('theReferError').innerHTML = v;
            }, WorkBlastJavaScript.Fail);
        },
        Upload: function(formName, onUpload) {
            WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            //the second argument of setForm is crucial,
            //which tells Connection Manager this is a file upload form
            YAHOO.util.Connect.setForm(formName, true);
            var uploadHandler = {
                upload: function(o) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                    onUpload(WorkBlastJavaScript.Helper.TextToJson(o));
                }
            };
            YAHOO.util.Connect.asyncRequest('POST', 'http://www.workblast.com/Upload.ashx?Ses=' + WorkBlastJavaScript.CurrentGUID, uploadHandler);
            //            YAHOO.util.Connect.asyncRequest('POST', 'http://localhost:3361/Upload.ashx?Ses='+WorkBlastJavaScript.CurrentGUID, uploadHandler);
        },
        RotateUploadLink: function(link) {
            link = document.getElementById(link);
            link.innerHTML = "Click here when done!";
            link.href = 'JobSeeker_Admin.aspx?#';
            link.setAttribute('onclick', "LoadTab('theProfileTab','profile');return false;");
        },
        JobSeeker: {
            OnWidgetsLoaded: function() { },
            Widgets: new Array(),
            LoadWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.JobSeeker.Widgets.push(false);

                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 1, false, false, null, function(v) { WorkBlastJavaScript.AjaxContent.JobSeeker.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 1, false, false, args, function(v) { WorkBlastJavaScript.AjaxContent.JobSeeker.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadEditWidget: function(widget, widgetContainer) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.JobSeeker.Widgets.push(false);
                WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 1, false, true, null, function(v) { WorkBlastJavaScript.AjaxContent.JobSeeker.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadWidgetSucceed: function(widget, v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                document.getElementById(widget).innerHTML = unescape(v[0]);
                eval(v[1]);
                WorkBlastJavaScript.AjaxContent.JobSeeker.Widgets.shift();
                if (WorkBlastJavaScript.AjaxContent.JobSeeker.Widgets.length == 0) {
                    WorkBlastJavaScript.AjaxContent.JobSeeker.OnWidgetsLoaded();
                }
            }
        },
        JobSeekerAdmin: {
            OnWidgetsLoaded: function() { },
            Widgets: new Array(),
            LoadWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.JobSeekerAdmin.Widgets.push(false);

                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 1, true, false, null, function(v) { WorkBlastJavaScript.AjaxContent.JobSeekerAdmin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 1, true, false, args, function(v) { WorkBlastJavaScript.AjaxContent.JobSeekerAdmin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadEditWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.JobSeekerAdmin.Widgets.push(false);
                //fixed args==0
                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 1, true, true, null, function(v) { WorkBlastJavaScript.AjaxContent.JobSeekerAdmin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 1, true, true, (args == -1 ? args - 1 : args), function(v) { WorkBlastJavaScript.AjaxContent.JobSeekerAdmin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadWidgetSucceed: function(widget, v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                document.getElementById(widget).innerHTML = unescape(v[0]);
                eval(v[1]);
                WorkBlastJavaScript.AjaxContent.JobSeekerAdmin.Widgets.shift();
                if (WorkBlastJavaScript.AjaxContent.JobSeekerAdmin.Widgets.length == 0) {
                    WorkBlastJavaScript.AjaxContent.JobSeekerAdmin.OnWidgetsLoaded();
                }
            },
            AddAutoGroup: function(industry, location) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                industry = document.getElementById(industry).value;
                location = document.getElementById(location).value;
                WorkBlast.WebServices.WorkBlast.SignUp2.AddAutoGroupToJobSeeker(industry, location, WorkBlastJavaScript.CurrentGUID, function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                });
            },
            ViewAutoGroup: function(industry, location) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                industry = document.getElementById(industry).value;
                location = document.getElementById(location).value;
                WorkBlast.WebServices.WorkBlast.SignUp2.ViewAutoGroup(industry, location, 'J', function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                });
            },
            AddUserGroup: function(type, name) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                type = document.getElementById(type).value;
                name = document.getElementById(name).value;
                WorkBlast.WebServices.WorkBlast.SignUp2.AddUserGroupToJobSeeker(type, name, WorkBlastJavaScript.CurrentGUID, function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                });
            },
            ViewUserGroup: function(type, name) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                type = document.getElementById(type).value;
                name = document.getElementById(name).value;
                WorkBlast.WebServices.WorkBlast.SignUp2.ViewUserGroup(type, name, 'J', function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                });
            },
            Upload: function(formName, onUpload) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                //the second argument of setForm is crucial,
                //which tells Connection Manager this is a file upload form
                YAHOO.util.Connect.setForm(formName, true);
                var uploadHandler = {
                    upload: function(o) {
                        WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                        window.close();
                    }
                };
                //                YAHOO.util.Connect.asyncRequest('POST', 'http://localhost:3361/Upload.ashx?Type=J&Ses='+WorkBlastJavaScript.CurrentGUID, uploadHandler);
                YAHOO.util.Connect.asyncRequest('POST', 'http://www.workblast.com/Upload.ashx?Type=J&Ses=' + WorkBlastJavaScript.CurrentGUID, uploadHandler);
            }
        },
        EmployerAdmin: {
            OnWidgetsLoaded: function() { },
            Widgets: new Array(),
            LoadWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.EmployerAdmin.Widgets.push(false);
                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 2, true, false, null, function(v) { WorkBlastJavaScript.AjaxContent.EmployerAdmin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 2, true, false, args, function(v) { WorkBlastJavaScript.AjaxContent.EmployerAdmin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadEditWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.EmployerAdmin.Widgets.push(false);
                //fixed args==0
                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 2, true, true, null, function(v) { WorkBlastJavaScript.AjaxContent.EmployerAdmin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 2, true, true, (args == -1 ? args - 1 : args), function(v) { WorkBlastJavaScript.AjaxContent.EmployerAdmin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadWidgetSucceed: function(widget, v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                //                alert(widget);
                document.getElementById(widget).innerHTML = unescape(v[0]);
                eval(v[1]);
                WorkBlastJavaScript.AjaxContent.EmployerAdmin.Widgets.shift();

                if (WorkBlastJavaScript.AjaxContent.EmployerAdmin.Widgets.length == 0) {
                    WorkBlastJavaScript.AjaxContent.EmployerAdmin.OnWidgetsLoaded();

                }
            },
            PreviewImageFromProduct: function(productselect, preview) {
                document.getElementById(preview).src = productselect.value.split('|')[1];
            },
            AddAutoGroup: function(industry, location) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                industry = document.getElementById(industry).value;
                location = document.getElementById(location).value;
                WorkBlast.WebServices.WorkBlast.SignUp2.AddAutoGroupToEmployer(industry, location, WorkBlastJavaScript.CurrentGUID, function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                });
            },
            ViewAutoGroup: function(industry, location) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                industry = document.getElementById(industry).value;
                location = document.getElementById(location).value;
                WorkBlast.WebServices.WorkBlast.SignUp2.ViewAutoGroup(industry, location, 'E', function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                });
            },
            AddUserGroup: function(type, name) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                type = document.getElementById(type).value;
                name = document.getElementById(name).value;
                WorkBlast.WebServices.WorkBlast.SignUp2.AddUserGroupToEmployer(type, name, WorkBlastJavaScript.CurrentGUID, function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                });
            },
            ViewUserGroup: function(type, name) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                type = document.getElementById(type).value;
                name = document.getElementById(name).value;
                WorkBlast.WebServices.WorkBlast.SignUp2.ViewUserGroup(type, name, 'E', function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                });
            },
            Upload: function(formName, onUpload) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                //the second argument of setForm is crucial,
                //which tells Connection Manager this is a file upload form
                YAHOO.util.Connect.setForm(formName, true);
                var uploadHandler = {
                    upload: function(o) {
                        WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                        window.close();
                    }
                };
                //                YAHOO.util.Connect.asyncRequest('POST', 'http://localhost:3361/Upload.ashx?Type=E&Ses='+WorkBlastJavaScript.CurrentGUID, uploadHandler);
                YAHOO.util.Connect.asyncRequest('POST', 'http://www.workblast.com/Upload.ashx?Type=E&Ses=' + WorkBlastJavaScript.CurrentGUID, uploadHandler);
            }
        },
        Employer: {
            OnWidgetsLoaded: function() { },
            Widgets: new Array(),
            LoadWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.Employer.Widgets.push(false);

                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 2, false, false, null, function(v) { WorkBlastJavaScript.AjaxContent.Employer.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 2, false, false, args, function(v) { WorkBlastJavaScript.AjaxContent.Employer.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadEditWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.Employer.Widgets.push(false);
                //fixed args==0
                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 2, false, true, null, function(v) { WorkBlastJavaScript.AjaxContent.Employer.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 2, false, true, (args == -1 ? args - 1 : args), function(v) { WorkBlastJavaScript.AjaxContent.Employer.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadWidgetSucceed: function(widget, v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                document.getElementById(widget).innerHTML = unescape(v[0]);
                eval(v[1]);
                WorkBlastJavaScript.AjaxContent.Employer.Widgets.shift();
                if (WorkBlastJavaScript.AjaxContent.Employer.Widgets.length == 0) {
                    WorkBlastJavaScript.AjaxContent.Employer.OnWidgetsLoaded();
                }
            }
        },
        Advertiser: {

            OnWidgetsLoaded: function() { },
            Widgets: new Array(),
            LoadWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.Advertiser.Widgets.push(false);
                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 3, false, false, null, function(v) { WorkBlastJavaScript.AjaxContent.Advertiser.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 3, false, false, args, function(v) { WorkBlastJavaScript.AjaxContent.Advertiser.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadEditWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.Advertiser.Widgets.push(false);
                //fixed args==0
                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 3, false, true, null, function(v) { WorkBlastJavaScript.AjaxContent.Advertiser.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 3, false, true, (args == -1 ? args - 1 : args), function(v) { WorkBlastJavaScript.AjaxContent.Advertiser.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadWidgetSucceed: function(widget, v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                document.getElementById(widget).innerHTML = unescape(v[0]);
                eval(v[1]);
                WorkBlastJavaScript.AjaxContent.Advertiser.Widgets.shift();
                if (WorkBlastJavaScript.AjaxContent.Advertiser.Widgets.length == 0) {
                    WorkBlastJavaScript.AjaxContent.Advertiser.OnWidgetsLoaded();
                }
            },
            ViewPackages: function(form) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                var xml = WorkBlastJavaScript.Helper.Field.GrabFieldElements(document.getElementById(form.split('|')[0]), 0);
                WorkBlast.WebServices.LoadControl.PostXML((form.split('|').length == 2 ? form.split('|')[1] + "|" : "") + xml, WorkBlastJavaScript.CurrentGUID, function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                }, WorkBlastJavaScript.Fail);
            },
            Purchase: function(form) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                var xml = WorkBlastJavaScript.Helper.Field.GrabFieldElements(document.getElementById(form.split('|')[0]), 0);
                WorkBlast.WebServices.LoadControl.PostXML((form.split('|').length == 2 ? form.split('|')[1] + "|" : "") + xml, WorkBlastJavaScript.CurrentGUID, function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                }, WorkBlastJavaScript.Fail);
            },
            GetEffectedUsers: function(form) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                var xml = WorkBlastJavaScript.Helper.Field.GrabFieldElements(document.getElementById(form.split('|')[0]), 0);
                WorkBlast.WebServices.LoadControl.PostXML((form.split('|').length == 2 ? form.split('|')[1] + "|" : "") + xml, WorkBlastJavaScript.CurrentGUID, function(v) {
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
                }, WorkBlastJavaScript.Fail);
            },
            Upload: function(formName, onUpload) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                //the second argument of setForm is crucial,
                //which tells Connection Manager this is a file upload form
                YAHOO.util.Connect.setForm(formName, true);
                var uploadHandler = {
                    upload: function(o) {
                        WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                        window.close();
                    }
                };
                YAHOO.util.Connect.asyncRequest('POST', 'http://www.workblast.com/Upload.ashx?Type=A&Ses=' + WorkBlastJavaScript.CurrentGUID, uploadHandler);
            }
        },
        Admin: {
            OnWidgetsLoaded: function() { },
            Widgets: new Array(),
            LoadWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.Admin.Widgets.push(false);
                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 4, false, false, null, function(v) { WorkBlastJavaScript.AjaxContent.Admin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 4, false, false, args, function(v) { WorkBlastJavaScript.AjaxContent.Admin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadEditWidget: function(widget, widgetContainer, args) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlastJavaScript.AjaxContent.Admin.Widgets.push(false);
                //fixed args==0
                if (!args)
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 4, false, true, null, function(v) { WorkBlastJavaScript.AjaxContent.Admin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
                else
                    WorkBlast.WebServices.LoadControl.LoadWidget(widget, WorkBlastJavaScript.CurrentGUID, 4, false, true, (args == -1 ? args - 1 : args), function(v) { WorkBlastJavaScript.AjaxContent.Admin.LoadWidgetSucceed(widgetContainer, v); }, WorkBlastJavaScript.Fail);
            },
            LoadWidgetSucceed: function(widget, v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                document.getElementById(widget).innerHTML = unescape(v[0]);
                eval(v[1]);
                WorkBlastJavaScript.AjaxContent.Admin.Widgets.shift();
                if (WorkBlastJavaScript.AjaxContent.Admin.Widgets.length == 0) {
                    WorkBlastJavaScript.AjaxContent.Admin.OnWidgetsLoaded();
                }
            },
            Upload: function(formName, onUpload) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                //the second argument of setForm is crucial,
                //which tells Connection Manager this is a file upload form
                YAHOO.util.Connect.setForm(formName, true);
                var uploadHandler = {
                    upload: function(o) {
                        WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                        window.close();
                    }
                };
                YAHOO.util.Connect.asyncRequest('POST', 'http://www.workblast.com/Upload.ashx?Type=Admin&Ses=' + WorkBlastJavaScript.CurrentGUID, uploadHandler);
            },
            LoadAdmin: function(type, val) {
                val = escape(document.getElementById(val).value);
                WorkBlast.WebServices.LoadControl.PostAdmin(type, val, WorkBlastJavaScript.CurrentSessionGUID, function(v) { alert(v); }, WorkBlastJavaScript.Fail);
            }
        },
        Loading: {
            StartLoading: function() {
                //     alert(document.getElementById('theLoading').style.display);
                document.body.style.cursor = 'progress';
                if (document.getElementById('theLoading')) {
                    document.getElementById('theLoading').style.display = 'block';
                }
            },
            EndLoading: function() {
                //       alert(document.getElementById('theLoading').style.display);
                document.body.style.cursor = 'default';
                if (document.getElementById('theLoading')) {
                    document.getElementById('theLoading').style.display = 'none';
                }
            }
        },
        PostReferAFriend: function(form) {
            WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            var xml = WorkBlastJavaScript.Helper.Field.GrabFieldElements(document.getElementById(form.split('|')[0]), 0);

            WorkBlast.WebServices.LoadControl.PostReferAFriend(WorkBlastJavaScript.CurrentGUID, xml, function(v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
            }, WorkBlastJavaScript.Fail);

        },
        PostReferAFriendWithEmails: function(form) {
            WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            var xml = WorkBlastJavaScript.Helper.Field.GrabFieldElements(document.getElementById(form.split('|')[0]), 0);

            WorkBlast.WebServices.LoadControl.PostXML(xml, WorkBlastJavaScript.CurrentGUID, function(v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
            }, WorkBlastJavaScript.Fail);

        },
        PostXML: function(form) {
            var xml = WorkBlastJavaScript.Helper.Field.GrabFieldElements(document.getElementById(form.split('|')[0]), 0);

            WorkBlast.WebServices.LoadControl.PostXML((form.split('|').length == 2 ? form.split('|')[1] + "|" : "") + xml, WorkBlastJavaScript.CurrentGUID, function(v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
            }, WorkBlastJavaScript.Fail);
        },
        LoadLoginSucceed: function(login) {
            document.getElementById('theLogin').innerHTML = login;
        },
        LoadLatest: function(str, arg) {
            WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            WorkBlast.WebServices.LoadControl.LoadContent(str, arg ? arg : null, function(v) {
                document.title = "Workblast :: " + str;
                WorkBlastJavaScript.AjaxContent.LoadLatestSucceed(v);
            }, WorkBlastJavaScript.Fail);
        },
        LoadLatestSucceed: function(latest) {
            WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
            document.getElementById('theLatest').innerHTML = unescape(latest);
        },
        FillKeyword: function(that, field) {
            WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            if (document.getElementById(that).value.length > 2)
                WorkBlast.WebServices.Utilities.GetKeywordSearchInfo(document.getElementById(that).value, function(v) { WorkBlastJavaScript.AjaxContent.FillKeywordSucceed(that, field, v); }, WorkBlastJavaScript.Fail);
        },
        UserGroups: {
            FillAlumni: function(that, where) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                if (that.value == 1) {
                    var select;
                    if (!$_('theAlumniStates')) {
                        WorkBlastJavaScript.Helper.RemoveChildNodes($_(where))
                        select = document.createElement('select');
                        select.setAttribute('id', 'theAlumniStates');
                        select.style.width = '270px';
                        select.setAttribute('onchange', 'WorkBlastJavaScript.AjaxContent.UserGroups.FillColleges(this,\'' + where + '\');');
                        HTML.APPEND($_(where), HTML.SPAN('University State'));
                        HTML.APPEND($_(where), select);
                    }
                    else { select = $_('theAlumniStates'); }

                    WorkBlastJavaScript.AjaxContent.State.UpdateState(select.id);
                } else {
                    var input;
                    if (!$_('theUserGroupName')) {
                        WorkBlastJavaScript.Helper.RemoveChildNodes($_(where))
                        input = document.createElement('input');
                        input.setAttribute('id', 'theUserGroupName');
                        input.style.width = '270px';
                        HTML.APPEND($_(where), HTML.SPAN('Group Name'));
                        HTML.APPEND($_(where), input);
                    }
                    else { input = $_('theUserGroupName'); }
                    WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                }
            },
            FillColleges: function(that, where) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                var select;
                if (!$_('theAlumniColleges')) {
                    select = document.createElement('select');
                    select.setAttribute('id', 'theAlumniColleges');
                    select.style.width = '270px';
                    HTML.APPEND($_(where), HTML.BR());
                    HTML.APPEND($_(where), HTML.SPAN('University'));

                    HTML.APPEND($_(where), select);
                }
                else { select = $_('theAlumniColleges'); }
                WorkBlastJavaScript.AjaxContent.Colleges.FillColleges(that, select.id);
            }
        },
        SlideSearch: function(slide) {


        },


        FillKeywordSucceed: function(that, where, v) {
            WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
            WorkBlastJavaScript.Helper.RemoveChildNodes(document.getElementById(where));
            var op;
            try {
                op = v.evalJSON();
            } catch (a) {
                op = eval('(' + v + ')');
            }
            for (var i = 0; i < op.Options.option.length; i++) {
                var span = document.createElement('a');
                span.className = 'SearchItem';
                span.href = '#';
                span.setAttribute('onclick', 'document.getElementById(\'' + document.getElementById(that).id + '\').value=\'' + op.Options.option[i].name + '\';WorkBlastJavaScript.AjaxContent.FillKeyword(\'theKeyword\',\'theSearchContent\');');
                span.innerHTML = op.Options.option[i].name;
                document.getElementById(where).appendChild(span);
            }
            WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
        },
        Colleges: {
            FillColleges: function(that, field) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlast.WebServices.Utilities.GetCollegesByState(that.value ? that.value : that, function(v) { WorkBlastJavaScript.AjaxContent.Colleges.FillCollegesSucceed(v, field); }, WorkBlastJavaScript.Fail);
                that.disabled = false;
            },
            FillCollegesSucceed: function(v, field) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                document.getElementById(field).disabled = false;

                WorkBlastJavaScript.Helper.JsonToSelect(field, v);
            }
        },
        Location: {
            FillLocation: function(that, field, notSpec) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                if (!notSpec) notSpec = false;
                WorkBlast.WebServices.Utilities.GetLocationsByState(that.value ? that.value : that, notSpec, function(v) { WorkBlastJavaScript.AjaxContent.Location.FillLocationSucceed(v, field); }, WorkBlastJavaScript.Fail);
            },
            FillLocationSucceed: function(v, field) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                document.getElementById(field).disabled = false;
                WorkBlastJavaScript.Helper.JsonToSelect(field, v);
            }
        },
        Industry: {
            FillIndustry: function(field) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlast.WebServices.Utilities.GetIndustries(function(v) { WorkBlastJavaScript.AjaxContent.Industry.FillIndustrySucceed(v, field); }, WorkBlastJavaScript.Fail);
            },
            FillIndustrySucceed: function(v, field) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                document.getElementById(field).disabled = false;
                WorkBlastJavaScript.Helper.JsonToSelect(field, v);
            }
        },
        State: {
            UpdateState: function(field) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();

                var state = document.getElementById(field);
                WorkBlast.WebServices.Utilities.GetStates(function(v) { WorkBlastJavaScript.AjaxContent.State.UpdateStateSucceed(v, field); }, WorkBlastJavaScript.Fail);
            },
            UpdateStateSucceed: function(v, field) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                WorkBlastJavaScript.Helper.JsonToSelect(field, v);
            }
        },
        City: {
            UpdateCity: function(state, field) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlast.WebServices.Utilities.GetCitiesByStateID(state.value ? state.value : state, function(v) { WorkBlastJavaScript.AjaxContent.City.UpdateCitySucceed(v, field); }, WorkBlastJavaScript.Fail);
            },
            UpdateCitySucceed: function(v, field) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                var city = document.getElementById(field);
                document.getElementById(field).disabled = false;

                WorkBlastJavaScript.Helper.JsonToSelect(field, v);
            }
        },
        Zipcode: {
            UpdateZipcode: function(city, field) {
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlast.WebServices.Utilities.GetZipcodesByCityID(city.value ? city.value : city, function(v) { WorkBlastJavaScript.AjaxContent.Zipcode.UpdateZipcodeSucceed(v, field); }, WorkBlastJavaScript.Fail);
            },
            UpdateZipcodeSucceed: function(v, field) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                var city = document.getElementById(field);
                document.getElementById(field).disabled = false;

                WorkBlastJavaScript.Helper.JsonToSelect(field, v);
            }
        },
        Login: {
            Login: function(username, pass, theLoginTable) {
                var cn = document.getElementById(theLoginTable).className;

                switch (cn) {
                    case 'loginback2':
                        WorkBlastJavaScript.Login.JobSeeker.Login(username, pass);
                        break;
                    case 'loginback3':
                        WorkBlastJavaScript.Login.Employer.Login(username, pass);
                        break;
                    case 'loginback4':
                        WorkBlastJavaScript.Login.Advertiser.Login(username, pass);
                        break;
                }


            },
            Load: function(type, control) {
                if (type == 'Advertiser') return;
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
                WorkBlast.WebServices.WorkBlast.Login.TryLogin(type, function(v) { WorkBlastJavaScript.AjaxContent.Login.LoadSuccessful(v, type, control); }, WorkBlastJavaScript.Fail);
            },
            LoadSuccessful: function(val, type, control) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
                control = document.getElementById(control);
                if (document.getElementById('theLoginMessage'))
                    document.getElementById('theLoginMessage').style.display = 'none';
                switch (type) {
                    case 'JobSeeker':
                        control.className = 'loginback2';
                        break;
                    case 'Employer':
                        control.className = 'loginback3';
                        break;
                    case 'Advertiser':
                        control.className = 'loginback4';
                        break;
                }
                if (val == '') {
                    if (WorkBlastJavaScript.AjaxContent.Login.LoginContent != '')
                        control.innerHTML = WorkBlastJavaScript.AjaxContent.Login.LoginContent;
                    if (document.getElementById('theLoginTable'))
                        document.getElementById('theLoginTable').style.display = 'block';
                    if (document.getElementById('theLoginMessage'))
                        document.getElementById('theLoginMessage').style.display = 'none';
                } else {
                    if (document.getElementById('theLoginTable'))
                        document.getElementById('theLoginTable').style.display = 'none';
                    if (WorkBlastJavaScript.AjaxContent.Login.LoginContent == '')
                        WorkBlastJavaScript.AjaxContent.Login.LoginContent = control.innerHTML;
                    control.innerHTML = "<a href='" + val + "' style='color:white;'>Back to Admin</a>";
                }
            },
            LoginContent: ''
        }
    },
    JobPosting: {
        PostQuestionnaire: function() {
            WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            var that = 'theQuestionnaire';
            var xml = WorkBlastJavaScript.Helper.Field.GrabFieldElements(document.getElementById(that), 0);
            WorkBlast.WebServices.LoadControl.PostQuestionnaire(WorkBlastJavaScript.CurrentGUID, xml, function(v) {
                WorkBlastJavaScript.AjaxContent.Loading.EndLoading(); eval(v);
            })
        },
        StartQuestionnaire: function(that) {
            that = $_(that);
            var div = HTML.DIV('theQuestionnaire');
            div.appendChild(HTML.SUBMIT('theAddQuestion', 'Add Question', "WorkBlastJavaScript.JobPosting.AddQuestionToSelfAssessment('theQuestionContent'); return false;"));
            HTML.APPEND(div, HTML.DIV('theQuestionContent'));

            HTML.APPEND(div, HTML.BR());
            //     HTML.APPEND(div,HTML.SUBMIT('theSubmitQuestionnaire','Submit','WorkBlastJavaScript.JobPosting.PostQuestionnaire();return false;'));
            HTML.APPEND(that, div);
            WorkBlastJavaScript.JobPosting.AddQuestionToSelfAssessment('theQuestionContent');
        },
        AddQuestionToSelfAssessment: function(that) {
            that = $_(that);
            var id = $_('theQuestionCount').value;
            HTML.APPEND(that, HTML.BR());
            HTML.APPEND(that, HTML.BR());

            var div = HTML.DIV('theQuestionContent' + id);


            div.appendChild(HTML.TEXT('JobPostingQuestionName' + id + 'Field', '', 'Question'));
            HTML.APPEND(div, HTML.TEXT('MinimumScore' + id + 'Field', '25', 'Minimum Score'));
            HTML.APPEND(div, HTML.BR());
            var radioType = HTML.RADIOLIST('QuestionType' + id + 'Field', 'Question Type',
                                                        [{ 'text': 'Multiple Choice', 'value': '1', 'selected': false, 'onclick': "WorkBlastJavaScript.JobPosting.AddAnswerToQuestion(1,'" + id + "');$_('QuestionType" + id + "_0').setAttribute('onclick','');$_('QuestionType" + id + "_1').setAttribute('onclick','');" },
                                                         { 'text': 'Multi Select', 'value': '2', 'selected': false, 'onclick': "WorkBlastJavaScript.JobPosting.AddAnswerToQuestion(2,'" + id + "');$_('QuestionType" + id + "_0').setAttribute('onclick','');$_('QuestionType" + id + "_1').setAttribute('onclick','');"}]);
            div.appendChild(radioType);
            div.appendChild(HTML.SUBMIT('theAddAnswer' + id, 'Add Answer', "WorkBlastJavaScript.JobPosting.AddAnswerToQuestion(WorkBlastJavaScript.Helper.GetRadioButtonSelected('theQuestionAnswerType" + id + "'),'" + id + "'); return false;"));
            HTML.APPEND(div, HTML.BR());
            $_('theQuestionCount').value += 1;
            HTML.APPEND(that, div);

        },
        AddAnswerToQuestion: function(type, id) {
            var where = document.getElementById('theQuestionContent' + id);
            var answerCount = 0;

            if (!$_('theQuestionAnswerCount' + id))
                HTML.APPEND(where, HTML.HIDDEN('theQuestionAnswerCount' + id, 0));
            else
                answerCount = parseInt($_('theQuestionAnswerCount' + id).value) + 1;
            if (answerCount >= 10) return;
            HTML.APPEND(where, HTML.TEXT('JobPostingQuestionAnswerName' + id + 'Answer' + answerCount + 'Field', '', 'Answer  ' + (answerCount + 1)));
            HTML.APPEND(where, HTML.TEXT('JobPostingQuestionAnswerScore' + id + 'Answer' + answerCount + 'Field', '0', 'Score'));
            HTML.APPEND(where, HTML.BR());

            $_('theQuestionAnswerCount' + id).value = answerCount;
        }
    },
    LoadControl: function(loadTo, result) {
        WorkBlastJavaScript.AjaxContent.Loading.EndLoading();
        document.getElementById(loadTo).innerHTML = result;
    },
    Fail: function(result) {
        alert(result.get_message());
    },
    Helper: {
        TextToJson: function(j) {
            var op;
            try {
                op = j.evalJSON();
            } catch (a) {
                op = eval('(' + j + ')');
            }
            return op;
        },
        GetRadioButtonSelected: function(rblDCId) {
            var rblDCs = document.getElementsByName(rblDCId);
            var rblDCSelection = "";
            for (var i = 0; i < rblDCs.length; i++) {
                if (rblDCs[i].checked) {
                    rblDCSelection = rblDCs[i].value;
                    break;
                }
            }
            return rblDCSelection;
        },

        Field: {
            FieldElements: new Array(),
            GrabFieldElements: function(start, count) {
                if (count == 0)
                    WorkBlastJavaScript.Helper.Field.FieldElements = new Array();

                var nodes = start.childNodes;
                for (var i = 0; i < nodes.length; i++) {
                    if (nodes[i].id)
                        if (nodes[i].id.indexOf('Field') > -1) {
                        if (nodes[i].nodeName == 'TABLE') {
                            var b = { 'id': nodes[i].id.replace('Field', ''), 'value': (escape(WorkBlastJavaScript.Helper.GetRadioButtonSelected(nodes[i].id))) };

                            WorkBlastJavaScript.Helper.Field.FieldElements.push(b);
                        } else {
                            if (nodes[i].type == 'checkbox') {
                                if (nodes[i].checked == true) {
                                    var b = { 'id': nodes[i].id.replace('Field', ''), 'value': (escape(nodes[i].value)) };
                                    WorkBlastJavaScript.Helper.Field.FieldElements.push(b);
                                }
                            } else {
                                var b = { 'id': nodes[i].id.replace('Field', ''), 'value': (escape(nodes[i].value)) };
                                WorkBlastJavaScript.Helper.Field.FieldElements.push(b);
                            }
                        }

                    }

                    if (nodes[i].childNodes.length > 0)
                        WorkBlastJavaScript.Helper.Field.GrabFieldElements(nodes[i], count + 1);
                }

                if (count == 0) {
                    var xml = '<' + start.id.replace('Information', '') + '>';
                    for (var a = 0; a < WorkBlastJavaScript.Helper.Field.FieldElements.length; a++) {
                        xml += '<Property Name="' + (WorkBlastJavaScript.Helper.Field.FieldElements[a].id) + '" Value="' + (WorkBlastJavaScript.Helper.Field.FieldElements[a].value) + '" />';
                    }
                    xml += '</' + start.id.replace('Information', '') + '>';
                }
                return xml;
            }
        },
        StartFLV: function(name, video, img, w, h, autostart) {
                WorkBlastJavaScript.Helper.RemoveChildNodes(document.getElementById(name));
            /*
            var so = new SWFObject("videoplayer.swf", "main", "370", "319", "8", "#000000");
            so.addParam("allowFullScreen", "true");
           
            so.addVariable("videoLink",video);
            so.addVariable("defaultVideo", "1");
            so.addVariable("videoVolume", "75");
            so.addVariable("image", img);
            so.addVariable("logo", "logo.swf");
            so.addVariable("logoLink", "http://www.as-flash.com");
            so.addVariable("logoTarget", "_blank");
            so.addVariable("autoplay", "false");
            so.write(name);
            */

            //var so = new SWFObject("videoplayer.swf", "main", "370", "319", "8", "#000000");

            //if (!swfobject) { alert('File swfobject.js not found') } 
            //swfobject.embedSWF('videoplayer.swf', name, '370', '319', '8', false, {'videoLink': video,'defaultVideo': '1','image': img,'autoplay': 'false' ,type: 'flv', width: 370, height: 319}, {allowfullscreen: 'true'}, false);
            if (!w)
                w = 370;
            if (!h)
                h = 319;

            if (!autostart) autostart = false;

            var so = swfobject.embedSWF("http://workblast.com/flvPlayer.swf?imagePath=" + img + "&videoPath=" + video + "&autoStart=" + (autostart ? 'true' : 'false') + "&scaleMode=full&autoHide=false&autoHideTime=5&hideLogo=true&volAudio=60&newWidth=" + w + "&newHeight=" + h + "&disableMiddleButton=false&playSounds=true&soundBarColor=0x0066FF&barColor=0x0066FF&barShadowColor=0x91BBFB&subbarColor=0xffffff", name, w, h, "9.0.0");

            //			so.write(name); 


            //alert(document.getElementById(name).innerHTML);
            //document.getElementById(name).innerHTML='<embed type="application/x-shockwave-flash" src="videoplayer.swf" style="" id="main" name="main" bgcolor="#000000"  allowfullscreen="true" flashvars="videoLink='+video+'&amp;videoVolume=50&amp;image='+img+'&amp;logo=logo.swf&amp;logoTarget=_blank&amp;autoplay=false&amp;defaultVideo=1" height="319" width="370">';
        },
        RemoveChildNodes: function(ctrl) {
                if (ctrl != null)
                    while (ctrl.childNodes[0])
                    ctrl.removeChild(ctrl.childNodes[0]);
        },
        ImageRotate: function(that, new_) {
            if (that.src.indexOf('on') == -1)
                that.src = new_;
        },
        RotateEdit: function(that, new_) {
            if (that.src.indexOf('on') == -1)
                that.src = new_;
        },
        JsonToSelect: function(control, json) {
            document.getElementById(control).options.length = 0;
            var op;
            try {
                op = json.evalJSON();
            } catch (a) {
                op = eval('(' + json + ')');
            }
            for (var i = 0; i < op.Options.option.length; i++) {
                WorkBlastJavaScript.Helper.AddSelectOption(control, op.Options.option[i].name, op.Options.option[i].value, false);
            }
        },
        AddSelectOption: function(selectObj, text, value, isSelected) {
            selectObj = document.getElementById(selectObj);
            if (selectObj != null && selectObj.options != null) {
                selectObj.options[selectObj.options.length] = new Option(text, value, false, isSelected);
            }
        },
        TryParseInt: function(str, defaultValue) {
            var retValue = defaultValue;
            if (str != null) {
                if (str.length > 0) {
                    if (!isNaN(str)) {
                        retValue = parseInt(str);
                    }
                }
            }
            return retValue;
        },
        ClearValue: function(v) {
            document.getElementById(v).value = '';
        }
    }
};

  
        function load(month,year,guid){
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            WorkBlast.WebServices.Calendar.UpdateCalendar(month,year,guid,function(v){document.getElementById('theCalendar_Content').innerHTML=v;});
        }
        function addNoteBox(day,month,year,guid){
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            WorkBlast.WebServices.Calendar.AddNoteBox(day,month,year,guid,function(v){document.getElementById('theCalendar_Content').innerHTML=v;});
        }
        function addNote(note,day,month,year,guid){
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            WorkBlast.WebServices.Calendar.AddNote(note,day,year,month,guid,function(v){document.getElementById('theCalendar_Content').innerHTML=v;});
        }
        function editNote(noteID,day,month,year,guid){
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            WorkBlast.WebServices.Calendar.EditNote(noteID,day,month,year,guid,function(v){document.getElementById('theCalendar_Content').innerHTML=v;});
        }
        function updateNote(note,noteID,month,year,guid){
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            WorkBlast.WebServices.Calendar.UpdateNote(noteID,note,month,year,guid,function(v){document.getElementById('theCalendar_Content').innerHTML=v;});
        }
        
        function removeNote(noteID,month,year,guid){
                WorkBlastJavaScript.AjaxContent.Loading.StartLoading();
            WorkBlast.WebServices.Calendar.RemoveNote(noteID,month,year,guid,function(v){document.getElementById('theCalendar_Content').innerHTML=v;});
        }
        
        function fixNoteToEdit(noteEditID){
            
        }