﻿/*Function for the jcarousel scroll*/
function jscroll() {
    jQuery(document).ready(function() {
        jQuery('#search-carousel').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });

    jQuery(document).ready(function() {
        jQuery('#invite-carousel').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });
    jQuery(document).ready(function() {
        jQuery('#search-carousel-down').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });
    jQuery(document).ready(function() {
        jQuery('#sponsored-carousel').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });
    jQuery(document).ready(function() {
        jQuery('#charitable-carousel').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });
    jQuery(document).ready(function() {
        jQuery('#invite-carousel1').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });
    jQuery(document).ready(function() {
        jQuery('#invite-carousel11').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });

    jQuery(document).ready(function() {
        jQuery('#chat-carousel11').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });

    jQuery(document).ready(function() {
        jQuery('#chat-carousel5').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });
    jQuery(document).ready(function() {
        jQuery('#friends-carousel').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });
    jQuery(document).ready(function() {
        jQuery('#invite-carousel3').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });

    jQuery(document).ready(function() {
        jQuery('#invite-carousel21').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });

    jQuery(document).ready(function() {
        jQuery('#suser-carousel').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });

    jQuery(document).ready(function() {
        jQuery('#suser-carousel-down').jcarousel({
            horizontal: true,
            scroll: 5
        });
    });
}
/*ends here*/
/*Base64 Encoding starts here*/
var Base64 = {
    /* private property */
    _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
    /* public method for encoding */
    encode: function(input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;
        input = Base64._utf8_encode(input);
        while (i < input.length) {
            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);
            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;
            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }
            output = output +
            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
        }
        return output;
    },

    /* public method for decoding */
    decode: function(input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;
        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
        while (i < input.length) {
            enc1 = this._keyStr.indexOf(input.charAt(i++));
            enc2 = this._keyStr.indexOf(input.charAt(i++));
            enc3 = this._keyStr.indexOf(input.charAt(i++));
            enc4 = this._keyStr.indexOf(input.charAt(i++));
            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;
            output = output + String.fromCharCode(chr1);
            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }
        }
        output = Base64._utf8_decode(output);
        return output;
    },

    /* private method for UTF-8 encoding */
    _utf8_encode: function(string) {
        string = string.replace(/\r\n/g, "\n");
        var utftext = "";
        for (var n = 0; n < string.length; n++) {
            var c = string.charCodeAt(n);
            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if ((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
        }
        return utftext;
    },

    /* private method for UTF-8 decoding */
    _utf8_decode: function(utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;
        while (i < utftext.length) {
            c = utftext.charCodeAt(i);
            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if ((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i + 1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i + 1);
                c3 = utftext.charCodeAt(i + 2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }
        }
        return string;
    }
};
/*encoding ends here*/

function getXmlHttpObject() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
};

var content = "ctl00_ContentPlaceHolder1_";
//var siteURL = "http://localhost/mysomeday/"; 
// var siteURL = "http://www.mysomedaytest.com/"; 
 var siteURL = "http://www.mysomeday.com/"; 

/* get pagesize */
function getPageSize(i) {

    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    // for small pages with total height less then height of the viewport
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }


    // for small pages with total width less then width of the viewport
    if (xScroll < windowWidth) {
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }

    var paghg;
    paghg = windowHeight + yScroll;
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
    if (navigator.userAgent.indexOf("Firefox") != -1) {
        pageWidth = pageWidth - 17;
    }
    if (i != '') {
        document.getElementById('fade').style.width = (pageWidth + 'px');
        document.getElementById('fade').style.height = (pageHeight + 'px');
    }

    if (i == 2) {
        document.getElementById('fade_long_img').style.width = (pageWidth + 'px');
        document.getElementById('fade_long_img').style.height = (pageHeight + 'px');
    }
};

