﻿

<!--
var debugging = true; // or true
if (typeof console == "undefined") var console = { log: function() {} };
else if (!debugging || typeof console.log == "undefined") console.log = function() {};
jQuery.fn.extend({
    scrollTo : function(speed, easing) {
        return this.each(function() {
            var targetOffset = $(this).offset().top;
            $('html,body').animate({scrollTop: targetOffset}, speed, easing);
        });
    },
    setDependency: function(dependency) {
        return this.each(function(i) {
            var that = this;            
            $.each(dependency,function(k,v) {                                                            
                // @#$%^&* IE7 ! Hide <option> with CSS works fine on all browsers exept that piece of ***** - dummy 
                $('body').append('<select name="dummy'+i+'" style="display: none !important;" id="dummy'+$(that).attr('id')+'"/>');
                $(v).bind('change.dependency',function() {                               
                    if($(this).val() != 'null') {                        
                        $('select#dummy'+$(that).attr('id')).append($(that).find('option[value != "null"]'));
                        $(that).append($('select#dummy'+$(that).attr('id')).find('option').filter('.'+$(this).find('option:selected').text()));
                        // $(that).find('option[value != "null"]').addClass('opt-hidden').filter('.'+$(this).find('option:selected').text()).removeClass('opt-hidden');
                    } else {                        
                        $(that).append($('select#dummy'+$(that).attr('id')).find('option'));
                        //$(that).find('option').removeClass('opt-hidden');
                    }                    
                    $(that).find('option').removeAttr("selected").filter('[value="null"]').attr("selected","selected");                    
                    if(typeof GmapPage == 'object') GmapPage._sortOptionlist($(that).attr('id'));     
     $(that).customDropdown({ optsScrollable: true});
                });
            });
        });        
    },
    setDefaultValue: function(defValue,options) {          
        // jQuery('.year').setDefaultValue('RRRR');
        var default_options = {defClass:'def',allowNullVal: false}
        options = $.extend({},default_options,options);            
        return this.each(function() {            
            $(this)
                .focus(function() {if($(this).hasClass(options.defClass)) $(this).removeClass(options.defClass).val('')})
                .blur(function() {if($(this).val() == '' && !options.allowNullVal){$(this).val(defValue).addClass(options.defClass)}})
            if($(this).val() == defValue || ($(this).val() == '' && !options.allowNullVal)) $(this).val(defValue).addClass(options.defClass);
        })
    }
});
function pad(number, length) {  
    var str = '' + number;
    while (str.length < length) {str = '0' + str;}
    return str;
}
var JSON = JSON || {}; 
JSON.stringify = JSON.stringify || function (obj) {
 var t = typeof (obj);
 if (t != "object" || obj === null) {
  // simple data type
  if (t == "string") obj = '"'+obj+'"';
  return String(obj);
 }
 else {
  // recurse array or object
  var n, v, json = [], arr = (obj && obj.constructor == Array);
  for (n in obj) {
   v = obj[n]; t = typeof(v);
   if (t == "string") v = '"'+v+'"';
   else if (t == "object" && v !== null) v = JSON.stringify(v);
   json.push((arr ? "" : '"' + n + '":') + String(v));
  }
  return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
 }
};
JSON.parse = JSON.parse || function (str) {
 if (str === "") str = '""';
 eval("var p=" + str + ";");
 return p;
};
//-->

