

/*!
 * jQuery corner plugin: simple corner rounding
 * Examples and documentation at: http://jquery.malsup.com/corner/
 * version 2.06 (16-FEB-2010)
 * Requires jQuery v1.3.2 or later
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Authors: Dave Methvin and Mike Alsup
 */

/**
 *  corner() takes a single string argument:  $('#myDiv').corner("effect corners width")
 *
 *  effect:  name of the effect to apply, such as round, bevel, notch, bite, etc (default is round).
 *  corners: one or more of: top, bottom, tr, tl, br, or bl.  (default is all corners)
 *  width:   width of the effect; in the case of rounded corners this is the radius.
 *           specify this value using the px suffix such as 10px (yes, it must be pixels).
 */
;(function($) {

var style = document.createElement('div').style;
var moz = style['MozBorderRadius'] !== undefined;
var webkit = style['WebkitBorderRadius'] !== undefined;
var radius = style['BorderRadius'] !== undefined;
var mode = document.documentMode || 0;
var noBottomFold = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);

var expr = $.browser.msie && (function() {
    var div = document.createElement('div');
    try { div.style.setExpression('width','0+0'); div.style.removeExpression('width'); }
    catch(e) { return false; }
    return true;
})();

function sz(el, p) {
    return parseInt($.css(el,p))||0;
};
function hex2(s) {
    var s = parseInt(s).toString(16);
    return ( s.length < 2 ) ? '0'+s : s;
};
function gpc(node) {
    for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode ) {
        var v = $.css(node,'backgroundColor');
        if (v == 'rgba(0, 0, 0, 0)')
            continue; // webkit
        if (v.indexOf('rgb') >= 0) {
            var rgb = v.match(/\d+/g);
            return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
        }
        if ( v && v != 'transparent' )
            return v;
    }
    return '#ffffff';
};

function getWidth(fx, i, width) {
    switch(fx) {
    case 'round':  return Math.round(width*(1-Math.cos(Math.asin(i/width))));
    case 'cool':   return Math.round(width*(1+Math.cos(Math.asin(i/width))));
    case 'sharp':  return Math.round(width*(1-Math.cos(Math.acos(i/width))));
    case 'bite':   return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
    case 'slide':  return Math.round(width*(Math.atan2(i,width/i)));
    case 'jut':    return Math.round(width*(Math.atan2(width,(width-i-1))));
    case 'curl':   return Math.round(width*(Math.atan(i)));
    case 'tear':   return Math.round(width*(Math.cos(i)));
    case 'wicked': return Math.round(width*(Math.tan(i)));
    case 'long':   return Math.round(width*(Math.sqrt(i)));
    case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
	case 'dogfold':
    case 'dog':    return (i&1) ? (i+1) : width;
    case 'dog2':   return (i&2) ? (i+1) : width;
    case 'dog3':   return (i&3) ? (i+1) : width;
    case 'fray':   return (i%2)*width;
    case 'notch':  return width;
	case 'bevelfold':
    case 'bevel':  return i+1;
    }
};

$.fn.corner = function(options) {
    // in 1.3+ we can fix mistakes with the ready state
	if (this.length == 0) {
        if (!$.isReady && this.selector) {
            var s = this.selector, c = this.context;
            $(function() {
                $(s,c).corner(options);
            });
        }
        return this;
	}

    return this.each(function(index){
		var $this = $(this);
		// meta values override options
		var o = [$this.attr($.fn.corner.defaults.metaAttr) || '', options || ''].join(' ').toLowerCase();
		var keep = /keep/.test(o);                       // keep borders?
		var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);  // corner color
		var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);  // strip color
		var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
		var re = /round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/;
		var fx = ((o.match(re)||['round'])[0]);
		var fold = /dogfold|bevelfold/.test(o);
		var edges = { T:0, B:1 };
		var opts = {
			TL:  /top|tl|left/.test(o),       TR:  /top|tr|right/.test(o),
			BL:  /bottom|bl|left/.test(o),    BR:  /bottom|br|right/.test(o)
		};
		if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
			opts = { TL:1, TR:1, BL:1, BR:1 };

		// support native rounding
		if ($.fn.corner.defaults.useNative && fx == 'round' && (radius || moz || webkit) && !cc && !sc) {
			if (opts.TL)
				$this.css(radius ? 'border-top-left-radius' : moz ? '-moz-border-radius-topleft' : '-webkit-border-top-left-radius', width + 'px');
			if (opts.TR)
				$this.css(radius ? 'border-top-right-radius' : moz ? '-moz-border-radius-topright' : '-webkit-border-top-right-radius', width + 'px');
			if (opts.BL)
				$this.css(radius ? 'border-bottom-left-radius' : moz ? '-moz-border-radius-bottomleft' : '-webkit-border-bottom-left-radius', width + 'px');
			if (opts.BR)
				$this.css(radius ? 'border-bottom-right-radius' : moz ? '-moz-border-radius-bottomright' : '-webkit-border-bottom-right-radius', width + 'px');
			return;
		}

		var strip = document.createElement('div');
		$(strip).css({
			overflow: 'hidden',
			height: '1px',
			minHeight: '1px',
			fontSize: '1px',
			backgroundColor: sc || 'transparent',
			borderStyle: 'solid'
		});

        var pad = {
            T: parseInt($.css(this,'paddingTop'))||0,     R: parseInt($.css(this,'paddingRight'))||0,
            B: parseInt($.css(this,'paddingBottom'))||0,  L: parseInt($.css(this,'paddingLeft'))||0
        };

        if (typeof this.style.zoom != undefined) this.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) this.style.border = 'none';
        strip.style.borderColor = cc || gpc(this.parentNode);
        var cssHeight = $.curCSS(this, 'height');

        for (var j in edges) {
            var bot = edges[j];
            // only add stips if needed
            if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
                strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
                var d = document.createElement('div');
                $(d).addClass('jquery-corner');
                var ds = d.style;

                bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

                if (bot && cssHeight != 'auto') {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.bottom = ds.left = ds.padding = ds.margin = '0';
                    if (expr)
                        ds.setExpression('width', 'this.parentNode.offsetWidth');
                    else
                        ds.width = '100%';
                }
                else if (!bot && $.browser.msie) {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';

                    // fix ie6 problem when blocked element has a border width
                    if (expr) {
                        var bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
                        ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"');
                    }
                    else
                        ds.width = '100%';
                }
                else {
                	ds.position = 'relative';
                    ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' :
                                        (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';
                }

                for (var i=0; i < width; i++) {
                    var w = Math.max(0,getWidth(fx,i, width));
                    var e = strip.cloneNode(false);
                    e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                    bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
                }

				if (fold && $.support.boxModel) {
					if (bot && noBottomFold) continue;
					for (var c in opts) {
						if (!opts[c]) continue;
						if (bot && (c == 'TL' || c == 'TR')) continue;
						if (!bot && (c == 'BL' || c == 'BR')) continue;

						var common = { position: 'absolute', border: 'none', margin: 0, padding: 0, overflow: 'hidden', backgroundColor: strip.style.borderColor };
						var $horz = $('<div/>').css(common).css({ width: width + 'px', height: '1px' });
						switch(c) {
						case 'TL': $horz.css({ bottom: 0, left: 0 }); break;
						case 'TR': $horz.css({ bottom: 0, right: 0 }); break;
						case 'BL': $horz.css({ top: 0, left: 0 }); break;
						case 'BR': $horz.css({ top: 0, right: 0 }); break;
						}
						d.appendChild($horz[0]);

						var $vert = $('<div/>').css(common).css({ top: 0, bottom: 0, width: '1px', height: width + 'px' });
						switch(c) {
						case 'TL': $vert.css({ left: width }); break;
						case 'TR': $vert.css({ right: width }); break;
						case 'BL': $vert.css({ left: width }); break;
						case 'BR': $vert.css({ right: width }); break;
						}
						d.appendChild($vert[0]);
					}
				}
            }
        }
    });
};

