﻿var path = (location.href.split("gulbargaone.com")[1]) == "/" ? "" : "../";
var isCategoriesShown = false;
var rightAd = parseInt(Math.random() * maxRightAds); topAd = parseInt(Math.random() * maxTopAds); bigAd = parseInt(new Date().getDay()) + 1;

function changeRightAd() {
    rightAd++;
    if (rightAd > maxRightAds) rightAd = 1;
    $("td.right_ad a img").hide();
    $("td.right_ad a img").attr("src", path + "resources/ads/right_0" + rightAd + ".jpg");
    $("td.right_ad a").attr("href", "javascript:addHits(2,'"+RightAdsLinks[rightAd]+"')");
    $("td.right_ad a img").fadeIn(500);
}

function changeTopAd() {
    topAd++;
    if (topAd > maxTopAds) topAd = 1;
    $("#top_ad a img").hide();
    $("#top_ad a img").attr("src", path + "resources/ads/top_0" + topAd + ".jpg");
    $("#top_ad a").attr("href", "javascript:addHits(2,'"+TopAdsLinks[topAd]+"')");
    $("#top_ad a img").fadeIn(1000);
}

function changeBigAd() {
    $("td.big_ad a img").hide();
    $("td.big_ad a img").attr("src", path + "resources/ads/big_0" + BigAds[bigAd] + ".jpg");
    $("td.big_ad a").attr("href", "javascript:addHits(3,'"+BigAdsLinks[bigAd]+"')");
    $("td.big_ad a img").fadeIn(1000);
}

function closeWindows(n) {
    if (isCategoriesShown == true && n == 1) {
        $("#mycontent").slideUp("medium");
    } else if (n == undefined) {
        $("#mycontent").fadeOut(1000);
    }
    isCategoriesShown = false;
}

function changeSmallAd() {
    var getAds = SmallAdsToday[parseInt(new Date().getDay())].split(",");
    $("td.bottom_ad1 a img").attr("src", path + "resources/ads/small_0" + getAds[0] + ".jpg");
    $("td.bottom_ad2 a img").attr("src", path + "resources/ads/small_0" + getAds[1] + ".jpg");
    $("td.bottom_ad3 a img").attr("src", path + "resources/ads/small_0" + getAds[2] + ".jpg");
    $("td.bottom_ad4 a img").attr("src", path + "resources/ads/small_0" + getAds[3] + ".jpg");
    $("td.bottom_ad1 a").attr("href", "javascript:addHits(1,'" + SmallAdsLinks[getAds[0]] + "')");    
    $("td.bottom_ad2 a").attr("href", "javascript:addHits(1,'" + SmallAdsLinks[getAds[1]] + "')");
    $("td.bottom_ad3 a").attr("href", "javascript:addHits(1,'" + SmallAdsLinks[getAds[2]] + "')");
    $("td.bottom_ad4 a").attr("href", "javascript:addHits(1,'" + SmallAdsLinks[getAds[3]] + "')");
}

function showInfo(page) {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + page, function(data) {
        $("#mycontent").html(data);
        $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='"+path+"resources/images/close.png' alt='Close' border='0' /></a></div>");
        location.href = "#cw";
    });    
    $("#mycontent").fadeIn(1000);    
}

function showCategories() {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + "category.htm", function(data) {
        $("#mycontent").html(data);
        $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div>");
        isCategoriesShown = true;
    });
    $("#mycontent").slideDown("medium");
}

function showValuableInformation() {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + "valinfo.htm", function(data) {
        $("#mycontent").html(data);
        $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div>");
        isCategoriesShown = true;
    });
    $("#mycontent").slideDown("medium");
}

function showRankings() {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + "common.ashx?type=ranking", function(data) {
    var d = "<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div><span class='heading'>Webpage Rankings</span><br /><br /><table class='ranks' width='100%' bgcolor='#999' cellpadding='10' cellspacing='1'><tr class='rankhdr'><td>Rank</td><td>Profile / Member Name</td><td>Category of Listing</td><td>Hits</td></tr>"
    $("#mycontent").html(d + data + "</table> <br /><p style='font-size: 9pt; color: #999'><span class='pgn'>&nbsp;</span>&nbsp;&nbsp;&nbsp; Promotional Activities - Not Started &nbsp;&nbsp;&nbsp;&nbsp; <span class='pgu'>&nbsp;</span>&nbsp;&nbsp;&nbsp; Promotional Activities - Not Applicable &nbsp;&nbsp;&nbsp;&nbsp; <span class='pgq'>&nbsp;</span>&nbsp;&nbsp;&nbsp; Promotional Activities - Applicable</p><br /><b>Note</b>: Profiles qualified for Promotional Activities and ranking top of the Webpage Rankings List will be declared winner for a given Promotional Activity as and when the Promotions are conducted. For more information and participation, please contact us. Thank you.");
        isCategoriesShown = true;
    });
    $("#mycontent").show();
    location.href = "#cw";
}

