/*$Header: /home/cvs/www.highlevelplatforms.com/public_html/scripts/common.js,v 1.1 2007/07/25 09:16:50 melissa Exp $*/

var is_safari = (document.childNodes)&&(!document.all)&&(!navigator.taintEnabled)&&(!navigator.accentColorName)?true:false;
var is_ie55 = (document.all && document.fireEvent && !document.createComment);
INT = new Object();

INT.win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);

$(document).ready(function() {
    $('.tips').INTToolTip(options);
    INT.tabRollvers();
    INT.setStyle();
    INT.textResizeSetUp();
    externalLinks();
    chooseFeaturedProduct();
    //$('#featured-products div').fadeIn(1000);
});

// pick a featured product and display it
// add/change testimonials in content/testimonials.html
function chooseFeaturedProduct() {
  $('#featured-products div').hide();
  var howMany = $('#featured-products div').size();
  if (! howMany) return;
  // selected is a pseudo random number between 0 and howMany-1
  var selected = Math.floor(Math.random() * howMany);
  $('#featured-products div:eq(' + selected + ')').fadeIn(1000);
  // call me again soon!
  setTimeout('chooseFeaturedProduct()', 10000);
}

var options = {
    'clname':'tipclass',
    'offsetx': 10,
    'offsety': 10,
    'fadeinspeed':'fast',
    'fadeoutspeed':'fast',
    'childelement': 'li'
};

function externalLinks(){
    if (document.getElementsByTagName){
        var objAnchors = document.getElementsByTagName('a');
        for (var iCounter=0; iCounter<objAnchors.length; iCounter++){
            if (objAnchors[iCounter].getAttribute('href') && objAnchors[iCounter].getAttribute('rel') == 'external'){
                objAnchors[iCounter].onclick = function(event){return launchWindow(this, event);};
                objAnchors[iCounter].onkeypress = function(event){return launchWindow(this, event);};
            }
        }
    }
}

function launchWindow(objAnchor, objEvent){
    var iKeyCode;
    if (objEvent && objEvent.type == 'keypress'){
        if (objEvent.keyCode)
            iKeyCode = objEvent.keyCode;
        else if (objEvent.which)
            iKeyCode = objEvent.which;
        if (iKeyCode != 13 && iKeyCode != 32)
        return true;
}

return !window.open(objAnchor);
}

//elements that do text resize stuff
INT.resizeArr = ['default','larger','largest']

INT.textResizeSetUp = function(){
//assign events
$.each(INT.resizeArr, function(){
 $('#'+this).click(function(){INT.switchStylestyle(this.id);});
});
}

INT.setStyle = function(){

  var cookie = $.cookie('style');

  if(cookie)
    INT.switchStylestyle(cookie);

}

INT.switchStylestyle = function(styleName) {
    $('link[rel*=style][title]').each(function(i) {
        this.disabled = true;
        if (this.getAttribute('title') == styleName) this.disabled = false;
    });
    $.cookie('style', styleName, {
        expires: 365
    });
}


//rollovers for browser that can't do hover
INT.tabRollvers = function(){

$("#top_nav").children('li').each(function(i){

if(this.className.match('roll')){
  $(this).mouseover(function() { this.className = this.className+'on';});
  $(this).mouseout(function() {  this.className=this.className.replace(new RegExp("on\\b"), ""); });
  }
});



};