$.fn.uncorner = function() {
	if (radius || moz || webkit)
		this.css(radius ? 'border-radius' : moz ? '-moz-border-radius' : '-webkit-border-radius', 0);
	$('div.jquery-corner', this).remove();
	return this;
};

// expose options
$.fn.corner.defaults = {
	useNative: true, // true if plugin should attempt to use native browser support for border radius rounding
	metaAttr:  'data-corner' // name of meta attribute to use for options
};

})(jQuery);





		function isEmpty(s) { return ((s == null) || (s.length == 0)); }
		var whitespace = " \t\n\r";
		function isWhitespace (s) {
		  var i;
		  if (isEmpty(s)) return true;
		  for (i = 0; i < s.length; i++) {
		    var c = s.charAt(i);
		    if (whitespace.indexOf(c) == -1) return false;
		  }
		  return true;
		}
		function doesExist (s) { return ( ! isEmpty(s) && ! isWhitespace (s) ); }
		var iEmail = "You must use a valid email address (like you@there.com). Please reenter it now.!";
		function isEmail (s) {
		  if (isEmpty(s)) return ( true );
		  if (isWhitespace(s)) return ( false );
		  var i = 1;
		  var sLength = s.length;
		  while ((i < sLength) && (s.charAt(i) != "@")) { i++; }
		  if ((i >= sLength) || (s.charAt(i) != "@")) return ( false );
		  else i += 2;
		  while ((i < sLength) && (s.charAt(i) != ".")) { i++; }
		  if ((i >= sLength - 1) || (s.charAt(i) != ".")) return ( false );
		  else return ( true );
		}

		/*function validateAndSubmit() {
		  var form = document.register_members;
		  var ok = validateForm ();
		  if ( ok ) form.submit ();
		  return ( ok );
		}*/



		var interval = 0.5; // delay between rotating images (in seconds)
		var random_display = 1; // 0 = no, 1 = yes
		interval *= 1000;
		var image_index = 0;
		var number_of_image;
		var cleared = false;
		var image_list = new Array();
		var timer;
		/** Rotate images **/
		function rotateImages(imgid,im1,im2,im3,im4,im5)
		{
			image_index=0;
			image_list = new Array();
			imgObj = imgid;

			if(im1!='')
			{
				image_list[image_index++] = new imageItem(im1);
			}

			if(im2!='')
			{
				image_list[image_index++] = new imageItem(im2);
			}
			if(im3!='')
			{
				image_list[image_index++] = new imageItem(im3);
			}
			if(im4!='')
			{
				image_list[image_index++] = new imageItem(im4);
			}
			if(im5!='')
			{
				image_list[image_index++] = new imageItem(im5);
			}

			number_of_image = image_list.length;

			rotateImage(imgObj);
		}

		function imageItem(image_location)
		{
			this.image_item = new Image();
			this.image_item.src = image_location;
		}

		function get_ImageItemLocation(imageObj)
		{
			return(imageObj.image_item.src)
		}
		function generate(x, y)
		{
			var range = y - x + 1;
			return Math.floor(Math.random() * range) + x;
		}

		function getNextImage()
		{
			if (random_display) {
				image_index = generate(0, number_of_image-1);
			}
			else {
				image_index = (image_index+1) % number_of_image;
			}

			var new_image = get_ImageItemLocation(image_list[image_index]);

			return(new_image);
		}

		function rotateImage(place)
		{
			var new_image = getNextImage();
			$(place).src = new_image;
			var recur_call = "rotateImage('"+place+"')";
			timer = setTimeout(recur_call, interval);
		}

		function clearTimer()
		{
			clearTimeout(timer);
		}




function clearTextBox(field,txt)
{
	if(field.value==txt)
	{
		field.value='';
	}
}

function changeFieldType(obj)
{
	$('#tftpwdfield').html('<input name="pword" type="password" id="email_pwd" value="" size="20"/>');
	$('#email_pwd').focus();
}




function ajaxLogin(formobj,container)
{
	$.ajax({
		type:'POST',
		url:'/index.php',
		data:'nolayout=true&page=40&ACTION=member_login.php&trigger=ajaxlogin&username='+ formobj.username.value +'&pword='+ formobj.pword.value,
		success:function(data){
			if(data.indexOf('loggedIN')!=-1)
			{
				$('#error_block').toggle('slow');

				//fetch Billing/Shipping Information Form
				fillBillingInfo('address_box');

				$('#login_box').toggle('slow');

			}
			else
			{
				$('#'+container).html(data);
				$('#'+container).show('slow');
			}
		}
	});
}


	function showLoader (responseId) {
		$(responseId).innerHTML = "<img src='/images/loader.gif' align='middle' />";
	}
	//BATTERY SEARCH

	function searchByCat(responseId,formName)
	{
		var tmphtml;
		var newajax = new Ajax.Updater(
					'battery_search_results',
					'/index.php',
					{	method: 'post',
						parameters:Form.serialize(formName),
						evalscripts:true,
						onLoading: function(request) {
							tmphtml=$(responseId).innerHTML;
							$(responseId).innerHTML = "<img src='/images/cr_loader.gif' />";//"<img src='/images/search_loader1.gif' />";
						},
						onComplete:function(request){
							$(responseId).innerHTML=tmphtml;
						},
						onFailure: function(request) {
							reportError(request)
						}
					}
				);
	}


	function searchByTxt(responseId,formName)
	{
		var tmphtml;
		var newajax = new Ajax.Updater(
					'battery_search_results',
					'/index.php',
					{	method: 'post',
						parameters:Form.serialize(formName),
						evalscripts:true,
						onLoading: function(request) {
							tmphtml=$(responseId).innerHTML;
							$(responseId).innerHTML = "<img src='/images/cr_loader.gif' />";
						},
						onComplete:function(request){
							$(responseId).innerHTML=tmphtml;
						},
						onFailure: function(request) {
							reportError(request)
						}
					}
				);
	}


	//fetch brands who make this device
	function loadBrands(formName,responseId)
	{
		var newajax = new Ajax.Updater(
					'brands_holder',
					'/index.php',
					{	method: 'post',
						parameters:Form.serialize(formName)+'&loadbrand=1',
						evalscripts:true,
						onLoading: function(request) {
							$(responseId).innerHTML = "<img src='/images/cr_loader.gif' />";
						},
						onComplete:function(request){
						},
						onFailure: function(request) {
							reportError(request)
						}
					}
				);
	}


	function loadModels(formName,responseId)
	{
		var newajax = new Ajax.Updater(
					'model_holder',
					'/index.php',
					{	method: 'post',
						parameters:Form.serialize(formName)+'&loadmodels=1',
						evalscripts:true,
						onLoading: function(request) {
							$(responseId).innerHTML = "<img src='/images/cr_loader.gif' />";
						},
						onComplete:function(request){
						},
						onFailure: function(request) {
							reportError(request)
						}
					}
				);

		//load batteries also! having no Model
		var newajax = new Ajax.Updater(
					'battery_search_results',
					'/index.php',
					{	method: 'post',
						parameters:Form.serialize(formName),
						evalscripts:true,
						onLoading: function(request) {
							//$(responseId).innerHTML = "<img src='/images/cr_loader.gif' />";
						},
						onComplete:function(request){
						},
						onFailure: function(request) {
							reportError(request)
						}
					}
				);

	}


	function loadBattery(formName,responseId)
	{
		var tmphtml;
			var newajax = new Ajax.Updater(
					'battery_search_results',
					'/index.php',
					{	method: 'post',
						parameters:Form.serialize(formName)+'&loadbymodels=1',
						evalscripts:true,
						onLoading: function(request) {
							//$('battery_search_results').innerHTML = "<img src='/images/cr_loader.gif' />";
						},
						onComplete:function(request){

						},
						onFailure: function(request) {
							reportError(request)
						}
					}
				);


	}


	function pop_window(url,h,w)
	{
		//var zoom_window = dhtmlwindow.open("zoom", "ajax", url, "Pop-Up", "width="+ w +"px,height="+ h +"px,resize=1,scrolling=1,center=1");
		newwin = window.open(url,"add_content","location=no,scrollbars=no,copyhistory=no,toolbar=no,status=yes,height="+h+",width="+w+",left=185,top=100")
	}



