
var request;
function load_skype(url) {
    try {
        if (window.XMLHttpRequest) {
            request = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            request = new ActiveXObject("Msxml2.XMLHTTP");
            if (!request) {request = new ActiveXObject("Microsoft.XMLHTTP");}
        }
        if (request) {
            request.onreadystatechange = doajax;
            request.open('GET', url, true);
            request.send(null);
        }
    } catch (errv) {
        // alert('bad ajax ' + errv.message);
    }
}

function doajax() {
    if (request.readyState == 4) {
        if (request.status == 200) {
            var resp = request.responseText;
            var elt = document.getElementById('skype');
            elt.innerHTML = resp;
        }
    }
}

function show_colours(idcolours, colours) {
    var xtab = document.createElement('table');
    var xtbody = document.createElement('tbody');
    var xtrow = document.createElement('tr');
    for (var i = 0; i < colours.length; ++i ) {
        var xtcell = document.createElement('td');
        var colour = colours[i];
        xtcell.bgColor = '#' + colour;
        xtcell.onclick = function () {setcolour(this.bgColor);};
        xtcell.onclick.colour = colour;
        xtcell.width = 15;
        xtcell.height = 15;
        xtcell.className = 'pointable';
        var node = document.createTextNode(' ');
        xtcell.appendChild(node);
        xtrow.appendChild(xtcell);
        if (i % 25 == 24) {
            xtbody.appendChild(xtrow);
            xtrow = document.createElement('tr');
        }
    }
    xtbody.appendChild(xtrow);
    xtab.appendChild(xtbody);
    idcolours.appendChild(xtab);
}

var currpage;
var frames_per_page = 16;
var num_frames = 1;
function showframes(page, nf) {
    num_frames = nf;
    var idframes = document.getElementById('frameslist');
    var idtable = document.getElementById('frametable');
    if (idtable != undefined) {idframes.removeChild(idtable);}
    var xtab = document.createElement('table');
    xtab.setAttribute('id', 'frametable');
    var xtbody = document.createElement('tbody');
    var xtrow = document.createElement('tr');
    for (var i = 0; (i < frames_per_page) && (page * frames_per_page +
                                              i < num_frames); ++i ) {
        var frame =  framedata[page * frames_per_page + i];
        var xtcell = document.createElement('td'); 
        xtcell.className = 'pointablebordered';
        xtcell['frameid'] = frame.id;
        xtcell.onclick = 
            function() {setframe(this.frameid); return true;};
        var node = document.createTextNode(frame.descr + ' ');
        xtcell.appendChild(node);
        node = document.createElement('br');
        xtcell.appendChild(node);
        node = document.createElement('img');
        node.setAttribute('src', frame.picsrc);
        xtcell.appendChild(node);
        node = document.createElement('br');
        xtcell.appendChild(node);
        node = document.createElement('font');
        var node2 = document.createTextNode(frame.in_stock 
                                            ? ''  : '');
        node.appendChild(node2);
        node.setAttribute('color', frame.in_stock ? 'green' :'red');
        xtcell.appendChild(node);
        xtrow.appendChild(xtcell);
        if (i % 3 == 2) {
            xtbody.appendChild(xtrow);
            xtrow = document.createElement('tr');
        }  
    }
    xtbody.appendChild(xtrow);
    xtab.appendChild(xtbody);    
    idframes.appendChild(xtab);         
    currpage = page;
}
function moreframes() {
    if ((currpage + 1) * frames_per_page >= num_frames) {
        showframes(0, num_frames);
    } else {
        showframes(currpage + 1, num_frames);
    }
}

// Browser Window Size and Position
// copyright ebuypainting.com, 3rd Jan 2008, 8th Dec 2008
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {
    return window.innerWidth != null
        ? window.innerWidth : document.documentElement && document.documentElement.clientWidth 
        ? document.documentElement.clientWidth : document.body != null 
        ? document.body.clientWidth : null;
} 

function pageHeight() {
    return  window.innerHeight != null
        ? window.innerHeight : document.documentElement && document.documentElement.clientHeight 
        ?  document.documentElement.clientHeight : document.body != null
        ? document.body.clientHeight : null;
} 

function posLeft() {
    return typeof window.pageXOffset != 'undefined' 
        ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft 
        ? document.documentElement.scrollLeft : document.body.scrollLeft 
        ? document.body.scrollLeft : 0;
} 

function posTop() {
    return typeof window.pageYOffset != 'undefined' 
        ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop 
        ? document.documentElement.scrollTop : document.body.scrollTop 
        ? document.body.scrollTop : 0;
} 

function posRight() {return posLeft()+pageWidth();} 
function posBottom() {return posTop()+pageHeight();}

                   
