
(function($){
	$.fn.paging = function(options)
	{
	    var settings = {
	        total: 0,
            n:10,
            current: 0,
            onClick: null
        };
	    var form = '<a href="#%url" rel="%url" class="%class">%name</a>';
	    var more = '';
	    var paging = this;
        
        $.extend(settings, options);
        
		return this.each(function()
		{
			if ( options.current>1 ) { 
				tpl = form.replace(/%url/g, options.current);
				tpl = tpl.replace(/%name/g, 'Truoc');
			} else tpl='';
			total_page = options.total/options.n;
			
			if ( options.total-(options.n*total_page)>0 ) total_page++;
			
			jump = 10;
			if ( total_page>1 ) {
				start_page = (options.current-jump>0)?options.current-jump:0;
				end_page = (options.current+jump>total_page)?total_page:options.current+jump;
				for ( i=start_page; i<end_page; i++ ) {
					tem = form.replace(/%url/g, i+1);
					tem = tem.replace(/%name/g, i+1);

					if ( i==options.current ) {
						tem = tem.replace('%class', "current");
					} else tem = tem.replace('%class', "");
					tpl += tem;
				}
			}
			if ( (options.current+5<total_page) ) tpl += more;
			if ( (options.current+1<total_page) ) { 
				tem = form.replace(/%url/g, options.current+2);
				tem = tem.replace(/%name/g, 'Sau');
				tpl += tem;
			}
			$(this).html(tpl);
			$(this).find("a").click(function() {
				options.onClick($(this).attr("rel"));
				return false;
			});
		    return paging;
		});
	}
})(jQuery);

/*
	* Test whether argument elements are parents
	* of the first matched element
	* @return boolean
	* @param objs
	* 	a jQuery selector, selection, element, or array of elements
*/
$.fn.hasParent = function(objs) {
	// ensure that objs is a jQuery array
	objs = $(objs); var found = false;
	$(this[0]).parents().andSelf().each(function() {
		if ($.inArray(this, objs) != -1) {
			found = true;
			return false; // stops the each...
		}
	});
	return found;
}

function getFlashVersion(){
  // ie
  try {
    try {
      // avoid fp6 minor version lookup issues
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
      try { axo.AllowScriptAccess = 'always'; }
      catch(e) { return '6,0,0'; }
    } catch(e) {}
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  // other browsers
  } catch(e) {
    try {
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
      }
    } catch(e) {}
  }
  return '0,0,0';
}
 
var flashVersion = getFlashVersion().split(',').shift();
if(flashVersion < 10){
  //alert("Lower than 10");
}else{
  //alert("10 or higher");
}