window.onerror=function(desc,page,line,chr){
/* alert('JavaScript error occurred! \n'
  +'\nError description: \t'+desc
  +'\nPage address:      \t'+page
  +'\nLine number:       \t'+line
 );*/
}

$(function(){
 $('a').focus(function(){this.blur();});
 SI.Files.stylizeAll();
 slider.init();
 //mc.init();

 $('input.text-default').each(function(){
  $(this).attr('default',$(this).val());
 }).focus(function(){
  if($(this).val()==$(this).attr('default'))
   $(this).val('');
 }).blur(function(){
  if($(this).val()=='')
   $(this).val($(this).attr('default'));
 });

 $('input.text,textarea.text').focus(function(){
  $(this).addClass('textfocus');
 }).blur(function(){
  $(this).removeClass('textfocus');
 });

 var popopenobj=0,popopenaobj=null;
 $('a.popup').click(function(){
  var pid=$(this).attr('rel').split('|')[0],_os=parseInt($(this).attr('rel').split('|')[1]);
  var pobj=$('#'+pid);
  if(!pobj.length)
   return false;
  if(typeof popopenobj=='object' && popopenobj.attr('id')!=pid){
   popopenobj.hide(50);
   $(popopenaobj).parent().removeClass(popopenobj.attr('id').split('-')[1]+'-open');
   popopenobj=null;
  }
  return false;
 });
 $('p.images img').click(function(){
  var newbg=$(this).attr('src').split('bg/bg')[1].split('-thumb')[0];
  $(document.body).css('backgroundImage','url('+_siteRoot+'images/bg/bg'+newbg+'.jpg)');

  $(this).parent().find('img').removeClass('on');
  $(this).addClass('on');
  return false;
 });
 $(window).load(function(){
  //$.each(css_ims,function(){(new Image()).src=_siteRoot+'css/images/'+this;});
  /*$.each(css_cims,function(){
   var css_im=this;
   $.each(['blue','purple','pink','red','grey','green','yellow','orange'],function(){
    (new Image()).src=_siteRoot+'css/'+this+'/'+css_im;
   });
  });*/
 });
 $('div.sc-large div.img:has(div.tml)').each(function(){
  $('div.tml',this).hide();
  $(this).append('<a href="#" class="tml_open">&nbsp;</a>').find('a').css({
   left:parseInt($(this).offset().left)+864,top:parseInt($(this).offset().top)+1
  }).click(function(){
   $(this).siblings('div.tml').slideToggle();
   return false;
  }).focus(function(){this.blur();});
 });
});
var slider={
 num:-1,
 cur:0,
 cr:[],
 al:null,
 at:10*1000,
 ar:true,
 init:function(){
  if(!slider.data || !slider.data.length)
   return false;

  var d=slider.data;
  slider.num=d.length;
  var pos=Math.floor(Math.random()*1);//slider.num);
  for(var i=0;i<slider.num;i++){
   $('#'+d[i].id).css({left:((i-pos)*1000)});
   $('#slide-nav').append('<a id="slide-link-'+i+'" href="#" onclick="slider.slide('+i+');return false;" onfocus="this.blur();">'+(i+1)+'</a>');
  }

  $('img,div#slide-controls',$('div#slide-holder')).fadeIn();
  slider.text(d[pos]);
  slider.on(pos);
  slider.cur=pos;
  window.setTimeout('slider.auto();',slider.at);
 },
 auto:function(){
  if(!slider.ar)
   return false;

  var next=slider.cur+1;
  if(next>=slider.num) next=0;
  slider.slide(next);
 },
 slide:function(pos){
  if(pos<0 || pos>=slider.num || pos==slider.cur)
   return;

  window.clearTimeout(slider.al);
  slider.al=window.setTimeout('slider.auto();',slider.at);

  var d=slider.data;
  for(var i=0;i<slider.num;i++)
   $('#'+d[i].id).stop().animate({left:((i-pos)*1000)},1000,'swing');

  slider.on(pos);
  slider.text(d[pos]);
  slider.cur=pos;
 },
 on:function(pos){
  $('#slide-nav a').removeClass('on');
  $('#slide-nav a#slide-link-'+pos).addClass('on');
 },
 text:function(di){
  slider.cr['a']=di.client;
  slider.cr['b']=di.desc;
  slider.ticker('#slide-client span',di.client,0,'a');
  slider.ticker('#slide-desc',di.desc,0,'b');
 },
 ticker:function(el,text,pos,unique){
  if(slider.cr[unique]!=text)
   return false;

  ctext=text.substring(0,pos)+(pos%2?'-':'_');
  $(el).html(ctext);

  if(pos==text.length)
   $(el).html(text);
  else
   window.setTimeout('slider.ticker("'+el+'","'+text+'",'+(pos+1)+',"'+unique+'");',30);
 }
};
// STYLING FILE INPUTS 1.0 | Shaun Inman <http://www.shauninman.com/> | 2007-09-07
if(!window.SI){var SI={};};
SI.Files={
 htmlClass:'SI-FILES-STYLIZED',
 fileClass:'file',
 wrapClass:'cabinet',

 fini:false,
 able:false,
 init:function(){
  this.fini=true;
 },
 stylize:function(elem){
  if(!this.fini){this.init();};
  if(!this.able){return;};

  elem.parentNode.file=elem;
  elem.parentNode.onmousemove=function(e){
   if(typeof e=='undefined') e=window.event;
   if(typeof e.pageY=='undefined' &&  typeof e.clientX=='number' && document.documentElement){
    e.pageX=e.clientX+document.documentElement.scrollLeft;
    e.pageY=e.clientY+document.documentElement.scrollTop;
   };
   var ox=oy=0;
   var elem=this;
   if(elem.offsetParent){
    ox=elem.offsetLeft;
    oy=elem.offsetTop;
    while(elem=elem.offsetParent){
     ox+=elem.offsetLeft;
     oy+=elem.offsetTop;
    };
   };
  };
 },
 stylizeAll:function(){
  if(!this.fini){this.init();};
  if(!this.able){return;};
 }
};

/*** Menu ***
 *
 * TODO: Make this handle an arbitary level of menus.
 *
 */

var menuActive=0;
Menu =function(){
	this.init=function()
	{
		//$('ul.nav a').each(this.setupEvents);
		$('ul.prodnav a').each(function(i){
			this.hoverElement = '#menu_'+ i +'_hover';//document.getElement('#menu_'+ item +'_hover');
			if(!$(this.hoverElement).length>0) {
				return;
			}
			$(this).bind('mouseover', function(e){

				var position = $('#myslidemenu').position();

				var currentposition = $('#menu_'+(i-1)).position();

				$(this.hoverElement).css({display:'block',left:currentposition.left,top:currentposition.top+30});
				$(this).addClass('hover1');
				var hoverBg = document.getElementById("hoverBackground");
				if(hoverBg) {
					hoverBg.style.display="block";
					hoverBg.style.left = currentposition.left;
					hoverBg.style.top =  currentposition.top+30;
				}

				menuActive = this;

			});
			$(this).bind('mouseout', function(e){
				$(this.hoverElement).css({display:'none'});
				$(menuActive).removeClass('hover1');
					var hoverBg = document.getElementById("hoverBackground");
					if(hoverBg) {
						hoverBg.style.display="none";
					}
			});

			$(this.hoverElement).bind('mouseover', function(e){

				$(this).css({display:'block'});
				$(this).addClass('hover');
				$(menuActive).addClass('hover1');

				var hoverBg = document.getElementById("hoverBackground");
				if(hoverBg) {
					hoverBg.style.display="block";
				}
			});
			$(this.hoverElement).bind('mouseout', function(e){

				$(this).css({display:'none'});
				$(this).removeClass('hover');

				$(menuActive).removeClass('hover1');

				var hoverBg = document.getElementById("hoverBackground");
				if(hoverBg) {
						hoverBg.style.display="none";
				}
			});

		});
	}
}