function showCategoriesList(catID) {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + "source.ashx?type=catlist&id="+catID, function(data) {
        $("#mycontent").html("<p class='catlist'>"+data+ "</p>");
        $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div>");
        isCategoriesShown = true;
    });
    $("#mycontent").show();
    location.href = "#cw";
}

function searchNow(th, e) {
    $("#mycontent").css("background", "#222");
    if (e.keyCode == 13) {
        if ($("#txtSearch").val().length > 2) {
            if (path != "") $("#mycontent").css("height", "1355px");
            var searchFor = $("#txtSearch").val();
            if (searchFor != "") {
                $("#mycontent").html("Please wait ...");
                $.get(path + "common.ashx?type=search&str=" + searchFor, function (data) {
                    $("#mycontent").html("<p class='catlist'>" + data + "</p>");
                    $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div>");
                    isCategoriesShown = true;
                });
                $("#mycontent").show();
                location.href = "#cw";
            }
        } else {
            alert("Please enter atleast 3 characters to Search GulbargaONE!")
            $("#txtSearch").focus();
        }
    }
}

function Advertise() {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + "advertise.htm", function(data) {
        $("#mycontent").html(data);
        $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div>");        
        $("#txtAdName").focus();
    });
    $("#mycontent").fadeIn(1000);
    location.href = "#cw";
}

function adFormValid() {
    var sn = document.getElementById("txtAdName");
    var sp = document.getElementById("txtAdPhone");    
    if (!NameValidate(sn)) {
        alert('Please enter your Name');
        $("#txtAdName").val("");
        $("#txtAdName").focus();
    } else if (!CellValidate(sp)) {
        alert('Please enter valid Mobile Number in India');
        $("#txtAdPhone").focus();
    } else {
        $("#tnx").html("Please wait ...");
        $.get(path+"sms.ashx?type=advertise&sndName=" + sn.value + "&sndPhone=" + sp.value, function (data) {
            $("#tnx").css("color", "#fff");
            $("#tnx").html(data);
            $("#txtAdName").val("");
            $("#txtAdPhone").val("");
        });
    }
    return false;
}

function cbFormValid() {
    var sn = document.getElementById("txtAdName");
    var sp = document.getElementById("txtAdPhone");
    var memID = document.getElementById("hdmemID");
    if (!NameValidate(sn)) {
        alert('Please enter your Name');
        $("#txtAdName").val("");
        $("#txtAdName").focus();
    } else if (!CellValidate(sp)) {
        alert('Please enter valid Mobile Number in India');
        $("#txtAdPhone").focus();
    } else {
        $("#tnx").html("Please wait ...");
        $.get(path+"asms.ashx?type=callback&id="+memID.value+"&sndType="+$("#lstRequest").val()+"&sndName=" + sn.value + "&sndPhone=" + sp.value, function(data) {
            $("#tnx").css("color", "#000");
            $("#tnx").html(data);
            $("#txtAdName").val("");
            $("#txtAdPhone").val("");
        });
    }
    return false;
}

function NameValidate(objName) {
    var str = objName.value;
    if (str.length<3 || str.search(/[^a-zA-Z\s.]/g) != -1)
        return false;
    else
        return true;
}

function CellValidate(objMobileNo) {
    var incomingString = objMobileNo.value;
    if (incomingString.length < 10 || incomingString.search(/[^0-9]/g) != -1 || incomingString.charAt(0)<8)
        return false;
    else
        return true;
}

function NumberValidate(objNumber) {
    var incomingString = objNumber.value;
    if (incomingString.length < 10 || incomingString.search(/[^0-9]/g) != -1)
        return false;
    else
        return true;
}

