
function displayItem(theitem) {
var theid = document.getElementById(theitem);
theid.style.display = "";
}
function hideItem(theitem) {
var theid = document.getElementById(theitem);
theid.style.display = "none";
}
function changeClassName(theitem,theclass) {
var theid = document.getElementById(theitem);
theid.className = theclass;
}
function changeImageSrc(theitem,thesrc) {
document.getElementById(theitem).src = thesrc;
}
function updateField(theitem,thehtml) {
if (document.getElementById(theitem) != null) {
document.getElementById(theitem).innerHTML = thehtml;
}
}

/* */
function orderPicture(thetype,theurl) {
location.href = "http://mdmpix.com/" + theurl + thetype;
}

function mdmLink(theurl) {
location.href = "http://mdmpix.com/" + theurl;
}


function manageBrowseOptions(theurl,theon) {
getThePart('contentzone',theurl + '?setcook=1&setbrowsecook=' + theon);
changeClassName('brwopt1','');changeClassName('brwopt2','');changeClassName('brwopt3','');changeClassName('brwopt4','');
changeImageSrc('brwopt1-img','/elements/design/display-large-off.png');
changeImageSrc('brwopt2-img','/elements/design/display-large-det-off.png');
changeImageSrc('brwopt3-img','/elements/design/display-small-off.png');
changeImageSrc('brwopt4-img','/elements/design/display-small-det-off.png');
if (theon == 'Large') {
changeClassName('brwopt1','navon');changeImageSrc('brwopt1-img','/elements/design/display-large-on.png');
} else if (theon == 'Large-Details') {
changeClassName('brwopt2','navon');changeImageSrc('brwopt2-img','/elements/design/display-large-det-on.png');
} else if (theon == 'Small') {
changeClassName('brwopt3','navon');changeImageSrc('brwopt3-img','/elements/design/display-small-on.png');
} else if (theon == 'Small-Details') {
changeClassName('brwopt4','navon');changeImageSrc('brwopt4-img','/elements/design/display-small-det-on.png');
} 
}

function manageSortOptions(theurl,theon) {
getThePart('contentzone',theurl + '?setcook=1&setsortcook=' + theon);
changeClassName('sortby-location','');
changeClassName('sortby-added','');
changeClassName('sortby-' + theon,'navon');
}

/* */
function checkSearch() {
var thequery = document.getElementById("qsearch").value;
if (thequery.length > 2) {
hideItem('searcherror');
return true;
} else {
displayItem('searcherror');
return false;
}
}

/* */
function overlayItem(theitem,thearg) {
if (theitem == 'sendcard') {
updateField("poverlay-head","Internet Postcard");
updateField("poverlay-content",'<iframe src="/elements/ajax/card_prepare.php?picture=' + thearg + '" frameborder="0" scrolling="no" style="width:100%; height:440px;"></iframe>');

} else {


}
displayItem("poverlay");
document.getElementById("poverlay").scrollIntoView(true);
}





/* */
var loadingWidget = '<div class="loadingwidget"><div>Loading.<blink>.</blink>.<br>Please Wait!</div></div>';

function makeHttpObject() {
    var xmlHttpObj;
    /*@cc_on
    @if (@_jscript_version >= 5)
        try {
            xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlHttpObj = false;
            }
        }
    @else
        xmlHttpObj = false;
    @end @*/
    if (!xmlHttpObj && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlHttpObj = new XMLHttpRequest();
        } catch (e) {
            xmlHttpObj = false;
        }
    }
    return xmlHttpObj;
}
var httpObj = makeHttpObject(); // create the HTTP Object

function getHttpResponse() {
if (httpObj.readyState == 4) {
if (httpObj.status == 200) {
var theHTML = httpObj.responseText;
var idname = document.thetargetid;
if (idname == 'picdata') {
var picparts = theHTML.split('^~^');
document.getElementById(idname).innerHTML = picparts[0];
document.getElementById('picinfo').innerHTML = picparts[1];
} else {
document.getElementById(idname).innerHTML = theHTML;
}


} else {
alert("There was a problem with the response: " + 
httpObj.statusText);
}
}
}
document.last = "";
document.laststartat = 0;

function getThePart(thetarget,theurl) {
var tarit = document.getElementById(thetarget);
tarit.innerHTML = loadingWidget + tarit.innerHTML;
document.thetargetid = thetarget;
document.therecipid = "";
httpObj.open("GET", theurl, true);
httpObj.onreadystatechange = getHttpResponse;
httpObj.send(null);
}
