/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do {curDate = new Date();}
while(curDate-date < millis);
}

function expandCollapse(id){
    if ($('#'+id).is(":hidden")) {
        $('#'+id).slideDown("slow");
      } else {
        $('#'+id).slideUp('slow');
      }
}

function changeImage(id,changeTo,changeBack){
    if (document.getElementById(id).src != changeTo){
        document.getElementById(id).src = changeTo;
    } else if (changeBack != null) {
        document.getElementById(id).src = changeBack;
    }
}

function getEl(id){
    return document.getElementById(id);
}

function getByN(name){
    return document.getElementsByName(name);
}

function in_array( what, where ){
    for(var i=0;i<where.length;i++){
        if(what == where[i]){
            return true;
        }
    }
    return false;
}

function showHideLoadingAnimation(animId){
    var loadAnim = getEl(animId);
    if (loadAnim){
        if (loadAnim.style.display=='none'){
            loadAnim.style.display='inline';
        } else {
            loadAnim.style.display='none';
        }
    }
}

// X-Browser isArray(), including Safari
// @link: http://www.bram.us/2008/02/01/javascript-isarray-check-if-an-elementobject-is-an-array/
function isArray(obj) {
    return obj.constructor == Array;
}

var c=0;
var index=0;
var i=0;
var base='';
var max=0;
function rotate(pBase,pMax){
    base=pBase;
    max=pMax;
    rotation();
}
function rotation(){
    index = c % max + 1;
    // for (i=1;i<=max;i++){
        document.getElementById('rot'+index).style.backgroundColor='inherit';
        document.getElementById('rot'+index).style.color='black';
        $('#offertaImg'+index).fadeOut(1000); //style.dislay='none';
        $('#offertaDetails'+index).fadeOut(1000); //style.dislay='none';
        
    // }
    c=c+1;
    index = c % max + 1;
    document.getElementById('rot'+index).style.backgroundColor='black';
    document.getElementById('rot'+index).style.color='white';
    
    $('#offertaImg'+index).fadeIn(1000); //style.dislay='block';
    $('#offertaDetails'+index).fadeIn(1000); //style.dislay='block';
    t=setTimeout(rotation,5000);
}

function trim(text){
    return text.replace(/^\s*/, "").replace(/\s*$/, "");
}

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
    if (window.sidebar) // firefox
            window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print){ // opera
            var elem = document.createElement('a');
            elem.setAttribute('href',url);
            elem.setAttribute('title',title);
            elem.setAttribute('rel','sidebar');
            elem.click();
    }
    else if(document.all)// ie
            window.external.AddFavorite(url, title);
}


