$(document).ready(function(){
	
    $('#toggle_testimonials').click(function(){
        $('#clients_page_container').css('display', 'none');
        $('#testimonials_page_container').fadeIn('slow');
        $(this).css('color', '#297931').css('font-size', '16px'); 
        $('#toggle_clients').css('font-size', '12px');
    });

    $('#toggle_clients').click(function(){
        $('#testimonials_page_container').css('display', 'none');
        $('#clients_page_container').fadeIn('slow');
        $(this).css('color', '#297931').css('font-size', '16px');
        $('#toggle_testimonials').css('font-size', '12px');
    }).css('font-size', '16px');

    //check currently anchored div in testimonials
    var myFile = document.location.toString();
    var myAnchor = myFile.split('#')[1];
    if(myAnchor == 'testimonials'){
      $('#clients_page_container').css('display', 'none');
      $('#testimonials_page_container').fadeIn('slow');
      $('#toggle_testimonials').css('color', '#297931').css('font-size', '16px'); 
      $('#toggle_clients').css('font-size', '12px');
    }
    if(myAnchor == 'clients'){
      $('#testimonials_page_container').css('display', 'none');
      $('#clients_page_container').fadeIn('slow');
      $('#toggle_clients').css('color', '#297931').css('font-size', '16px');
      $('#toggle_testimonials').css('font-size', '12px');
    }


    //PORTFOLIO PAGE
    $("div.portfolio_nav a").click(function(){
      openwhatp = $(this).attr("class"); //get the table to open
      //alert("open page: "+openwhatp); //debug
      $("table.p_page").fadeOut(); //fade out all the tables
      $("table."+openwhatp).fadeIn(); //fade in the page to open
      $("div.portfolio_nav a").css('font-size', '13px').css('font-weight', 'normal');
      $("a."+openwhatp).css('font-size', '15px').css('font-weight', 'bolder');
      
    });


    //CONTACT FORM 
    $("#contactform").submit(function(){
        var errors = 0;
        $('.required').each(function(i){
            if($(this).val() == ''){
                $('.required').css('border', 'solid 1px red');
                $("#errormsg").text('Please fill up all of the required fields (*) first before submitting.');
                errors = 1;
                return false;
            }
        });
        if(errors == 1){
            return false;
        } else {
            return true;
        }
    });

    $("a[rel^=lightbox]").lightBox();

    $('.testimonials_block_content').cycle({
        fx: 'scrollHorz',
        timeout: 0,
        next: '#testi_next',
        prev: '#testi_prev'
    });
    $('.sf-menu').superfish({
        animation: {opacity:'show',height:'show'},
        speed: 'slow'
    });

    $('.testimonials_block_content_3').cycle({
      fx: 'fade',
      timeout: 0,
      next: '.testinext',
      prev: '.testiprev',
      cleartype: true,    
      cleartypeNoBg:  true
    });

    $('.newsrotate').cycle({
      fx: 'fade',
      cleartype: true,
      cleartypeNoBg: true
    });

    $("a.inline").fancybox({ 'hideOnContentClick': true, 'frameHeight': 310, 'frameWidth': 512}); 

});

function sb_feedbackForm () {
  //var myurl = document.location.href;
  //myurl = myurl.replace ("http://www.ontimesupplies.com", "").replace ("https://www.ontimesupplies.com", "");

  $.fn.colorbox ({href: "http://www.pearlogic.com/contactpopup.aspx", open: true, width: "665px", height: "550px", title: "Contact Pear Logic", speed: 150, iframe: true});


  //$.fn.colorbox ({href: "http://www.pearlogic.com/contactpopup_thankyou.aspx", open: true, width: "665px", height: "550px", title: "Contact Pear Logic", speed: 150, iframe: true});
}

