// Preload Images
var preloaded = new Array();
function preload_images() {
    for (var i = 0; i < arguments.length; i++){
        preloaded[i] = document.createElement('img');
        preloaded[i].setAttribute('src',arguments[i]);
    };
};
preload_images(
        '/public/images/btn-back-over.gif',
        '/public/images/btn-cancel-over.gif',
        '/public/images/btn-update-over.gif',
        '/public/images/btn-change-password-over.gif',
        '/public/images/btn-login-over.gif',
        '/public/images/btn-next-over.gif',
        '/public/images/btn-preview-over.gif',
        '/public/images/btn-save-fullname-over.gif',
        '/public/images/btn-save-over.gif',
        '/public/images/btn-save-profilename-over.gif',
        '/public/images/btn-search-over.gif',
        '/public/images/ico-a-over.gif',
        '/public/images/ico-buy-over.gif',
        '/public/images/ico-check-over.gif',
        '/public/images/btn-rename-over.gif',
        '/public/images/btn-duplicate-over.gif',
        '/public/images/btn-submit-over.gif',
        '/public/images/btn-contact-user-over.gif',
        '/public/images/btn-edit-over.gif',
        '/public/images/btn-publishListing-over.gif',
        '/public/images/btn-promo-done-over.gif',
        '/public/images/btn-publish-my-listing-over.gif',
        '/public/images/btn-promo-add-over.gif',
        '/public/images/btn-calculate-over.gif',
        '/public/images/ico-worth-over.gif',
        '/public/images/ibox/btn-add-link-over.gif',
        '/public/images/ibox/btn-add-over.gif',
        '/public/images/ibox/btn-done-over.gif',
        '/public/images/btn-submit-claim-over.gif',
        '/public/images/ibox/btn-back-over.gif',
        '/public/images/ibox/btn-cancel-over.gif',
        '/public/images/ibox/btn-cant-find-a-match-over.gif',
        '/public/images/ibox/btn-delete-link-over.gif',
        '/public/images/ibox/btn-delete-over.gif',
        '/public/images/ibox/btn-preview-over.gif',
        '/public/images/ibox/btn-remove-over.gif',
        '/public/images/ibox/btn-save-as-draft-over.gif',
        '/public/images/ibox/btn-save-n-publish-over.gif',
        '/public/images/ibox/btn-submit-over.gif',
        '/public/images/ibox/btn-reset-over.gif',
        '/public/images/getworth_roll.gif',
        '/public/images/giveworth_roll.gif',
        '/public/images/sellit_roll.gif'
        );

        /* Change Button on Hover */
        function ChangeBtn(element) {
            var ElementSrc = element.getAttribute("src");
            var length = ElementSrc.length;
            var OverStr = "-over.";
            var IsOverStr = ElementSrc.indexOf(OverStr);
            var DesSrc;
            if (IsOverStr == -1) {
                DesSrc = ElementSrc.slice(0, length-4) + OverStr + ElementSrc.slice(length-3, length);
            }
            else {
                DesSrc = ElementSrc.slice(0, length-9) + ElementSrc.slice(length-4, length);
            }
            element.setAttribute("src",DesSrc);
        }

/* Help */
function getHelp(element) {
    var nextElement = element.nextSibling.nextSibling;
    if (nextElement.style.display == "none") {
        nextElement.style.display = "block";
    }
    else nextElement.style.display = "none";
}


/* Widget */
function previewWidget(predefinedColor)	{
    if (predefinedColor != null) color = predefinedColor;
    else {
        colorBox = document.getElementById('widgetColor');
        color = colorBox.value;
    }
    titleBox = document.getElementById('widgetTitle');
    tilte = titleBox.value;

    alert(title);
    alert(color);
}

/* Data reloading */
function reloadDataSection() {
    if ($('dataReloading').style.display == "none") {
        $('dataReloading').style.display = "block";
        setTimer(3);
    }
    else {
        $('dataReloading').style.display = "none";
        setTimer(10);
    }
    $('dataReloading').style.height = $('areYouWorthy').clientHeight - 5 + "px";
    $('dataReloading').style.lineHeight = $('areYouWorthy').clientHeight - 5 + "px";
}
function setTimer(timer) {
    setTimeout(reloadDataSection, timer*1000);
}

/* Add Event Listener */
Event.observe(window, 'load', function() {

        hoverBox('venjuvoPrice');
        hoverBox('ztailPrice');
        if ($('rating')) {                                                          
           var allLI = $('rating').childElements();                                
           for (i = 0; i < allLI.length; i++) {                                    
              allLI[i].observe('mouseover', function(event){                      
                this.getElementsBySelector('div')[0].style.display = 'block';   
            });                                                                 
            allLI[i].observe('mouseout', function(event){                       
                this.getElementsBySelector('div')[0].style.display = 'none';    
            });                                                                 
           }                                                                       
        }                                                                           
});
/* iPhonePromo */
function hoverBox(e) {
    if($(e)) {
        $(e).onmouseover = function() {
            this.addClassName('BoxOver');
        }
        $(e).onmouseout = function() {
            this.removeClassName('BoxOver');
        }
    }
}

/*Event.observe(window, 'load', function() {
  var toLoad = $A($w(' /script/appraize2.js /script/tinymce/jscripts/tiny_mce/tiny_mce_src.js http://widgets.clearspring.com/launchpad/include.js ' ));
  var head= document.getElementsByTagName('head')[0];
  var script= document.createElement('script');
  script.type= 'text/javascript';
  toLoad.each(function(n) {
  var script= document.createElement('script');
  script.type= 'text/javascript';
  script.src= n;
// head.appendChild(script);
}
);


}
);
*/