function Profile(n) {
    //location.href = path + "g" + n + "/";
    setTimeout(function () { window.location = path + "g" + n + "/"; }, 0);
}

function addHits(n, l) {
    if (l.toString().length == 4) {
        $.get(path + "source.ashx?type=addhits&id=" + l + "&no=" + n, function (data) {
            //location.href = path + "g" + l + "/";            
            setTimeout(function () { window.location = path + "g" + l + "/"; }, 0);
        });
    } else if(l.toString().indexOf("http://") != -1) {
        window.open(l);
    } else {
        //location.href = l;
        setTimeout(function () { window.location = l; }, 0);
    }
}

function getNewsEvents() {
    $("#newsEvents").html("Please wait ...");
    $.get(path + "common.ashx?type=news", function (data) {
        $("#newsEvents").html("News / Events / Offers<br /><br /><marquee direction='up' scrollamount='1' onMouseOver='this.stop()' onMouseOut='this.start()' height='210px' scrolldelay='1'>" + data + "</marquee>");
        //$("#newsEvents marquee").mouseover(function () { $(this).attr("scrollAmount", "0"); });
        //$("#newsEvents marquee").mouseout(function () { $(this).attr("scrollAmount", "1"); });
    });
}

function getFooter() {
    $("#footerInt").html("<ul class='ftr-menu'><li><a href='javascript:;' onclick=showInfo('knowus.htm')>Know Us</a></li><li><a href='javascript:;' onclick=showInfo('reachus.htm')>Reach Us</a></li><li><a href='javascript:;' onclick=showInfo('feedback.htm')>Feedback Us</a></li><li><a href='javascript:;' onclick=Advertise()>Advertise</a></li><li><a href='javascript:;' onclick=showRankings()>Webpage Rankings</a></li><li><a href='javascript:;' onclick=showInfo('faqs.htm')>FAQs</a></li><li><a href='javascript:;' onclick=showInfo('terms.htm')>Terms of Service</a></li><li><a href='javascript:;' onclick=showInfo('privacy.htm')>Privacy</a></li></ul><span class='copyright'>&copy 2010 Proinfocus.  All rights reserved. Registered Trademarks, Patents, Licenses are owned by their respective owners.</span>");
}

function showJobs() {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + "jobs.htm", function(data) {
        $("#mycontent").html(data);
        $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div>");
        location.href = "#cw";
    });
    $("#mycontent").show();
}

function showRentals() {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + "rentals.htm", function(data) {
        $("#mycontent").html(data);
        $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div>");
        location.href = "#cw";
    });
    $("#mycontent").show();
}

function showTenders() {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + "tenders.htm", function (data) {
        $("#mycontent").html(data);
        $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div>");
        location.href = "#cw";
    });
    $("#mycontent").show();
}

function getMenu() {
    //var menu = "<li><a accesskey='z' href='javascript:;' onclick='showCategories()'>Categories</a></li>";
    var menu = "<li><a accesskey='c' href='javascript:;' onclick=showInfo('bidwin/bidwin.htm')><font color='#ff9933'><b>Bid-Win</b></font></a></li>";
    menu += "<li><a accesskey='k' href='http://blog.gulbargaone.com' target='_blank'><font color='#ff9933'><b>Blog</b></font></a></li>";
    menu += "<li><a accesskey='h' href='javascript:;' onclick='showValuableInformation()'>For your Help</a></li>";
    menu += "<li><a accesskey='f' href='javascript:;' onclick=showInfo('famous.htm')>Famous</a></li>";
    menu += "<li><a accesskey='e' href='javascript:;' onclick='showEvents()'>Events</a></li>";
    menu += "<li><a accesskey='j' href='javascript:;' onclick='showJobs()'>Jobs</a></li>";
    menu += "<li><a accesskey='r' href='javascript:;' onclick='showRentals()'>Rentals</a></li>";
    menu += "<li><a accesskey='t' href='javascript:;' onclick='showTenders()'>Tenders</a></li>";
    menu += "<li><a accesskey='n' href='javascript:;' onclick='showJoin()'><b>Join Now!</b></a></li>";
    menu += "</ul>";
    
    if(path=="../")
        $("#getMenu").html("<ul><li><a href='../'>Home</a></li>"+menu);
    else
        $("#getMenu").html("<ul><li><a href='./'>Home</a></li>"+menu);
}

