// $Id$

/**
 * @file
 * OM Scripts
 *
 * @author: Daniel Honrade http://drupal.org/user/351112
 *
 */
 
jQuery(document).ready(function($){
	
/**
 * Disabled this functionality due to colorbox compatibility problem
 * for external links, open in new window
  $('a[href^=http]').click( function() {
    window.open(this.href);
    return false;	    
  });
 *
 */
}); 
;
//collapsible comments
/*
jQuery(document).ready(function($){
var 
pcounter=0,
ptotal=0,
$related_articles = $('<div id="related-articles-container"/>');
$related_articlesimage = $('<div class="imagearticles"><img src="/sites/default/themes/aw960/css/images/image_ad300x250_sample1.jpg" alt="AD 300x250" /></div>');
$related_articles.append('<div id="label">Related Articles</div>');
$related_articles.append($("#block-reltw-reltw-default"));
$related_articles.append($("#block-reltw-reltw-default-1"));
$('.node-type-article .node .field-name-body p').each( function(index, value) { 
  ptotal++;
});
$('.node-type-article .node .field-name-body p').each( function(index, value) { 
  pcounter++;
  if(ptotal<2){
  $(this).append($related_articles);
  } else{
    if(pcounter==2){
  $(this).append($related_articles);
    }
  }
  if(ptotal<4){
  $(this).append($related_articlesimage);
  } else{
    if(pcounter==4){
  $(this).append($related_articlesimage);
    }
  }
});
});

jQuery(document).ready(function($){
var
divtotal=0,
divcounter=0,
$qoutable = $("#block-block-26");
$('.section-operations #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divtotal++;
 });
$('.section-operations #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divcounter++;
  if(divtotal<3){
  $(this).append($qoutable);
  }else{
    if(divcounter==3){
  $(this).append($qoutable);
    }
  }
});
});
jQuery(document).ready(function($){
var
divtotal=0,
divcounter=0,
$qoutable = $("#block-block-27");
$('.section-control #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divtotal++;
 });
$('.section-control #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divcounter++;
  if(divtotal<3){
  $(this).append($qoutable);
  }else{
    if(divcounter==3){
  $(this).append($qoutable);
    }
  }
});
});
jQuery(document).ready(function($){
var
divtotal=0,
divcounter=0,
$qoutable = $("#block-block-28");
$('.section-informationmanagement #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divtotal++;
 });
$('.section-informationmanagement #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divcounter++;
  if(divtotal<3){
  $(this).append($qoutable);
  }else{
    if(divcounter==3){
  $(this).append($qoutable);
    }
  }
});
});
jQuery(document).ready(function($){
var
divtotal=0,
divcounter=0,
$qoutable = $("#block-block-29");
$('.section-safety #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divtotal++;
 });
$('.section-safety #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divcounter++;
  if(divtotal<3){
  $(this).append($qoutable);
  }else{
    if(divcounter==3){
  $(this).append($qoutable);
    }
  }
});
});
jQuery(document).ready(function($){
var
divtotal=0,
divcounter=0,
$qoutable = $("#block-block-30");
$('.section-security #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divtotal++;
 });
$('.section-security #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divcounter++;
  if(divtotal<3){
  $(this).append($qoutable);
  }else{
    if(divcounter==3){
  $(this).append($qoutable);
    }
  }
});
});
jQuery(document).ready(function($){
var
divtotal=0,
divcounter=0,
$qoutable = $("#block-block-32");
$('.section-energy #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divtotal++;
 });
$('.section-energy #block-system-main .view-category-part-1 div.views-row').each( function(index, value) { 
  divcounter++;
  if(divtotal<3){
  $(this).append($qoutable);
  }else{
    if(divcounter==3){
  $(this).append($qoutable);
    }
  }
});
});
*/

jQuery(document).ready(function($){
$('.page-home #block-views-main-story-block .views-field-body span').append($('.page-home #block-views-main-story-block .views-field-view-node span'));
});
jQuery(document).ready(function($){
$('.view-category-main-story .views-field-body span').append($('.view-category-main-story .views-field-view-node span'));
});

/*position the subscription text inside the article webform subscription h3*/
jQuery(document).ready(function($){
$('#webform-client-form-9301 #webform-component-description p').css('color','#4D4D4D');
$('#webform-client-form-9301 #webform-component-description p').css('display','inline');
$('#webform-client-form-9301 #webform-component-description p').css('font-size','0.7em');
$('#webform-client-form-9301 #webform-component-description p').css('margin-left','10px');
$('#webform-client-form-9301 #webform-component-description p').css('line-height','0');
$('#webform-client-form-9301 #webform-component-description p').css('position','relative');
$('#webform-client-form-9301 #webform-component-description p').css('top','0px');
$('.page-node #block-webform-client-block-9301 h3.title').append($('#webform-client-form-9301 #webform-component-description p'));
});
/*.page-node accordion tabs*/
/*used by comments and subscription block*/
jQuery(document).ready(function($){

$('.block-webform h3.title').click(function () {
  $(".block-webform .content").toggle('normal',function() {
    if( $(".block-webform .content").is(':hidden') ) {
      $('.block-webform h3.title').css('background-position','0 0');
    }
    else {
      $('.block-webform h3.title').css('background-position','0 -31px');
    }
   }
  );
});

$('h3.comments-tab').click(function () {
  $("#comments").toggle('normal',function() {
    if( $("#comments").is(':hidden') ) {
      $('h3.comments-tab').css('background-position','0 0');
    }
    else {
      $('h3.comments-tab').css('background-position','0 -31px');
    }
   }
  );
});

});
/*
(function($) {$(function() {
  var $comments = $('#comments');
  if (!$comments.size()) return;
  var count = $comments.find('.comment').size();
  // if (!count) return; // Do nothing when there is no comment.
  var label = Drupal.formatPlural(count, 'Comment (1)', 'Comments (@count)');
  var $legend = $(document.createElement('legend')).html('<span class="fieldset-legend">' + label + '</span>');
  var fsetclass = 'comments collapsible' + (location.href.search(/#(comment|new)/) == -1 ? ' collapsed' : '');
  
	var $fsetwrapout = $(document.createElement('div')).addClass('fieldset-wrapper-outer').attr('id', 'page-comments');
  var $fset = $(document.createElement('fieldset')).addClass(fsetclass);
  var $fsetwrap = $(document.createElement('div')).addClass('fieldset-wrapper');
  
	$fsetwrapout.insertBefore($comments).append($fset);
	
	$fset.append($legend).append($fsetwrap);
  $fsetwrap.append($comments);

  var attach = function() {Drupal.behaviors.collapse.attach($fset.parent(), Drupal.settings);};
  Drupal.behaviors.collapse ? attach() : $.getScript(Drupal.settings.basePath + 'misc/collapse.js', attach);
});})(jQuery);
*/

jQuery(document).ready(function($){ // this will add the hover effect in the frontpage news image block
  $("#block-views-news-block .attachment-after .views-row .views-field-field-image .field-content .container").hover(
    function () {
    jQuery("span", this).css('background','url("sites/default/themes/aw960/css/images/bghover.png")');
    },
    function () {
      jQuery("span", this).css('background','url("sites/default/themes/aw960/css/images/bg.png")');
    }
  );
});;

