var tgs = new Array( 'div','td','tr','span','p','h1','h2','a' );



function ts( trgt, inc ) {

  var sz = 0;

  

  for ( i = 0 ; i < tgs.length ; i++ )

  {

    jQuery('#' + trgt + ' ' + tgs[ i ]).each(function()

    {

      var ourText = jQuery(this);

      var currFontSize = jQuery(this).css('fontSize');

      var finalNum = parseFloat(currFontSize, 10);

      var stringEnding = currFontSize.slice(-2);

      if(inc) {

        finalNum *= 1.2;

      }

      else {

        finalNum /=1.2;

      }

      jQuery(this).css('fontSize', finalNum + stringEnding);

    });

  }

}



function fromDatapicker(month, year, next)

{

  if (next > 0)

  {

    if (month == 12)

    {

      month = 1;

      year = (year * 1) + 1;

    }

    else

    {

      month = (month * 1) + 1;

    }

  }

  else

  {

    if (month == 1)

    {

      month = 12;

      year = (year * 1) - 1;

    }

    else

    {

      month = (month * 1) - 1;

    }

  }

  

  jQuery('.cls-date').attr('style', 'font-weight: normal !important; color: #222222 !important;');

  

  var curl = "http://www.csi360.com/set-colors-on-calendar.html";

  //var curl = "http://qa.informa-it-solutions.com/csi-new/set-colors-on-calendar.html";

  //var curl = "http://localhost/webbizideas/www.csi360.com/pro/set-colors-on-calendar.html";

  

  jQuery.ajax({

    type: "GET",

    url: curl,

    data: "month="+month+"&year="+year,

    success: function(dates) {

      var exploded = dates.split('::');

      for ( var i in exploded )

      {

        jQuery('.date-'+exploded[i]).attr('style', 'font-weight: bold !important; color: #669933 !important;');

      }

    }

  });

}



function dateClicked(cday, cmonth, cyear)

{

  if (cmonth == 12) cmonth = 1;

  else cmonth = (cmonth * 1) + 1;

  

  var curl = "http://www.csi360.com/news-and-events.html?tab=3";

  //var curl = "http://qa.informa-it-solutions.com/csi-new/news-and-events.html?tab=3";

  //var curl = "http://localhost/webbizideas/www.csi360.com/pro/news-and-events.html?tab=3";

  

  if ( (cday > 0) && (cmonth > 0) && (cyear > 0))

  {

    window.location = curl + "&month=" + cmonth + "&day=" + cday + "&year=" + cyear;

  }

  return false;

}



jQuery(document).ready(function() {



  jQuery("#root").treeview();

  

  jQuery("#datepicker").datepicker();

  

  jQuery("#duration_txt").focus(function() {

    if (jQuery(this).val() == "enter time (ie) 1 Hour") jQuery(this).val("");

  });

  

  jQuery("#edit-phone").mask("(999) 999-9999? x99999");

  

  jQuery('#when_dt').attr('readonly', 'readonly');

  jQuery('#when_dt').datepicker({

    duration: '',

    showTime: true,

    constrainInput: false,

    stepMinutes: 1

  });



  jQuery(".rotate-link").click(function() {

    var url = jQuery.trim(jQuery(this).attr("title"));

    if (url != "")

    {

      window.open(url);

    }

  });



  jQuery("#custom_pages_form #edit-preview").click(function() {

    var cp_form = jQuery("#custom_pages_form");

    if (cp_form != null && cp_form != 'undefined')

    {

      var cp_action = cp_form.attr("action");

      cp_form.attr("action", "http://www.csi360.com/preview-only.html");

      //cp_form.attr("action", "http://qa.informa-it-solutions.com/csi-new/preview-only.html");

      //cp_form.attr("action", "http://localhost/webbizideas/www.csi360.com/pro/preview-only.html");

      cp_form.attr("target", "_blank");

      jQuery("#edit-submit").click();

      //cp_form.submit();

      cp_form.attr("target", "");

      cp_form.attr("action", cp_action);

    }

    return false;

  });



  jQuery("#news_articles_form #edit-preview").click(function() {

    var cp_form = jQuery("#news_articles_form");

    if (cp_form != null && cp_form != 'undefined')

    {

      var cp_action = cp_form.attr("action");

      cp_form.attr("action", "http://www.csi360.com/preview-news-article.html");

      //cp_form.attr("action", "http://qa.informa-it-solutions.com/csi-new/preview-news-article.html");

      //cp_form.attr("action", "http://localhost/webbizideas/www.csi360.com/pro/preview-news-article.html");

      cp_form.attr("target", "_blank");

      jQuery("#edit-submit").click();

      //cp_form.submit();

      cp_form.attr("target", "");

      cp_form.attr("action", cp_action);

    }

    return false;

  });

  

  jQuery("#events_articles_form #edit-preview").click(function() {

    var cp_form = jQuery("#events_articles_form");

    if (cp_form != null && cp_form != 'undefined')

    {

      var cp_action = cp_form.attr("action");

      cp_form.attr("action", "http://www.csi360.com/preview-event.html");

      //cp_form.attr("action", "http://qa.informa-it-solutions.com/csi-new/preview-event.html");

      //cp_form.attr("action", "http://localhost/webbizideas/www.csi360.com/pro/preview-event.html");

      cp_form.attr("target", "_blank");

      jQuery("#edit-submit").click();

      //cp_form.submit();

      cp_form.attr("target", "");

      cp_form.attr("action", cp_action);

    }

    return false;

  });

  

  jQuery('blockquote').each(function() {

    var bContent = jQuery(this).html();

	jQuery(this).html('<span class="default-text-12"><span class="quote-icon">" </span>'+bContent+'<span class="quote-icon"> "</span></span>');

  });

});