/*function getJobsData() {
    startdata = "<table class='ranks' width='100%' bgcolor='#999' cellpadding='8' cellspacing='1'><tr class='rankhdr'><td width='30'>S.No.</td><td width='150px'>Name</td><td>Description</td><td width='100px'>Contact</td></tr>";
    enddata = "</table>";
    $("#getJobInformation").html("Retrieving Jobs, Please wait ...");
    $.get(path + "jobrent.ashx?type=jobs&filter=" + $("#jobType").val(), function (data) {
        $("#getJobInformation").html(startdata + data + enddata);
    });
}

function getRentData() {
    startdata = "<table class='ranks' width='100%' bgcolor='#999' cellpadding='8' cellspacing='1'><tr class='rankhdr'><td width='30'>S.No.</td><td width='150px'>Name</td><td>Description</td><td width='100px'>Contact</td></tr>";
    enddata = "</table>";
    $("#getRentInformation").html("Retrieving Rental Information, Please wait ...");
    $.get(path + "jobrent.ashx?type=rent&filter=" + $("#rentType").val(), function (data) {
        $("#getRentInformation").html(startdata + data + enddata);
    });
}*/

function getJobsData(n) {
    startdata = "<table class='ranks' width='100%' bgcolor='#999' cellpadding='8' cellspacing='1'><tr class='rankhdr'><td width='30'>S.No.</td><td width='150px'>Name</td><td>Description</td><td width='100px'>Contact</td></tr>";
    enddata = "</table>";
    $("#getJobInformation").html("Retrieving Jobs, Please wait ...");
    $.get(path + "jobrent.ashx?type=jobs&filter=" + n, function (data) {
        switch (n) {
            case 0: startdata = "<center><b>List of Jobs Offered</b></center><br />" + startdata; break;
            case 1: startdata = "<center><b>List of Job Aspirants</b></center><br />" + startdata; break;
            default: break;
        }    
        $("#getJobInformation").html(startdata + data + enddata);
    });
}

function getRentData(n) {
    startdata = "<table class='ranks' width='100%' bgcolor='#999' cellpadding='8' cellspacing='1'><tr class='rankhdr'><td width='30'>S.No.</td><td width='150px'>Name</td><td>Description</td><td width='100px'>Contact</td></tr>";
    enddata = "</table>";
    $("#getRentInformation").html("Retrieving Rental Information, Please wait ...");
    $.get(path + "jobrent.ashx?type=rent&filter=" + n, function (data) {
        switch (n) {
            case 0: startdata = "<center><b>List of Residential Houses / Flats To-Let</b></center><br />" + startdata; break;
            case 1: startdata = "<center><b>List of Commercial Shops To-Let</b></center><br />" + startdata; break;
            case 2: startdata = "<center><b>List of Warehouses / Godowns To-Let</b></center><br />" + startdata; break;
            default: break;
        }
        $("#getRentInformation").html(startdata + data + enddata);
    });
}

function getTenderData() {
    startdata = "<table class='ranks' width='100%' bgcolor='#999' cellpadding='8' cellspacing='1'><tr class='rankhdr'><td width='30'>S.No.</td><td width='150px'>Organization and<br />Last Date</td><td>Description</td><td width='100px'>Estimated Cost and EMD</td></tr>";
    enddata = "</table>";
    $("#getTenderInformation").html("Retrieving Tender Information, Please wait ...");
    $.get(path + "jobrent.ashx?type=tender", function (data) {
        $("#getTenderInformation").html(startdata + data + enddata);
    });
}

function showJoin() {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + "joinnow.htm", function (data) {
        $("#mycontent").html(data);
        $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div>");
        $("#txtAdName").focus();
    });
    $("#mycontent").fadeIn(1000);
    location.href = "#cw";
}

function jnFormValid() {
    var sn = document.getElementById("txtAdName");
    var sp = document.getElementById("txtAdPhone");
    var st = document.getElementById("txtType");
    if (!NameValidate(sn)) {
        alert('Please enter your Name');
        $("#txtAdName").val("");
        $("#txtAdName").focus();
    } else if (!CellValidate(sp)) {
        alert('Please enter valid Mobile Number in India');
        $("#txtAdPhone").focus();
    } else if (st.value == "0") {
        alert('Please choose your Profession');
        $("#txtType").focus();
    } else {
        $("#tnx").html("Please wait ...");
        $.get(path + "sms.ashx?type=joinnow&sndName=" + sn.value + "&sndPhone=" + sp.value + "&sndType=" + st.value, function (data) {
            $("#tnx").css("color", "#fff");
            $("#tnx").html(data);
            $("#txtAdName").val("");
            $("#txtAdPhone").val("");
        });
    }
    return false;
}