$(document).ready(docReady);

//FUNCTIONS
function docReady() {

	//var menu = new Menu();
	//menu.init();
}

/*********************
//* jQuery Multi Level CSS Menu #2- By Dynamic Drive: http://www.dynamicdrive.com/
//* Last update: Nov 7th, 08': Limit # of queued animations to minmize animation stuttering
//* Menu avaiable at DD CSS Library: http://www.dynamicdrive.com/style/
*********************/

//Specify full URL to down and right arrow images (23 is padding-right to add to top level LIs with drop downs):
var arrowimages={down:['downarrowclass', '', 13], right:['rightarrowclass', '']}

var jqueryslidemenu={

animateduration: {over: 200, out: 100}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid, arrowsvar){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			$subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})
			$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: arrowsvar.down[2]} : {}).append(
				'<span src="'+ (this.istopheader? arrowsvar.down[1] : arrowsvar.right[1])
				+'" class="' + (this.istopheader? arrowsvar.down[0] : arrowsvar.right[0])
				+ '"  />'
			)
			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					this._offsets={left:$(this).offset().left, top:$(this).offset().top}
					var menuleft=this.istopheader? 0 : this._dimensions.w
					menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						$targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu.animateduration.over)
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(jqueryslidemenu.animateduration.out)
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}

//build menu with ID="myslidemenu" on page:
jqueryslidemenu.buildmenu("myslidemenu", arrowimages)