function getWindowSize() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    // for small pages with total height less then height of the viewport
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if (xScroll < windowWidth) {
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }

    var paghg;
    paghg = windowHeight + yScroll;
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
    if (navigator.userAgent.indexOf("Firefox") != -1) {
        pageWidth = pageWidth - 17;
    }

    document.getElementById(content + "width_window").value = (pageWidth + 'px');
    document.getElementById(content + "ht_window").value = (pageHeight + 'px');
};
/*ends here*/
function homeTab() {
    document.getElementById('home').style.backgroundImage = 'url(../cssimages/myprofile_roll.gif)';
};
function myprofileTab() {
    document.getElementById('myprofile').style.background = "url(./cssimages/myprofile_roll.gif)";
};
function chitchatTab() {
    document.getElementById('chitchat').style.background = "url(./cssimages/chitchat_roll.gif)";
};
function spotlightOnTab() {
    document.getElementById('spotlighton').style.background = "url(./cssimages/spotlighton_roll.gif)";
};
function messagesTab() {
    document.getElementById('DivMessages').style.background = "url(./cssimages/messagesTabHov.gif)";
};
/*function used for sign up link*/
function callReg() {
    document.location = "/newuser-registration.aspx";
};
/*ends here*/
function removeText(cid) {
    document.getElementById(cid).select();
    //    if (document.getElementById(cid).value != "") {
    //        document.getElementById(cid).value = "";
    //    }
    //    else {
    //        document.getElementById(cid).value = "Search by Name";
    //     }
    return;
}
/*for paging of featured somedays in home page new function*/
function pageDataHomeNew(flag, somedaytype, pgno, pgInprogressCount, pgneedplanCount, pgachievedCount, pgViewallCount, recordsperpage) {
    var recordsper = recordsperpage;
    var url_arg;
    url_arg = "pgInprogressCount=" + pgInprogressCount + "&pgneedplanCount=" + pgneedplanCount + "&pgachievedCount=" + pgachievedCount + "&pgViewallCount=" + pgViewallCount + "&perpage=" + recordsper + "&currentpg=" + pgno + "&somedaytype=" + somedaytype + "";
    makePOSTRequest('/ajaxHome-featuredsomedays.aspx?enc=' + Base64.encode(url_arg), '', '4');
};

function makePOSTRequest(url, parameters, type) {
    http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            http_request.overrideMimeType('text/html');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) { }
        }
    }
    if (!http_request) {
        alert(geterrmsg('e54'));
        return false;
    }
    if (type == "4") http_request.onreadystatechange = showFeaturedSomedays; /* paging of featured someday in homepage  */
    if (type == "163") http_request.onreadystatechange = loginStateChanged;
    if (type == "164") http_request.onreadystatechange = loginOutStateChanged;
    if (type == "165") http_request.onreadystatechange = emailStateChanged;
    if (type == "201") http_request.onreadystatechange = ResultClickTracking;
    if (type == "210") http_request.onreadystatechange = showExpertOnRefresh;
    
     //url = "http://localhost/mysomeday" + url; 
     //url = "http://www.mysomedaytest.com" + url; 
    //url = "http://www.mysomeday.com" + url; 
    http_request.open('POST', url, true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
};

function showFeaturedSomedays() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            result = http_request.responseText;

            rec_count = result.split("^^^^");
            var somedaytypes = rec_count[0];
            var pagerecord = rec_count[1];
            var datapagerecord = rec_count[2];
            var new1 = rec_count[3];
            var pgcount = rec_count[4];
            var newwh = rec_count[5];
            var pagingdown = rec_count[6];


            var newstart = 1;
            if (new1 > 5) {
                if (newwh == 0) {
                    newstart = ((new1 - 5) + 1);
                }
                else {
                    newstart = ((new1 - newwh) + 1);
                }
            }
            document.getElementById("id_featured_paging").innerHTML = pagerecord;

            jQuery(document).ready(function() {
                jQuery('#search-carousel').jcarousel({
                    horizontal: true,
                    scroll: 5,
                    start: newstart
                });
            });

            document.getElementById("id_featured_paging_down").innerHTML = pagingdown;

            jQuery(document).ready(function() {
                jQuery('#search-carousel-down').jcarousel({
                    horizontal: true,
                    scroll: 5,
                    start: newstart

                });
            });
            document.getElementById("bindsomedaytypes").innerHTML = somedaytypes;
            document.getElementById("bindsomedaytypes_down").innerHTML = somedaytypes;
            if (document.getElementById("id_featured") != null)
                document.getElementById("id_featured").innerHTML = datapagerecord;
        }
        else {
            alert('There was a problem with the request: ' + http_request.status);
        }
    }
};

