window.log = function(){
  log.history = log.history || [];  
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});


/* Drop Down Menu Code */
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function() {
  $('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);
});

document.onclick = jsddm_close;
/* END - Drop Down Menu Code */


/**
 * Select Subcategory - A jQuery plugin for grabbing options of a select box using AJAX.
 * Tested in jQuery v1.3.2 or above
 *
 * http://nilambar.com.np
 *
 * Copyright (c) 2010 Nilambar Sharma
 * License: DWYW (Do Whatever You Want)
 * Version: 1.0
 */
/**
 * It is useful when you want to populate select list according to its parent select box's value.
 *
 * For example lets take a HTML markup as follows
 *
 *   <select name="category" id="category" size="1">
 *   <option value="-1">Select</option>
 *		  <option value="1" >Asia</option>
 *		  <option value="2">Europe</option>
 *	</select>
 *	<select name="subcategory" id="subcategory">
 *		  <option>Select</option>
 *	</select>
 *
 * Now include jQuery library along with the selectsubcategory(this) plugin
 *
 * Use the following snippet to initiate select box.
 *   $("#category").selectSubcategory({
			url: 'includes/getsubcategories.php',
			subcategoryid: 'subcategory'
		});
 *
 * Parameters here are:
 *
 * @url: 			url of the serverside file from where we want to get select options
  *		Default is 'getsubcategories.php' in the same directory
 * @subcategoryid:	id of the subcategory 
 *		Default is 'subcategory'
 *
 * JSON is used for sending data.
 *
 * In the server side, For example, PHP code:
 * getsubcategories.php
 * <?php
 *	if(isset($_GET['myid']))
 *	{
 *		$curid=$_GET['myid'];
 *		if($curid=='1')
 *		{
 *			echo '[ { "title": "Nepal", "key": "np" }, { "title": "China", "key": "ch" } ]';
 *		}
 *		else if($curid=='2')
 *		{
 *			echo '[ { "title": "Germany", "key": "gy" }, { "title": "Denmark", "key": "dk" } ]';
 *		}
 *		else
 *		{
 *			echo '[ { "title": "Select", "key": "-1" }]';
 *		}
 *		
 *	}
 *	?>
 *
 *
 *
 */
(function($) {
$.fn.selectSubcategory = function(o) {
    o = $.extend({ url: "getsubcategories.php", subcategoryid:'subcategory'}, o || {});
	var selectorid=this.selector;
    return this.each(function() {
        var me = $(this), noop = function(){};
		me.change(function(){
			//var datatosend = me.val() + '/';
			//alert(datatosend);
			$.ajax({
				   type: "GET",
				   url: o.url + me.val() + '/',
				   //data: datatosend,
				   dataType: "json",
				   success:function(data){
					   $('#'+o.subcategoryid).find('option').remove().end();
					   $.each(data,function(index,val){
							var newopt='<option value="'+val.key+'">'+val.title+'</option>';					
							$('#'+o.subcategoryid).append(newopt);
							});
					}
			});
		});
		
    });
};
})(jQuery);
/* END - Select Subcategory */


/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Philip Myers :: http://virtualipod.tripod.com/bookmark.html */

function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}


/* Clear Text Field function */
function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}




/*jslint browser: true */ /*global jQuery: true */

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

// TODO JsDoc

/**
 * Create a cookie with the given key and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String key The key of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given key.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String key The key of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function (key, value, options) {
    
    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }
        
        value = String(value);
        
        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