/*
 * jQuery Cycle Plugin
 * Examples and documentation at: http://malsup.com/jquery/cycle/
 * Copyright (c) 2007-2008 M. Alsup
 * Version: 2.34 (26-JAN-2009)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
;(function(F){var A="2.34";if(F.support==undefined){F.support={opacity:!(F.browser.msie&&/MSIE 6.0/.test(navigator.userAgent))}}function C(){if(window.console&&window.console.log){window.console.log("[cycle] "+Array.prototype.join.call(arguments,""))}}F.fn.cycle=function(I){if(this.length==0){C("terminating; zero elements found by selector"+(F.isReady?"":" (DOM not ready)"));return this}var J=arguments[1];return this.each(function(){if(this.cycleStop==undefined){this.cycleStop=0}if(I===undefined||I===null){I={}}if(I.constructor==String){switch(I){case"stop":this.cycleStop++;if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;F(this).removeData("cycle.opts");return ;case"pause":this.cyclePause=1;return ;case"resume":this.cyclePause=0;if(J===true){I=F(this).data("cycle.opts");if(!I){C("options not found, can not resume");return }if(this.cycleTimeout){clearTimeout(this.cycleTimeout);this.cycleTimeout=0}D(I.elements,I,1,1)}return ;default:I={fx:I}}}else{if(I.constructor==Number){var R=I;I=F(this).data("cycle.opts");if(!I){C("options not found, can not advance slide");return }if(R<0||R>=I.elements.length){C("invalid slide index: "+R);return }I.nextSlide=R;if(this.cycleTimeout){clearTimeout(this.cycleTimeout);this.cycleTimeout=0}D(I.elements,I,1,R>=I.currSlide);return }}if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var W=F(this);var S=I.slideExpr?F(I.slideExpr,this):W.children();var N=S.get();if(N.length<2){C("terminating; too few slides: "+N.length);return }var K=F.extend({},F.fn.cycle.defaults,I||{},F.metadata?W.metadata():F.meta?W.data():{});if(K.autostop){K.countdown=K.autostopCount||N.length}W.data("cycle.opts",K);K.container=this;K.stopCount=this.cycleStop;K.elements=N;K.before=K.before?[K.before]:[];K.after=K.after?[K.after]:[];K.after.unshift(function(){K.busy=0});if(K.continuous){K.after.push(function(){D(N,K,0,!K.rev)})}if(!F.support.opacity&&K.cleartype&&!K.cleartypeNoBg){B(S)}var Y=this.className;K.width=parseInt((Y.match(/w:(\d+)/)||[])[1])||K.width;K.height=parseInt((Y.match(/h:(\d+)/)||[])[1])||K.height;K.timeout=parseInt((Y.match(/t:(\d+)/)||[])[1])||K.timeout;if(W.css("position")=="static"){W.css("position","relative")}if(K.width){W.width(K.width)}if(K.height&&K.height!="auto"){W.height(K.height)}if(K.startingSlide){K.startingSlide=parseInt(K.startingSlide)}if(K.random){K.randomMap=[];for(var O=0;O<N.length;O++){K.randomMap.push(O)}K.randomMap.sort(function(c,Z){return Math.random()-0.5});K.randomIndex=0;K.startingSlide=K.randomMap[0]}else{if(K.startingSlide>=N.length){K.startingSlide=0}}var Q=K.startingSlide||0;S.css({position:"absolute",top:0,left:0}).hide().each(function(Z){var a=Q?Z>=Q?N.length-(Z-Q):Q-Z:N.length-Z;F(this).css("z-index",a)});F(N[Q]).css("opacity",1).show();if(F.browser.msie){N[Q].style.removeAttribute("filter")}if(K.fit&&K.width){S.width(K.width)}if(K.fit&&K.height&&K.height!="auto"){S.height(K.height)}if(K.containerResize){var T=0,M=0;for(var O=0;O<N.length;O++){var L=F(N[O]),V=L.outerWidth(),P=L.outerHeight();T=V>T?V:T;M=P>M?P:M}W.css({width:T+"px",height:M+"px"})}if(K.pause){W.hover(function(){this.cyclePause++},function(){this.cyclePause--})}var X=F.fn.cycle.transitions[K.fx];if(F.isFunction(X)){X(W,S,K)}else{if(K.fx!="custom"){C("unknown transition: "+K.fx)}}S.each(function(){var Z=F(this);this.cycleH=(K.fit&&K.height)?K.height:Z.height();this.cycleW=(K.fit&&K.width)?K.width:Z.width()});K.cssBefore=K.cssBefore||{};K.animIn=K.animIn||{};K.animOut=K.animOut||{};S.not(":eq("+Q+")").css(K.cssBefore);if(K.cssFirst){F(S[Q]).css(K.cssFirst)}if(K.timeout){K.timeout=parseInt(K.timeout);if(K.speed.constructor==String){K.speed=F.fx.speeds[K.speed]||parseInt(K.speed)}if(!K.sync){K.speed=K.speed/2}while((K.timeout-K.speed)<250){K.timeout+=K.speed}}if(K.easing){K.easeIn=K.easeOut=K.easing}if(!K.speedIn){K.speedIn=K.speed}if(!K.speedOut){K.speedOut=K.speed}K.slideCount=N.length;K.currSlide=Q;if(K.random){K.nextSlide=K.currSlide;if(++K.randomIndex==N.length){K.randomIndex=0}K.nextSlide=K.randomMap[K.randomIndex]}else{K.nextSlide=K.startingSlide>=(N.length-1)?0:K.startingSlide+1}var U=S[Q];if(K.before.length){K.before[0].apply(U,[U,U,K,true])}if(K.after.length>1){K.after[1].apply(U,[U,U,K,true])}if(K.click&&!K.next){K.next=K.click}if(K.next){F(K.next).bind("click",function(){return E(N,K,K.rev?-1:1)})}if(K.prev){F(K.prev).bind("click",function(){return E(N,K,K.rev?1:-1)})}if(K.pager){H(N,K)}K.addSlide=function(a,b){var Z=F(a),c=Z[0];if(!K.autostopCount){K.countdown++}N[b?"unshift":"push"](c);if(K.els){K.els[b?"unshift":"push"](c)}K.slideCount=N.length;Z.css("position","absolute");Z[b?"prependTo":"appendTo"](W);if(b){K.currSlide++;K.nextSlide++}if(!F.support.opacity&&K.cleartype&&!K.cleartypeNoBg){B(Z)}if(K.fit&&K.width){Z.width(K.width)}if(K.fit&&K.height&&K.height!="auto"){S.height(K.height)}c.cycleH=(K.fit&&K.height)?K.height:Z.height();c.cycleW=(K.fit&&K.width)?K.width:Z.width();Z.css(K.cssBefore);if(K.pager){F.fn.cycle.createPagerAnchor(N.length-1,c,F(K.pager),N,K)}if(typeof K.onAddSlide=="function"){K.onAddSlide(Z)}};if(K.timeout||K.continuous){this.cycleTimeout=setTimeout(function(){D(N,K,0,!K.rev)},K.continuous?10:K.timeout+(K.delay||0))}})};function D(N,I,M,O){if(I.busy){return }var L=I.container,Q=N[I.currSlide],P=N[I.nextSlide];if(L.cycleStop!=I.stopCount||L.cycleTimeout===0&&!M){return }if(!M&&!L.cyclePause&&((I.autostop&&(--I.countdown<=0))||(I.nowrap&&!I.random&&I.nextSlide<I.currSlide))){if(I.end){I.end(I)}return }if(M||!L.cyclePause){if(I.before.length){F.each(I.before,function(R,S){if(L.cycleStop!=I.stopCount){return }S.apply(P,[Q,P,I,O])})}var J=function(){if(F.browser.msie&&I.cleartype){this.style.removeAttribute("filter")}F.each(I.after,function(R,S){if(L.cycleStop!=I.stopCount){return }S.apply(P,[Q,P,I,O])})};if(I.nextSlide!=I.currSlide){I.busy=1;if(I.fxFn){I.fxFn(Q,P,I,J,O)}else{if(F.isFunction(F.fn.cycle[I.fx])){F.fn.cycle[I.fx](Q,P,I,J)}else{F.fn.cycle.custom(Q,P,I,J,M&&I.fastOnEvent)}}}if(I.random){I.currSlide=I.nextSlide;if(++I.randomIndex==N.length){I.randomIndex=0}I.nextSlide=I.randomMap[I.randomIndex]}else{var K=(I.nextSlide+1)==N.length;I.nextSlide=K?0:I.nextSlide+1;I.currSlide=K?N.length-1:I.nextSlide-1}if(I.pager){F.fn.cycle.updateActivePagerLink(I.pager,I.currSlide)}}if(I.timeout&&!I.continuous){L.cycleTimeout=setTimeout(function(){D(N,I,0,!I.rev)},G(Q,P,I,O))}else{if(I.continuous&&L.cyclePause){L.cycleTimeout=setTimeout(function(){D(N,I,0,!I.rev)},10)}}}F.fn.cycle.updateActivePagerLink=function(I,J){F(I).find("a").removeClass("activeSlide").filter("a:eq("+J+")").addClass("activeSlide")};function G(M,K,L,J){if(L.timeoutFn){var I=L.timeoutFn(M,K,L,J);if(I!==false){return I}}return L.timeout}function E(I,J,M){var L=J.container,K=L.cycleTimeout;if(K){clearTimeout(K);L.cycleTimeout=0}if(J.random&&M<0){J.randomIndex--;if(--J.randomIndex==-2){J.randomIndex=I.length-2}else{if(J.randomIndex==-1){J.randomIndex=I.length-1}}J.nextSlide=J.randomMap[J.randomIndex]}else{if(J.random){if(++J.randomIndex==I.length){J.randomIndex=0}J.nextSlide=J.randomMap[J.randomIndex]}else{J.nextSlide=J.currSlide+M;if(J.nextSlide<0){if(J.nowrap){return false}J.nextSlide=I.length-1}else{if(J.nextSlide>=I.length){if(J.nowrap){return false}J.nextSlide=0}}}}if(J.prevNextClick&&typeof J.prevNextClick=="function"){J.prevNextClick(M>0,J.nextSlide,I[J.nextSlide])}D(I,J,1,M>=0);return false}function H(J,K){var I=F(K.pager);F.each(J,function(L,M){F.fn.cycle.createPagerAnchor(L,M,I,J,K)});F.fn.cycle.updateActivePagerLink(K.pager,K.startingSlide)}F.fn.cycle.createPagerAnchor=function(L,M,J,K,N){var I=(typeof N.pagerAnchorBuilder=="function")?N.pagerAnchorBuilder(L,M):'<a href="#">'+(L+1)+"</a>";if(!I){return }var O=F(I);if(O.parents("body").length==0){O.appendTo(J)}O.bind(N.pagerEvent,function(){N.nextSlide=L;var Q=N.container,P=Q.cycleTimeout;if(P){clearTimeout(P);Q.cycleTimeout=0}if(typeof N.pagerClick=="function"){N.pagerClick(N.nextSlide,K[N.nextSlide])}D(K,N,1,N.currSlide<L);return false});if(N.pauseOnPagerHover){O.hover(function(){N.container.cyclePause++},function(){N.container.cyclePause--})}};function B(K){function J(L){var L=parseInt(L).toString(16);return L.length<2?"0"+L:L}function I(N){for(;N&&N.nodeName.toLowerCase()!="html";N=N.parentNode){var L=F.css(N,"background-color");if(L.indexOf("rgb")>=0){var M=L.match(/\d+/g);return"#"+J(M[0])+J(M[1])+J(M[2])}if(L&&L!="transparent"){return L}}return"#ffffff"}K.each(function(){F(this).css("background-color",I(this))})}F.fn.cycle.custom=function(T,N,I,K,J){var S=F(T),O=F(N);O.css(I.cssBefore);var L=J?1:I.speedIn;var R=J?1:I.speedOut;var M=J?null:I.easeIn;var Q=J?null:I.easeOut;var P=function(){O.animate(I.animIn,L,M,K)};S.animate(I.animOut,R,Q,function(){if(I.cssAfter){S.css(I.cssAfter)}if(!I.sync){P()}});if(I.sync){P()}};F.fn.cycle.transitions={fade:function(J,K,I){K.not(":eq("+I.startingSlide+")").css("opacity",0);I.before.push(function(){F(this).show()});I.animIn={opacity:1};I.animOut={opacity:0};I.cssBefore={opacity:0};I.cssAfter={display:"none"};I.onAddSlide=function(L){L.hide()}}};F.fn.cycle.ver=function(){return A};F.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,prevNextClick:null,pager:null,pagerClick:null,pagerEvent:"click",pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",startingSlide:0,sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:0,nowrap:0,fastOnEvent:0}})(jQuery);


/**
** CART RELATED FUNCTIONS
**/
var Cart = {
	remove_Item: function(productId,container)
	{
		var ajax = new Ajax('/index.php',
						{
							method:'post',
							evalScripts:true,
							data:'page=39&ACTION=view_cart.php&trigger=Remove&product_id[]='+ productId,
							update:container,
							onRequest:function(request)
							{
								$(container).innerHTML = 'Updating cart please standby...';
							}
						}
		).request();
	},
	updateItem:function(qty,productId,container)
	{
		var ajax = new Ajax('/index.php',
						{
							method:'post',
							evalScripts:true,
							data:'page=39&ACTION=view_cart.php&trigger=updateQty&qty='+ qty.value +'&product_id[]='+ productId,
							update:container,
							onRequest:function(request)
							{
								$(container).innerHTML = 'Updating cart please standby...';
							}

						}
		).request();

	},
	removeItem:function(productId,sizeId,colorId,patternId){
		$('#product_id').val(productId);
		document.view_cart.sizeId.value=sizeId;
		document.view_cart.colorId.value=colorId;
		document.view_cart.patternId.value=patternId;
		document.view_cart.trigger.value='Remove';
		document.view_cart.submit();
	},
	addItem:function(productId)
	{

		$("#productform").submit();
		/*
		sizeId = 0;
		colorId=0;
		patternId=0;
			$.ajax({
				url:'/index.php',
				type:'post',
				data:'page=39&ACTION=view_cart.php&trigger=addItem&qty='+ qty +'&product_id[]='+ productId +'&sizeId='+sizeId +'&colorId='+ colorId +'&patternId='+patternId,
				success:function(req)
				{
					//$("#add_to_cart_message").show('slow');
					//$("#add_to_cart_message").html("<h1>Item added to cart</h1> | <a href=\"/index/use_lang/EN/page/39.html\">View Cart to Checkout</a>");
				}
				/*onRequest:function(request)
				{
					$('cart_num_items').innerHTML = "<img src='/themes/tbz/images/loader_strip.gif' />";//'Updating cart please standby...';
					element = $('basket_body_id');
					if (element.className.indexOf("close") == -1)
					{
						element.className += " close";
					}
				}*

		});*/

	},
	addBundle:function(qty,bundleId,container)
	{
		var ajax = new Ajax('/index.php',
						{
							method:'post',
							evalScripts:true,
							data:'page=39&ACTION=view_cart.php&trigger=addBundle&qty='+ qty.value +'&bundle_id[]='+ bundleId,
							update:container,
							onSuccess:function(req)
							{
								element = $('basket_body_id');
								accordion.display(element);
								setTimeout('hideBox()',3000);
							},
							onRequest:function(request)
							{
								$('cart_num_items').innerHTML = "<img src='/themes/tbz/images/loader_strip.gif' />";//'Updating cart please standby...';
								element = $('basket_body_id');
								if (element.className.indexOf("close") == -1)
								{
									element.className += " close";
								}
							}

						}
		).request();

	},
	remove_Bundle: function(bundleId,container)
	{
		var ajax = new Ajax('/index.php',
						{
							method:'post',
							evalScripts:true,
							data:'page=39&ACTION=view_cart.php&trigger=Remove&bundle_id[]='+ bundleId,
							update:container,
							onRequest:function(request)
							{
								$(container).innerHTML = 'Updating cart please standby...';
							}
						}
		).request();
	}
}//end of Cart Class