function cycle() {
    makePOSTRequest('/Ajax-ExpertRefresh.aspx', "", "210");
};
function showExpertOnRefresh() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            result = http_request.responseText;
            document.getElementById("sponsored_content").innerHTML = result;
            var getTime = document.getElementById("ctl00_ContentPlaceHolder1_hidexp").value;
            window.setTimeout('cycle();', getTime);
        }
        else alert("There was problem with request." + http_request.status);
    }
};

/*** click tracking ***/
var chkElem, lnk;
function trackClicks(somedayID, page, element, link) {
    chkElem = element;
    lnk = link;
    var qs = "somedayID=" + somedayID + "&page=" + page + "&element=" + element;
    makePOSTRequest('/Ajax-ClickTracking.aspx?' + qs, "", "201");
};

function ResultClickTracking() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            if (chkElem == "name") window.open(lnk, "website");
            else if (chkElem == "logo") window.location = lnk;
            else if (chkElem == "original") {
                window.open(lnk, "website");
            }
        }
        else alert("There was problem with request." + http_request.status);
    }
};
/***end click tracking***/
/*Call chit chat layer*/
function callChitChatLayer() {
    document.getElementById('start_chitchat').style.display = 'block';
    document.getElementById('fade').style.display = 'block';
    alertSize();
    document.getElementById('start_chitchat').style.left = (parseInt(myWidth / 2) - 213) + "px";
    window.scrollTo(0, 0);
};
function closeChitchatLayer() {
    document.getElementById('ctl00_drp_cat').value = "0";
    document.getElementById('ctl00_txt_title_chat').value = "";
    document.getElementById('ctl00_txt_msg_chat').value = "";
    document.getElementById('start_chitchat').style.display = 'none';
    document.getElementById('fade').style.display = 'none';
};
/*ends here*/

var myWidth = 0, myHeight = 0;

function alertSize() {
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
};

/*Call someday layer*/
function callSomedayLayer() {
    document.getElementById('id_someday_what').style.display = 'block';
    document.getElementById('fade').style.display = 'block';
    alertSize();
    document.getElementById('id_someday_what').style.left = (parseInt(myWidth / 2) - 460) + "px";
    window.scrollTo(0, 0);
};
function closeSomedayLayer() {
    if (document.getElementById('ctl00_rigth_uname1') != null)
        document.getElementById('ctl00_rigth_uname1').value = "";
    if (document.getElementById('ctl00_rigth_pword1') != null)
        document.getElementById('ctl00_rigth_pword1').value = "";
    if (document.getElementById('ctl00_chk_remember1') != null)
        document.getElementById('ctl00_chk_remember1').checked = false;
    document.getElementById('id_someday_what').style.display = 'none';
    document.getElementById('fade').style.display = 'none';
};

/*Call login layer*/
function callLoginLayer() {
    document.getElementById('id_login').style.display = 'block';
    document.getElementById('fade').style.display = 'block';
    alertSize();
    document.getElementById('id_login').style.left = (parseInt(myWidth / 2) - 213) + "px";
    window.scrollTo(0, 0);
};

function closeLoginLayer() {
    document.getElementById('ctl00_rigth_uname').value = "";
    document.getElementById('ctl00_rigth_pword').value = "";
    document.getElementById('ctl00_chk_remember').checked = false;
    document.getElementById('id_login').style.display = 'none';
    document.getElementById('fade').style.display = 'none';
};/*ends here*/

