﻿/* <![CDATA[ */


function ShowImage(imgurl, owner, time, title, country, state, city) {
    objectPhoto = "<table width='790px' style='border: solid 1px #000000;background:#ffffff;'><tr><td width='100%' colspan='3' align='right' class='text'><div><a href='Javascript:void(0);' onclick='hidePopup(\"popupView\");'>Close</a></div><img src='images/b.gif' height='30px' /></td></tr><tr><td width='100%'><table><tr><td valign='top'><img src='" + unescape(imgurl) + "' alt='" + unescape(title) + "'/></td><td valign='top' align='left'><table cellpadding='0' cellspacing='0' border='0'><tr><td class='text'>Owner :</td><td class='text'>" + unescape(owner) + "</td></tr><tr><td class='text'>Time :</td><td class='text'>" + unescape(time) + "</td></tr><tr><td class='text'>Title :</td><td class='text'>" + unescape(title) + "</td></tr><tr><td class='text'>Country :</td><td class='text'>" + unescape(country) + "</td></tr><tr><td class='text'>State :</td><td class='text'>" + unescape(state) + "</td></tr><tr><td class='text'>City :</td><td class='text'>" + unescape(city) + "</td></tr></table></td></tr></table></td></tr></table>";
    showPopup('popupView', objectPhoto)
    //alert(imgurl + owner + time + title + country + state + city);
    
    return false;
}

function changeClass(ob) {
    ob.className = 'imgClassh';
}

function changeClass1(ob) {
    ob.className = 'imgClass';

}


var xmlhttp = false; ;
try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
    try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
        xmlhttp = false;
    }
}

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
        xmlhttp = new XMLHttpRequest();
    } catch (e) {
        xmlhttp = false;
    }
}
if (!xmlhttp && window.createRequest) {
    try {
        xmlhttp = window.createRequest();
    } catch (e) {
        xmlhttp = false;
    }
}



var obj;
var first = 0;
var last = 0;

function CallAjax(before, after) {
    callurl = "JsonProxy.ashx?url=";
    if ((before == 0) && (after == 0)) {
        callurl = callurl + escape("http://www.photowall.com/m/photos/tag.json?tags=Mumbaiindians&limit=30&cb=" + Math.round(Math.random() * 965824579437));
    }
    else if (before == 0) {
    callurl = callurl + escape("http://www.photowall.com/m/photos/tag.json?tags=Mumbaiindians&after=" + after + "&limit=30&cb=" + Math.round(Math.random() * 965824579437));
        document.getElementById('btnPrevious').style.visibility = 'visible';
    }
    else if (after == 0) {
    callurl = callurl + escape("http://www.photowall.com/m/photos/tag.json?tags=Mumbaiindians&limit=30&before=" + before + "&cb=" + Math.round(Math.random() * 965824579437));
    }

    //alert(callurl);

    xmlhttp.open("GET", callurl, true);
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            try {
                obj = eval('(' + xmlhttp.responseText + ')');
            }
            catch (e) {

                text = JSON.stringify(xmlhttp.responseText);
                //alert(text + "," + xmlhttp.responseText);
                obj = JSON.parse(text, function(key, value) {
                    var type;
                    if (value && typeof value === 'object') {
                        type = value.type;
                        if (typeof type === 'string' && typeof window[type] === 'function') {
                            return new (window[type])(value);
                        }
                    }
                    return value;
                });

            }
            //alert(eval('(' + xmlhttp.responseText + ')'));
            CreateWall(obj);
        }
        else {
            document.getElementById('PhotoWallId').innerHTML = "<div style='width:872px;height:420px;align:center'><img src='images/MILoader.gif' style='margin-top:196px'/>";
        }
    }
    xmlhttp.send(null);
}


function CreateWall(obj) {
    var i = 0;
    count = obj.photos.length;
    var a = "";
    a = "<table border='0' cellspacing='0' cellpadding='0' ><tr>";

    while (i < count) {
        //" + obj.photos[i].url_full + "
        if (i == 3) {
            //a += "<td colspan='8' rowspan='6' width='324' align='center'><img src='images/cannon_300X250.jpg' width='300'  height='250' /></td>";
        }


        a += "<td><a href='#' title='" + obj.photos[i].title + "' onclick='return ShowImage(" + "\"" + escape(obj.photos[i].url_full) + "\"," + "\"" + escape(obj.photos[i].media_owner) + "\"," + "\"" + escape(obj.photos[i].timestamp) + "\"," + "\"" + escape(obj.photos[i].title) + "\"," + "\"" + escape(obj.photos[i].country) + "\"," + "\"" + escape(obj.photos[i].state) + "\"," + "\"" + escape(obj.photos[i].city) + "\"" + ");'><img src='" + obj.photos[i].url_thumb + "' width='80' height='80' border='0' alt='" + obj.photos[i].title + "' class='imgClass' id='" + obj.photos[i].media_id + "' name='" + obj.photos[i].media_id + "' onmouseover='changeClass(this);' onmouseout='changeClass1(this);'/></a></td>";

        /*if (i < 21) {
            if (i % 6 != 5) {
                a += "<td><img src='images/b.gif' width='2'/></td>";
            }
            i++;
            if ((i % 6 == 0) && (i != count)) {
                a += "</tr><tr><td><img src='images/b.gif' height='2'/></td></tr><tr>";
            }
        }
        else { */
            if (i % 10 != 9) {
                a += "<td><img src='images/b.gif' width='2'/></td>";
            }
            i++;
            if ((i % 10 == 0) && (i != count)) {
                a += "</tr><tr><td><img src='images/b.gif' height='2'/></td></tr><tr>";
            }
        
        //}
        if (i == count) {
            a += "</tr><tr>";
        }

    }
    a += "</tr></table>";
    document.getElementById('PhotoWallId').innerHTML = a;
    first = obj.photos[0].media_id;
    last = obj.photos[obj.photos.length - 1].media_id;


}





function GetNext() {
    if (obj.photos.length > 30) {
        CallAjax(last, 0);
     }
   
}

function GetPrevious() {
    if (first == 0) {
        CallAjax(0, first);
    }
}




/* ]]> */