// Hide Box
function hideBox()
{
	element = $('#basket_body_id');
	accordion.display(element);
}

function clearTextBox(field,txt)
{
	if(field.value==txt)
	{
		field.value='';
	}
}

function changeFieldType(obj)
{
	$('#tftpwdfield').html('<input name="pword" type="password" id="email_pwd" value="" size="20"/>');
	$('#email_pwd').focus();
}


function ajaxLogin(formobj,container)
{
	$.ajax({
		type:'POST',
		url:'/index.php',
		data:'nolayout=true&page=40&ACTION=member_login.php&trigger=ajaxlogin&username='+ formobj.username.value +'&pword='+ formobj.pword.value,
		success:function(data){
			if(data.indexOf('loggedIN')!=-1)
			{
				$('#error_block').toggle('slow');

				//fetch Billing/Shipping Information Form
				fillBillingInfo('address_box');

				$('#login_box').toggle('slow');

			}
			else
			{
				$('#'+container).html(data);
				$('#'+container).show('slow');
			}
		}
	});


	/*
	var ajax = new Ajax('/index.php',
		{
			method:'get',
			data:'nolayout=true&page=40&ACTION=member_login.php&trigger=ajaxlogin&username='+ formobj.username.value +'&pword='+ formobj.pword.value,
			onRequest:function(request)
			{
				$(container).innerHTML = 'Authenticating! please standby...';
			},
			onComplete:function(r,rXml)
			{
				if(r=='loggedIN')
				{

					var collapsible1 = new Fx.Slide($('error_block'), {
					        duration: 500,
					        transition: Fx.Transitions.linear
					});

					collapsible1.toggle();

					//fetch Billing/Shipping Information Form
					fillBillingInfo('address_box');

					var collapsible = new Fx.Slide($('login_box'), {
					        duration: 500,
					        transition: Fx.Transitions.linear
					});

					collapsible.toggle();



				}
				else
				{
					$(container).innerHTML = r;
				}

			}
		}
		).request();*/

	return false;
}

function fillBillingInfo(container){

	$.ajax({
		url:'/index.php',
		data:'nolayout=true&page=40&trigger=ajax',
		success:function(data){
			$('#'+container).html(data);
		}
	});
	/*
	var ajax = new Ajax('/index.php',
		{
			method:'get',
			evalScripts:true,
			data:'nolayout=true&page=40&trigger=ajax',
			update:container,
			onRequest:function(request)
			{
				$(container).innerHTML = 'Fetching Billing information! please standby...';
			}
		}).request();
	*/
}

function pop_link(url,title,w,h) {
	pop_window = dhtmlwindow.open("popwin", "ajax", url, title, "width="+ w +"px,height="+ h +"px,resize=1,scrolling=1,center=1", "recal");
}


var openMyModal = function(source)
{
	modalWindow.windowId = "myModal";
	modalWindow.width = 430;
	modalWindow.height = 455;
	modalWindow.content ="<iframe width='410' height='455' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'></iframe>";
	modalWindow.open();
};



var modalWindow = {
	parent:"body",
	windowId:null,
	content:null,
	width:null,
	height:null,
	close:function()
	{
		$(".modal-window").remove();
		$(".modal-overlay").remove();
	},
	open:function()
	{
		var modal = "";
		modal += "<div class=\"modal-overlay\"></div>";
		modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
		modal += this.content;
		modal += "</div>";

		$(this.parent).append(modal);

		$(".modal-window").append("<a class=\"close-window\"></a>");
		$(".close-window").click(function(){modalWindow.close();});
	}
};


/**
 * Clears the form data.  Takes the following actions on the form's input fields:
 *  - input text fields will have their 'value' property set to the empty string
 *  - select elements will have their 'selectedIndex' property set to -1
 *  - checkbox and radio inputs will have their 'checked' property set to false
 *  - inputs of type submit, button, reset, and hidden will *not* be effected
 *  - button elements will *not* be effected
 */
$.fn.clearForm = function() {
    return this.each(function() {
        $('input,select,textarea', this).clearFields();
    });
};

/**
 * Clears the selected form elements.
 */
$.fn.clearFields = $.fn.clearInputs = function() {
    return this.each(function() {
        var t = this.type, tag = this.tagName.toLowerCase();
        if (t == 'text' || t == 'password' || tag == 'textarea')
            this.value = '';
        else if (t == 'checkbox' || t == 'radio')
            this.checked = false;
        else if (tag == 'select'){
            this.selectedIndex = 0;
        }
    });
};