/*call forgot password layer*/
function callForgotpassLayer(pagename) {
    if (pagename == 'login')
        document.getElementById('id_login').style.display = 'none';
    else if (pagename == 'somedaycopy')
        document.getElementById('id_someday_copy').style.display = 'none';
    else
        document.getElementById('id_someday').style.display = 'none';
    document.getElementById('id_forgotpass').style.display = 'block';
    document.getElementById('fade').style.display = 'block';
    alertSize();
    document.getElementById('id_forgotpass').style.left = (parseInt(myWidth / 2) - 213) + "px";
    window.scrollTo(0, 0);
};
function closeForgotpassLayer() {
    document.getElementById('ctl00_rigth_email').value = "";
    document.getElementById('id_login').style.display = 'none';
    document.getElementById('id_forgotpass').style.display = 'none';
    document.getElementById('fade').style.display = 'none';
};/*ends here*/
function checkLogin() {
    alert("Please login to contact");
};
/*error alert if not login for chit chat*/
function callLoginAlert() {
    alert(geterrmsg('e55'));
};
/*ends here*/
function removeSpaces(strVal) {
    strVal = strVal.replace(/^\s*(\S*(\s+\S+)*)\s*$/, '$1');
    return strVal;
};
function keyPress(e, type) {
    if (e.keyCode == 13) {
        if (type == "Login") loginValidate();
        if (type == "Search") searchfn();
        if (type == "SearchUsers") searchuser();
        if (type == "Splash") loginValidateMembers('buttonid', 'imgpreload');
        if (type == "Register") loginValidateMembers('sbtnid', 'preloader');
        if (type == "Default") return true;
        if (type == "Searchtxt") return true;
        if (type == "Searchreplytxt") return true;
        return false;
    }
};
/*Login Validation*/
var specialchar = "#";
function loginValidate() {
    document.getElementById("subbutton").style.visibility = "hidden";
    document.getElementById("imgpreloader").style.visibility = "visible";

    for (var i = 0; i < document.getElementById("ctl00_rigth_uname").value.length; i++) {
        if (specialchar.indexOf(document.getElementById("ctl00_rigth_uname").value.charAt(i)) != -1) {
            alert(geterrmsg('e512'));
            document.getElementById("ctl00_rigth_uname").focus();
            document.getElementById("subbutton").style.visibility = "visible";
            document.getElementById("imgpreloader").style.visibility = "hidden";
            return false;
        }
    }
    if (removeSpaces(document.getElementById("ctl00_rigth_uname").value) == "") {
        alert(geterrmsg('e46'));
        document.getElementById("ctl00_rigth_uname").focus();
        document.getElementById("subbutton").style.visibility = "visible";
        document.getElementById("imgpreloader").style.visibility = "hidden";
        return false;
    }
    if (removeSpaces(document.getElementById("ctl00_rigth_pword").value) == "") {
        alert(geterrmsg('e43'));
        document.getElementById("ctl00_rigth_pword").focus();
        document.getElementById("subbutton").style.visibility = "visible";
        document.getElementById("imgpreloader").style.visibility = "hidden";
        return false;
    }
    loginCheck("1", document.getElementById("ctl00_rigth_uname").value, document.getElementById("ctl00_rigth_pword").value, document.getElementById("ctl00_chk_remember").checked, 'nonmember');
}
/*ends here*/

function loginValidateWelcome() {
    document.getElementById("welcombtn").style.visibility = "hidden";
    document.getElementById("welcomepl").style.visibility = "visible";

    for (var i = 0; i < document.getElementById("ctl00_rigth_uname1").value.length; i++) {
        if (specialchar.indexOf(document.getElementById("ctl00_rigth_uname1").value.charAt(i)) != -1) {
            alert(geterrmsg('e512'));
            document.getElementById("ctl00_rigth_uname1").focus();
            document.getElementById("welcombtn").style.visibility = "visible";
            document.getElementById("welcomepl").style.visibility = "hidden";
            return;
        }
    }
    if (removeSpaces(document.getElementById("ctl00_rigth_uname1").value) == "") {
        alert(geterrmsg('e46'));
        document.getElementById("ctl00_rigth_uname1").focus();
        document.getElementById("welcombtn").style.visibility = "visible";
        document.getElementById("welcomepl").style.visibility = "hidden";
        return;
    }
    if (removeSpaces(document.getElementById("ctl00_rigth_pword1").value) == "") {
        alert(geterrmsg('e43'));
        document.getElementById("ctl00_rigth_pword1").focus();
        document.getElementById("welcombtn").style.visibility = "visible";
        document.getElementById("welcomepl").style.visibility = "hidden";
        return;
    }
    loginCheck("1", document.getElementById("ctl00_rigth_uname1").value, document.getElementById("ctl00_rigth_pword1").value, document.getElementById("ctl00_chk_remember1").checked, 'welcome');
}