function showEvents() {
    $("#mycontent").css("background", "#222");
    if (path != "") $("#mycontent").css("height", "1355px");
    $("#mycontent").html("Please wait ...");
    $.get(path + "events.htm", function (data) {
        $("#mycontent").html(data);
        $("#mycontent").prepend("<div id='closeBtn'><a href='javascript:;' onclick='closeWindows()'><img src='" + path + "resources/images/close.png' alt='Close' border='0' /></a></div>");
        location.href = "#cw";
    });
    $("#mycontent").show();
}

function rbwFormValid() {
    var sn = document.getElementById("txtAdName");
    var sp = document.getElementById("txtAdPhone");
    var sa = document.getElementById("txtAddress");
    var sw = document.getElementById("txtWork");
    var msp = document.getElementById("txtMSP");
    if (!NameValidate(sn)) {
        alert('Please enter your Name');
        $("#txtAdName").val("");
        $("#txtAdName").focus();
    } else if (!CellValidate(sp)) {
        alert('Please enter valid Mobile Number in India');
        $("#txtAdPhone").focus();
    } else if (sp.value.length<10) {
        alert('Please enter your Complete Address located anywhere in Gulbarga district');
        $("#txtAddress").focus();
    } else if (sw.value.length < 3) {
        alert('Please enter your current Profession');
        $("#txtWork").focus();                
    } else {
        $("#tnx").html("Please wait ...");
        $.get(path + "asms.ashx?type=regbidwin&sndName=" + sn.value + "&sndPhone=" + sp.value + "&sndAddress=" + sa.value + "&sndWork=" + sw.value + "&sndMSP=" + msp.value, function(data) {
            $("#tnx").css("color", "#000");
            $("#tnx").html(data);
            $("#txtAdName").val("");
            $("#txtAdPhone").val("");
            $("#txtAddress").val("");
            $("#txtWork").val("");
        });
    }
    return false;
}

function addRangeSelect(bm) {
    var rng = "Rs <select id='bidAmt1'>";
    for (i = 0; i <= bm; i++) {
        rng += "<option value='" + i + "'>" + i + "</option>";
    }
    rng += "</select> Paise <select id='bidAmt2'><option value='00'>00</option><option value='25'>25</option><option value='50'>50</option><option value='75'>75</option></select>";
    $("#addRangeBox").html(rng);
}

function bidNow() {
    var bv = parseFloat($("#bidAmt1").val() + "." + $("#bidAmt2").val());
    var bm = document.getElementById("bidMobile");
    var bc = document.getElementById("bidCode");

    if (!CellValidate(bm)) {
        alert('Please enter valid Mobile Number in India');
        $("#bidMobile").focus();
    } else if (!NumberValidate(bc)) {
        alert('Please enter valid Verification Code received on your Mobile Phone');
        $("#bidCode").focus();
    } else if (bv == 0) {
        alert("Bid Amount can't be 0. Choose amount which is greater than 0 and less than or equal to " + bidMax + ".");
    } else if (bv > bidMax) {
        alert("Bid Amount can't be more than " + bidMax + ". Choose amount which is greater than 0 and less than or equal to " + bidMax + ".");
    } else {
        $("#tnx").html("Please wait ...");
        $("#bidRes").attr("disabled", true);
        $.get(path + "asms.ashx?type=bidnow&sndPhone=" + bm.value + "&sndCode=" + bc.value + "&sndAmt=" + bv + "&sndItemCode=" + bidID, function (data) {
            $("#tnx").css("color", "#fff");
            $("#tnx").html(data);
            //if(data.toString().indexOf("Thank") == -1) $("#bidRes").attr("disabled", false);
            $("#bidMobile").val("");
            $("#bidCode").val("");
        });

    }
}

try {
changeSmallAd(); changeBigAd(); changeRightAd(); changeTopAd(); setInterval("changeRightAd()", RightAdDuration); setInterval("changeTopAd()", TopAdDuration);
getMenu();  getNewsEvents(); getFooter();
} catch(e) {};