jQuery.ui||(function(c){var i=c.fn.remove,d=c.browser.mozilla&&(parseFloat(c.browser.version)<1.9);c.ui={version:"1.7.2",plugin:{add:function(k,l,n){var m=c.ui[k].prototype;for(var j in n){m.plugins[j]=m.plugins[j]||[];m.plugins[j].push([l,n[j]])}},call:function(j,l,k){var n=j.plugins[l];if(!n||!j.element[0].parentNode){return}for(var m=0;m<n.length;m++){if(j.options[n[m][0]]){n[m][1].apply(j.element,k)}}}},contains:function(k,j){return document.compareDocumentPosition?k.compareDocumentPosition(j)&16:k!==j&&k.contains(j)},hasScroll:function(m,k){if(c(m).css("overflow")=="hidden"){return false}var j=(k&&k=="left")?"scrollLeft":"scrollTop",l=false;if(m[j]>0){return true}m[j]=1;l=(m[j]>0);m[j]=0;return l},isOverAxis:function(k,j,l){return(k>j)&&(k<(j+l))},isOver:function(o,k,n,m,j,l){return c.ui.isOverAxis(o,n,j)&&c.ui.isOverAxis(k,m,l)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(d){var f=c.attr,e=c.fn.removeAttr,h="http://www.w3.org/2005/07/aaa",a=/^aria-/,b=/^wairole:/;c.attr=function(k,j,l){var m=l!==undefined;return(j=="role"?(m?f.call(this,k,j,"wairole:"+l):(f.apply(this,arguments)||"").replace(b,"")):(a.test(j)?(m?k.setAttributeNS(h,j.replace(a,"aaa:"),l):f.call(this,k,j.replace(a,"aaa:"))):f.apply(this,arguments)))};c.fn.removeAttr=function(j){return(a.test(j)?this.each(function(){this.removeAttributeNS(h,j.replace(a,""))}):e.call(this,j))}}c.fn.extend({remove:function(){c("*",this).add(this).each(function(){c(this).triggerHandler("remove")});return i.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var j;if((c.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){j=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(c.curCSS(this,"position",1))&&(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}else{j=this.parents().filter(function(){return(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!j.length?c(document):j}});c.extend(c.expr[":"],{data:function(l,k,j){return !!c.data(l,j[3])},focusable:function(k){var l=k.nodeName.toLowerCase(),j=c.attr(k,"tabindex");return(/input|select|textarea|button|object/.test(l)?!k.disabled:"a"==l||"area"==l?k.href||!isNaN(j):!isNaN(j))&&!c(k)["area"==l?"parents":"closest"](":hidden").length},tabbable:function(k){var j=c.attr(k,"tabindex");return(isNaN(j)||j>=0)&&c(k).is(":focusable")}});function g(m,n,o,l){function k(q){var p=c[m][n][q]||[];return(typeof p=="string"?p.split(/,?\s+/):p)}var j=k("getter");if(l.length==1&&typeof l[0]=="string"){j=j.concat(k("getterSetter"))}return(c.inArray(o,j)!=-1)}c.widget=function(k,j){var l=k.split(".")[0];k=k.split(".")[1];c.fn[k]=function(p){var n=(typeof p=="string"),o=Array.prototype.slice.call(arguments,1);if(n&&p.substring(0,1)=="_"){return this}if(n&&g(l,k,p,o)){var m=c.data(this[0],k);return(m?m[p].apply(m,o):undefined)}return this.each(function(){var q=c.data(this,k);(!q&&!n&&c.data(this,k,new c[l][k](this,p))._init());(q&&n&&c.isFunction(q[p])&&q[p].apply(q,o))})};c[l]=c[l]||{};c[l][k]=function(o,n){var m=this;this.namespace=l;this.widgetName=k;this.widgetEventPrefix=c[l][k].eventPrefix||k;this.widgetBaseClass=l+"-"+k;this.options=c.extend({},c.widget.defaults,c[l][k].defaults,c.metadata&&c.metadata.get(o)[k],n);this.element=c(o).bind("setData."+k,function(q,p,r){if(q.target==o){return m._setData(p,r)}}).bind("getData."+k,function(q,p){if(q.target==o){return m._getData(p)}}).bind("remove",function(){return m.destroy()})};c[l][k].prototype=c.extend({},c.widget.prototype,j);c[l][k].getterSetter="option"};c.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").removeAttr("aria-disabled")},option:function(l,m){var k=l,j=this;if(typeof l=="string"){if(m===undefined){return this._getData(l)}k={};k[l]=m}c.each(k,function(n,o){j._setData(n,o)})},_getData:function(j){return this.options[j]},_setData:function(j,k){this.options[j]=k;if(j=="disabled"){this.element[k?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",k)}},enable:function(){this._setData("disabled",false)},disable:function(){this._setData("disabled",true)},_trigger:function(l,m,n){var p=this.options[l],j=(l==this.widgetEventPrefix?l:this.widgetEventPrefix+l);m=c.Event(m);m.type=j;if(m.originalEvent){for(var k=c.event.props.length,o;k;){o=c.event.props[--k];m[o]=m.originalEvent[o]}}this.element.trigger(m,n);return !(c.isFunction(p)&&p.call(this.element[0],m,n)===false||m.isDefaultPrevented())}};c.widget.defaults={disabled:false};c.ui.mouse={_mouseInit:function(){var j=this;this.element.bind("mousedown."+this.widgetName,function(k){return j._mouseDown(k)}).bind("click."+this.widgetName,function(k){if(j._preventClickEvent){j._preventClickEvent=false;k.stopImmediatePropagation();return false}});if(c.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(c.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},_mouseDown:function(l){l.originalEvent=l.originalEvent||{};if(l.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(l));this._mouseDownEvent=l;var k=this,m=(l.which==1),j=(typeof this.options.cancel=="string"?c(l.target).parents().add(l.target).filter(this.options.cancel).length:false);if(!m||j||!this._mouseCapture(l)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){k.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(l)&&this._mouseDelayMet(l)){this._mouseStarted=(this._mouseStart(l)!==false);if(!this._mouseStarted){l.preventDefault();return true}}this._mouseMoveDelegate=function(n){return k._mouseMove(n)};this._mouseUpDelegate=function(n){return k._mouseUp(n)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(c.browser.safari||l.preventDefault());l.originalEvent.mouseHandled=true;return true},_mouseMove:function(j){if(c.browser.msie&&!j.button){return this._mouseUp(j)}if(this._mouseStarted){this._mouseDrag(j);return j.preventDefault()}if(this._mouseDistanceMet(j)&&this._mouseDelayMet(j)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,j)!==false);(this._mouseStarted?this._mouseDrag(j):this._mouseUp(j))}return !this._mouseStarted},_mouseUp:function(j){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(j.target==this._mouseDownEvent.target);this._mouseStop(j)}return false},_mouseDistanceMet:function(j){return(Math.max(Math.abs(this._mouseDownEvent.pageX-j.pageX),Math.abs(this._mouseDownEvent.pageY-j.pageY))>=this.options.distance)},_mouseDelayMet:function(j){return this.mouseDelayMet},_mouseStart:function(j){},_mouseDrag:function(j){},_mouseStop:function(j){},_mouseCapture:function(j){return true}};c.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery);

(function(a){a.widget("ui.dropdownchecklist",{_appendDropContainer:function(){var c=a("<div/>");c.addClass("ui-dropdownchecklist-dropcontainer-wrapper");c.css({position:"absolute",left:"-3300",top:"-3300px",width:"3000px",height:"3000px"});var b=a("<div/>");b.addClass("ui-dropdownchecklist-dropcontainer").css("overflow-y","auto");c.append(b);a(document.body).append(c);c.drop=false;return c},_isDropDownKeyShortcut:function(b){return b.altKey&&(a.ui.keyCode.DOWN==(b.keyCode||b.which))},_isDroDownCloseKey:function(b){return a.ui.keyCode.ESCAPE==(b.keyCode||b.which)},_handleKeyboard:function(c){var b=this;if(b._isDropDownKeyShortcut(c)){c.stopPropagation();b._toggleDropContainer();b.dropWrapper.find("input:first").focus()}else{if(b.dropWrapper.drop&&b._isDroDownCloseKey(c)){b._toggleDropContainer()}}},_appendControl:function(){var b=this,c=this.sourceSelect;var f=a("<span/>");f.addClass("ui-dropdownchecklist-wrapper");f.css({display:"inline-block",cursor:"default"});var e=a("<span/>");e.addClass("ui-dropdownchecklist");e.css({display:"inline-block"});e.attr("tabIndex",0);e.keyup(function(g){b._handleKeyboard(g)});f.append(e);var d=a("<span/>");d.addClass("ui-dropdownchecklist-text");d.css({display:"inline-block",overflow:"hidden"});e.append(d);f.hover(function(){if(!b.disabled){e.toggleClass("ui-dropdownchecklist-hover")}},function(){if(!b.disabled){e.toggleClass("ui-dropdownchecklist-hover")}});f.click(function(g){if(!b.disabled){g.stopPropagation();b._toggleDropContainer()}});f.insertAfter(c);return f},_createDropItem:function(h,k,m,l,f,d){var o=this;var n=a("<div/>");n.addClass("ui-dropdownchecklist-item");n.css({whiteSpace:"nowrap"});var c=l?' checked="checked"':"";var j=f?' disabled="disabled"':"";var p=(o.sourceSelect.attr("id")||"ddcl");var b=p+h;var g;if(o.initialMultiple){g=a('<input type="checkbox" id="'+b+'"'+c+j+"/>")}else{g=a('<input type="radio" id="'+b+'" name="'+p+'"'+c+j+"/>")}g=g.attr("index",h).val(k);n.append(g);var i=a("<label for="+b+"/>");i.addClass("ui-dropdownchecklist-text").css({cursor:"default",width:"100%"}).text(m);if(d){n.addClass("ui-dropdownchecklist-indent")}if(f){n.addClass("ui-dropdownchecklist-item-disabled")}n.append(i);n.hover(function(){n.addClass("ui-dropdownchecklist-item-hover")},function(){n.removeClass("ui-dropdownchecklist-item-hover")});g.click(function(q){q.stopPropagation();if(!f){o._syncSelected(a(this));o.sourceSelect.trigger("change","ddcl_internal")}});var e=function(r){r.stopPropagation();if(!f){var q=g.attr("checked");g.attr("checked",!q);o._syncSelected(g);o.sourceSelect.trigger("change","ddcl_internal")}};i.click(function(q){q.stopPropagation()});n.click(e);n.keyup(function(q){o._handleKeyboard(q)});return n},_createGroupItem:function(d){var c=a("<div />");c.addClass("ui-dropdownchecklist-group");c.css({whiteSpace:"nowrap"});var b=a("<span/>");b.addClass("ui-dropdownchecklist-text").css({cursor:"default",width:"100%"}).text(d);c.append(b);return c},_appendItems:function(){var d=this,g=this.sourceSelect,f=this.dropWrapper;var b=f.find(".ui-dropdownchecklist-dropcontainer");b.css({"float":"left"});g.children().each(function(h){var i=a(this);if(i.is("option")){d._appendOption(i,b,h,false)}else{var k=i.attr("label");var j=d._createGroupItem(k);b.append(j);d._appendOptions(i,b,h,true)}});var c=b.outerWidth();var e=b.outerHeight();b.css({"float":""});return{width:c,height:e}},_appendOptions:function(f,c,e,b){var d=this;f.children("option").each(function(g){var h=a(this);var i=(e+"."+g);d._appendOption(h,c,i,b)})},_appendOption:function(f,b,g,c){var k=this;var i=f.text();var h=f.val();var e=f.attr("selected");var d=f.attr("disabled");var j=k._createDropItem(g,h,i,e,d,c);b.append(j)},_syncSelected:function(g){var h=this,i=this.options,c=this.sourceSelect,d=this.dropWrapper;var f=d.find("input:not([disabled])");if(i.firstItemChecksAll){if(g.attr("index")==0){f.attr("checked",g.attr("checked"))}else{var e;e=true;f.each(function(k){if(k>0){var l=a(this).attr("checked");if(!l){e=false}}});var j=f.filter(":first");j.attr("checked",false);if(e){j.attr("checked",true)}}}var b=c.get(0).options;f.each(function(k){a(b[k]).attr("selected",a(this).attr("checked"))});h._updateControlText()},_sourceSelectChangeHandler:function(c){var b=this,d=this.dropWrapper;d.find("input").val(b.sourceSelect.val());b._updateControlText()},_updateControlText:function(){var h=this,b=this.sourceSelect,i=this.options,e=this.controlWrapper;var j=b.find("option:first");var f=null!=j&&j.attr("selected");var c=b.find("option");var g=h._formatText(c,i.firstItemChecksAll,f);var d=e.find(".ui-dropdownchecklist-text");d.text(g);d.attr("title",g)},_formatText:function(c,d,b){var e;if(d&&b){e=c.filter(":first").text()}else{e="";c.each(function(){if(a(this).attr("selected")){e+=a(this).text()+", "}});if(e.length>0){e=e.substring(0,e.length-2)}}return e},_toggleDropContainer:function(){var c=this,f=this.dropWrapper,e=this.controlWrapper;var d=function(){var g=a.ui.dropdownchecklist.drop;if(null!=g){g.dropWrapper.css({top:"-3300px",left:"-3300px"});g.controlWrapper.find(".ui-dropdownchecklist").toggleClass("ui-dropdownchecklist-active");g.dropWrapper.find("input").attr("tabIndex",-1);g.dropWrapper.drop=false;a.ui.dropdownchecklist.drop=null;a(document).unbind("click",d);c.sourceSelect.trigger("blur")}};var b=function(g){if(null!=a.ui.dropdownchecklist.drop){d()}g.dropWrapper.css({top:g.controlWrapper.offset().top+g.controlWrapper.outerHeight()+"px",left:g.controlWrapper.offset().left+"px"});var i=e.parents().map(function(){var j=a(this).css("z-index");return isNaN(j)?0:j}).get();var h=Math.max.apply(Math,i);if(h>0){g.dropWrapper.css({zIndex:(h+1)})}g.controlWrapper.find(".ui-dropdownchecklist").toggleClass("ui-dropdownchecklist-active");g.dropWrapper.find("input").attr("tabIndex",0);g.dropWrapper.drop=true;a.ui.dropdownchecklist.drop=g;a(document).bind("click",d);c.sourceSelect.trigger("focus")};if(f.drop){d(c)}else{b(c)}},_setSize:function(b){var j=this.options,e=this.dropWrapper,h=this.controlWrapper;var g;if(j.width){g=parseInt(j.width)}else{g=b.width;var c=j.minWidth;if(g<c){g=c}}h.find(".ui-dropdownchecklist-text").css({width:g+"px"});var i=h.outerWidth();var f=j.maxDropHeight?parseInt(j.maxDropHeight):b.height;var d=b.width<i?i:b.width;a(e).css({width:d+"px",height:f+"px"});e.find(".ui-dropdownchecklist-dropcontainer").css({height:f+"px"})},_init:function(){var c=this,d=this.options;var g=c.element;c.initialDisplay=g.css("display");g.css("display","none");c.initialMultiple=g.attr("multiple");g.attr("multiple","multiple");c.sourceSelect=g;var f=c._appendDropContainer();c.dropWrapper=f;var b=c._appendItems();var e=c._appendControl();c.controlWrapper=e;c._updateControlText(e,f,g);c._setSize(b);if(d.bgiframe&&typeof c.dropWrapper.bgiframe=="function"){c.dropWrapper.bgiframe()}c.sourceSelect.change(function(i,h){if(h!="ddcl_internal"){c._sourceSelectChangeHandler(i)}})},enable:function(){this.controlWrapper.find(".ui-dropdownchecklist").removeClass("ui-dropdownchecklist-disabled");this.disabled=false},disable:function(){this.controlWrapper.find(".ui-dropdownchecklist").addClass("ui-dropdownchecklist-disabled");this.disabled=true},destroy:function(){a.widget.prototype.destroy.apply(this,arguments);this.sourceSelect.css("display",this.initialDisplay);this.sourceSelect.attr("multiple",this.initialMultiple);this.controlWrapper.unbind().remove();this.dropWrapper.remove()}});a.extend(a.ui.dropdownchecklist,{defaults:{width:null,maxDropHeight:null,firstItemChecksAll:false,minWidth:50,bgiframe:false}})})(jQuery);
