// JavaScript Document
window.onload = function ()
{
    setopacity(g_elem("reviewdiv"),0);
    g_elem("slideReviews").onmouseover= function(){
        fadein('reviewdiv');
    }
    g_elem("slideReviews").onmouseout=function(){
        fadeout('reviewdiv');
    }
    
}


function fadein(element){
    fadein_(element,0);
}
function fadeout(element){
    fadeout_(element,10);
}


function g_elem (html){
    return document.getElementById(html);
}

function fadein_(element,state) {
    var elem = document.getElementById(element);
    if(state == 11)
        return;
    setopacity(elem,state);
    elem.style.zIndex = 5;
    setTimeout("fadein_('"+element+"'," + (++state)+")",33);
}
function setopacity(elem,opa){
    if(elem)
    {
            
        elem.style.opacity = opa/10;
        elem.style.filter = 'alpha(opacity=' + opa*10 + ')';
    }
}
function fadeout_(element,state) {
    var elem = document.getElementById(element);
    if(state == -1)
        return;
    setopacity(elem,state);
    elem.style.zIndex = 5;
    setTimeout("fadeout_('"+element+"'," + (--state)+")",33);
}

function loadimages()
{
    
}

function xmlhttpPost(strURL,parameters,callback,arguments2) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttpReq.open('POST', strURL, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttpReq.onreadystatechange = function() {
        if (xmlHttpReq.readyState == 4) {
            callback(xmlHttpReq.responseText,arguments2);
        }
    }
    xmlHttpReq.send(parameters);
}



function addLoadEvent(old,test2) {
    var test = old;
    if (typeof(old) != 'function') {
        old = test2;
    } else {
        old = function() {
            if (test) {
                test();
            }
            test2();
        }
    }
    return old;
}


function images(imageid)
{
    
    xmlhttpPost("index.php/maincontroller/images","imageid="+imageid, putimages, "");
}


function putimages(r)
{
    var imagediv=document.getElementById("imagediv");
    r=eval("("+r+")");
    if(r.imagescount==0)
    {
        imagediv.style.display="none";
        return;
    }
    imagediv.style.display="block";
    imagediv=document.getElementById("imagedivcontainer");
    var text="";
    for(i=0;i<r.imagescount;i++)
    {
        text+="<div class=\"frame\"><div class=\"imagecontainer\"><img src=\""+r.images[i].square +"\" width=\"131\" height=\"89\" /></div><p>"+r.images[i].title +"</p></div>";
    }
    imagediv.innerHTML=text;
}