//login validation for members
function loginValidateMembers(btnid, preloadid) {
    document.getElementById(btnid).style.visibility = "hidden";
    document.getElementById(preloadid).style.visibility = "visible";

    for (var i = 0; i < document.getElementById(content + "rigth_uname").value.length; i++) {
        if (specialchar.indexOf(document.getElementById(content + "rigth_uname").value.charAt(i)) != -1) {
            alert(geterrmsg('e512'));
            document.getElementById(content + "rigth_uname").focus();
            document.getElementById(btnid).style.visibility = "visible";
            document.getElementById(preloadid).style.visibility = "hidden";
            return;
        }
    }
    if (removeSpaces(document.getElementById(content + "rigth_uname").value) == "") {
        alert("Please enter a Username to login");
        document.getElementById(content + "rigth_uname").focus();
        document.getElementById(btnid).style.visibility = "visible";
        document.getElementById(preloadid).style.visibility = "hidden";
        return;

    }
    if (removeSpaces(document.getElementById(content + "rigth_pword").value) == "") {
        alert("Please enter a Password to login");
        document.getElementById(content + "rigth_pword").focus();
        document.getElementById(btnid).style.visibility = "visible";
        document.getElementById(preloadid).style.visibility = "hidden";
        return;
    }


    if (document.getElementById(content + "chk_remember") == null) {
        checkrem = false;
    }
    else {
        checkrem = false;
        if (document.getElementById(content + "chk_remember").checked == true) checkrem = true;
    }
    if (btnid = "sbtnid") loginCheck("2", document.getElementById(content + "rigth_uname").value, document.getElementById(content + "rigth_pword").value, checkrem, 'member');
    if (btnid = "buttonid") loginCheck("1", document.getElementById(content + "rigth_uname").value, document.getElementById(content + "rigth_pword").value, checkrem, 'member');
};
function loginCheck(strpagecheck, struname, strpword, chk_checked, memberst) {
    xmlHttp = getXmlHttpObject();
    if (xmlHttp == null) {
        alert(geterrmsg('e51'));
        return;
    }
    var url = "/login_layer.aspx";
    url = url + "?usernam=" + struname + "&password=" + Base64.encode(strpword) + "&checked=" + chk_checked + "&pgchk=" + strpagecheck + "&memst=" + memberst;
    makePOSTRequest(url, "", '163');
};
function callClear() {
    document.getElementById('ctl00_rigth_uname').value = "";
    document.getElementById('rigth_pword').value = "";
    document.getElementById('ctl00_chk_remember').checked = false;
};
function loginStateChanged() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            result = http_request.responseText.split("^^^^");
            if (result[0] == "1") {
                window.location.reload(true);
            }
            else if (result[0] == "2") {
                document.location = "/UserProfile.aspx";
            }
            else if (result[0] == "3") {
                callConfirmMessage();
            }
            else {
                alert(geterrmsg('e48'));
                if (result[1] == "nonmember") {
                    document.getElementById("subbutton").style.visibility = "visible";
                    document.getElementById("imgpreloader").style.visibility = "hidden";
                    document.getElementById("ctl00_rigth_uname").focus();
                }
                else if (result[1] == "member") {
                    document.getElementById("buttonid").style.visibility = "visible";
                    document.getElementById("imgpreload").style.visibility = "hidden";
                    document.getElementById("ctl00_ContentPlaceHolder1_rigth_uname").focus();
                }
                else if (result[1] == "welcome") {
                    document.getElementById("welcombtn").style.visibility = "visible";
                    document.getElementById("welcomepl").style.visibility = "hidden";
                    document.getElementById("ctl00_rigth_uname1").focus();
                }
                else if (result[1] == "copysomeday") {
                    //                    document.getElementById("welcombtn").style.visibility = "visible";
                    //                    document.getElementById("welcomepl").style.visibility = "hidden";
                    document.getElementById("ctl00_rigth_uname2").focus();
                }
            }
        }
    }
};
/*ends here*/
function callConfirmMessage() {
    getPageSize(0);
    document.getElementById('id_login').style.display = 'none';
    document.getElementById('id_forgotpass').style.display = 'none';
    document.getElementById('id_addasfriend').style.display = 'none';
    document.getElementById('id_Confirmmessage').style.display = 'block';
    document.getElementById('fade').style.width = (pageWidth + 'px');
    document.getElementById('fade').style.height = (pageHeight + 'px');
    document.getElementById('fade').style.display = 'block';
    //document.getElementById('hid_profileid_id').value = strprofileid;
    alertSize();
    document.getElementById('id_Confirmmessage').style.left = (parseInt(myWidth / 2) - 213) + "px";
    window.scrollTo(0, 0);
};
/*Log Out Section*/
function loggedOut() {
    xmlHttp = getXmlHttpObject();
    if (xmlHttp == null) {
        alert(geterrmsg('e51'));
        return;
    }
    var url = "/logout.aspx";
    makePOSTRequest(url, "", '164');
};
function loginOutStateChanged() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            result = http_request.responseText;
            if (result == "1") {
                window.location = "/Default_home.aspx"
            }
        }
    }
};
/*ends here*/
function validateEmail(id) {
    var expression = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    return expression.test(id);
};
/* Forget Password Layer */
function forgetPassEmail() {
    document.getElementById("forgetmail").style.display = "none";
    document.getElementById("preload").style.display = "block";
    if (document.getElementById("ctl00_rigth_email").value == "") {
        alert(geterrmsg('e9'));
        document.getElementById("ctl00_rigth_email").focus();
        document.getElementById("forgetmail").style.display = "block";
        document.getElementById("preload").style.display = "none";
        return false;
    }
    if (validateEmail(document.getElementById("ctl00_rigth_email").value) == false) {
        alert(geterrmsg('e23'));
        document.getElementById("forgetmail").style.display = "block";
        document.getElementById("preload").style.display = "none";
        return false;
    }
    sendEmail(document.getElementById("ctl00_rigth_email").value);
};

