﻿function show(div) {
    if (div.indexOf('#') == 0) {
        $(div).show();
    }
    else {
        $('#' + div).show();
    }
}

function hide(div) {
    if (div.indexOf('#') == 0) {
        $(div).hide();
    }
    else {
        $('#' + div).hide();
    }
}

function showhide(div) {
    if ($('#' + div).is(':visible')) {
        hide(div);
    }
    else {
        show(div);
    }
}

function getcount(div, counttype) {
    $("#" + div).html("<img src='http://fs.datafrenzy.com/images/spinner.gif' width='12px' />");
    $("#" + div).load("http://admin.datafrenzy.com/includes/ajax/counter.aspx", {type: counttype});
}

function slidedown(div) {
    $('#' + div).slideDown('slow');
}

function slideup(div) {
    $('#' + div).slideUp('slow');
}

function openWindow(url, height, width) {
    window.open(url,null,'height=' + height + ',width=' + width + ',scrollbars=yes,resizable=yes'); 
}

function OpenURL(url){ 
    openWindow(url, 600, 750);
}

function isNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   return IsNumber;
}


function scrollTo(name) {  
    $.scrollTo('#' + name, {duration: 1200});
}

function makeelastic(div) {	
    $('#' + div).elastic();
}
    
function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
	    x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}


function getQuery(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