function sendEmail(stremailId) {
    xmlHttp = getXmlHttpObject();
    if (xmlHttp == null) {
        alert(geterrmsg('e51'));
        return;
    }
    var url = "/ForgetPassword-Layer.aspx";
    url = url + "?email=" + stremailId;
    makePOSTRequest(url, '', '165');
};
function emailStateChanged() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            result = http_request.responseText;
            if (result == "1") {
                alert(geterrmsg('e164')); //alert(geterrmsg('e49'));
                document.getElementById("ctl00_rigth_email").value = "";
                window.location.reload();
            }
            else {
                alert(geterrmsg('e49')); //alert(geterrmsg('e164'));
                document.getElementById("ctl00_rigth_email").value = "";
                document.getElementById("ctl00_rigth_email").focus();
                document.getElementById("forgetmail").style.display = "block";
                document.getElementById("preload").style.display = "none";
            }
        }
    }
};
/* End of Forgot Pass */
/*Validation for Start New Chitchat layer*/
function validateChitChat() {
    var valid = true;
    var errorstr = "The following fields are incomplete:" + '\r\n';

    document.getElementById("chatbutton").style.visibility = "hidden";
    document.getElementById("chatpreloader").style.visibility = "visible";

    if (document.getElementById("ctl00_drp_cat").value == "0") {
        errorstr = errorstr + '\r\n' + geterrmsg('e158');
        valid = false;
    }

    if (document.getElementById("ctl00_txt_title_chat").value.replace(/^\s+|\s+$/g, "") == "") {
        errorstr = errorstr + '\r\n' + geterrmsg('e159');
        valid = false;
    }
    if (document.getElementById("ctl00_txt_msg_chat").value.replace(/^\s+|\s+$/g, "") == "") {
        errorstr = errorstr + '\r\n' + geterrmsg('e160');
        valid = false;
    }
    if (valid == false) {
        errorstr = errorstr + '\r\n';
        document.getElementById("chatbutton").style.visibility = "visible";
        document.getElementById("chatpreloader").style.visibility = "hidden";
        alert(errorstr);
    }
    if (valid == true) {
        document.getElementById("chatbutton").style.visibility = "hidden";
        document.getElementById("chatpreloader").style.visibility = "visible";
    }
    return valid;
};
/*Chitchat ends here*/
function searchuser() {
    var usrnam = document.getElementById("ctl00_txtUsername").value;
    if (removeSpaces(usrnam) == "") {
        alert("Please enter the name.");
        return;
    }
    if (usrnam == 'Search by Name') {
        alert("Please enter the name.");
        return;
    }
    document.location = '/Searchusers.aspx?lnk=' + Base64.encode(usrnam);
};
function searchfn() {
    var kew = document.getElementById("ctl00_txt_key").value;
    var ddl = document.getElementById("ctl00_DropDownList1").value;
    kew = kew.replace(/^\s*(\S*(\s+\S+)*)\s*$/, '$1');
    if (kew == "Search by keyword") {
        kew = "";
    }
    if (kew == "" && ddl == "0") {
        alert(geterrmsg('e153'));
    }
    else {
        window.location = "/Search.aspx?msl=" + Base64.encode("cat=" + ddl + "&kw=" + kew);
    }
};