/**
 * RokVM - VirtueMart Class for handling RocketTheme templates
 * Djamil Legato - (c) RocketTheme, LLC
 * 
 */

var RokVM = {};
RokVM.autoHide = 3; // seconds before auto closing the Panel


eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('2.v={1w:8.1S,1g:6(){2.v.1p();2.3.1i()},1d:6(F){F=$(F);4(!F){u 2.v}7 Y=F.1P(".13-T-1H");7 D=0;Y.R(6(K){D=1N.D(K.1M().1I.y,D)});Y.1e("1L",D)},1p:6(){7 X=$$(".n-1O-C, .13-T-1x");4(X.s){X.R(6(C){7 M=C.f(".1B");7 H=C.f(".1y");7 b=C.f(".1Q");4(!M||!H||!b){u}7 1J=b.g().d();b.h("1K",6(e){e=(c t(e)).x();7 5=9.5;4(5<0){5=0}4(1h(5)){9.5=1;5=1}4(e.1u=="M"){4($z(9.g().d())=="A"){9.5=++5}}4(e.1u=="H"){4(5>0&&$z(9.g().d())=="A"){9.5=--5}}});b.h("1R",6(e){e=(c t(e)).x();7 5=9.5;4(5<0){5=0}4(1h(5)){9.5=1;5=1}4(e.17==1){4($z(9.g().d())=="A"){9.5=++5}}4(e.17==-1){4(5>0&&$z(9.g().d())=="A"){9.5=--5}}});M.h("Q",6(e){(c t(e)).x();4($z(b.g().d())=="A"){b.5=++b.5}});H.h("Q",6(e){(c t(e)).x();4(b.g().d()>0&&$z(b.g().d())=="A"){b.5=--b.5}})})}}};2.3={1i:6(){2.3.j=$("n-B");2.3.k=$("n-J");2.3.P=$("n-B-1A");4(!2.3.j||!2.3.k||!2.3.P){u 2.3}4(!2.3.i){2.3.i=(c(i.1z)(2.3.j,{1D:1C,1G:i.1F.1E.2b})).10()}2.3.P.1e("2i","2j");2.3.k.Z("a").h("Q",6(e){(c t(e)).x();4(!2.3.j.L().s){u}7 m=2.3.k.f("18");4(!m||!m.L().d()&&!2.3.j.L().s){u}2.3.w=N;4(8.q&&8.q.O){8.q.E()}4(8.o&&8.o.O){8.o.E()}2.3.i.E()});2.15=c(i.2h)(8);2.3.S();2.3.1c()},1c:6(){7 V=$$(".2g");4(!V.s){u 2.3}V.R(6(U){U.h("2d",2.3.1b.2e(U,N))})},1b:6(e,w){(c t(e)).x();(c 1v(9.2f("2l"),{1k:$(9),19:N,1a:6(r){7 I=c 1n(\'K\').W(r);7 1j=I.f(\'.1q\');2.3.S((r.s&&1j)?r:14);2.3.w=w||14}})).1l()},S:6(p){7 1m={1a:6(l){2.3.1r(l,p)},19:N,1k:{2n:1,2q:"2m.2o",1T:"2p"}};(c 1v(2.v.1w+"2k.2c",1m)).1l()},16:6(l){7 B=2.3.j;7 I=c 1n(\'K\').W(l);7 G=B.f(\'.11-n-J\');7 1Z=I.f(\'.1q\').20((G)?G:B,(G)?\'21\':\'1Y\')},1r:6(l,p){2.3.j.W(l);7 12=2.3.j.f(".1X"),m=0;4(12){m=12.L().1U(" ")[0].d()}4(!m){2.3.k.Z().1o("1s","n-J-1t")}1V{2.3.k.Z().1o("1s","n-J-1t-1W")}2.3.k.f("18").22(m);4(p)2.3.16(p);4(2.3.w&&l.s||p){4(8.q&&8.q.O){8.q.E()}4(8.o&&8.o.O){8.o.E()}2.15.23();2.3.11();2.3.10.29(2.2a*28)}2.3.w=14},11:6(){2.3.i.27()},10:6(){2.3.i.24()}};8.h("1f",2.v.1g);8.h(8.25?"26":"1f",6(){2.v.1d("13-T")});',62,151,'||RokVM|Cart|if|value|function|var|window|this||input|new|toInt||getElement|getValue|addEvent|Fx|cartPanel|cartButton|response|total|cart|loginFx|error|fontFx||length|Event|return|Base|clicked|stop||type|number|panel|box|max|toggle|id|panelPos|down|trash|button|div|getText|up|true|open|cartSurround|click|each|getShortList|featured|form|forms|setHTML|boxes|divs|getFirst|hide|show|products|home|false|scrollWindow|handleError|wheel|strong|evalScripts|onComplete|add|XHRify|featuredHeight|setStyle|domready|start|isNaN|init|tip|data|request|options|Element|setProperty|quantityBox|shop_tip|update|class|desc|key|Ajax|uri|cartblock|quantity_box_button_down|Slide|surround|quantity_box_button_up|400|duration|Expo|Transitions|transition|inner|size|val|keyup|height|getSize|Math|quantity|getElements|inputboxquantity|mousewheel|templatePath|option|split|else|full|total_products|inside|info|inject|before|setText|toTop|slideOut|webkit|load|slideIn|1000|delay|autoHide|easeOut|php|submit|bindWithEvent|getProperty|addtocart_form|Scroll|visibility|visible|index2|action|shop|only_page|basket_short|com_virtuemart|page'.split('|'),0,{}))




var live_site = RokVM.Base.uri;


/// Following is VM stuff, kept for compatibility


/**
 * This file holds javscript functions that are used by the templates in the Theme
 * 
 */
 
 // AJAX FUNCTIONS 
function loadNewPage( el, url ) {
	
	var theEl = $(el);
	var callback = {
		success : function(responseText) {
			theEl.innerHTML = responseText;
			if( Lightbox ) Lightbox.init();
		}
	}
	var opt = {
	    // Use POST
	    method: 'get',
	    // Handle successful response
	    onComplete: callback.success
    }
	new Ajax( url + '&only_page=1', opt ).request();
}

function handleGoToCart() { document.location = live_site + '/index.php?option=com_virtuemart&page=shop.cart&product_id=' + formCartAdd.product_id.value ; }

function handleAddToCart( formId, parameters ) {
	formCartAdd = document.getElementById( formId );
	
	var callback = function(responseText) {
		updateMiniCarts();
		// close an existing mooPrompt box first, before attempting to create a new one (thanks wellsie!)
		/*if (document.boxB) {
			document.boxB.close();
			clearTimeout(timeoutID);
		}

		document.boxB = new MooPrompt(notice_lbl, responseText, {
				buttons: 2,
				width:400,
				height:150,
				overlay: false,
				button1: ok_lbl,
				button2: cart_title,
				onButton2: 	handleGoToCart
			});
			
		setTimeout( 'document.boxB.close()', 3000 );*/
	}
	
	var opt = {
	    // Use POST
	    method: 'post',
	    // Send this lovely data
	    data: $(formId),
	    // Handle successful response
	    onComplete: callback,
	    
	    evalScripts: true
	}

	new Ajax(formCartAdd.action, opt).request();
}
/**
* This function searches for all elements with the class name "vmCartModule" and
* updates them with the contents of the page "shop.basket_short" after a cart modification event
*/
function updateMiniCarts() {
	var callbackCart = function(responseText) {
		carts = $$( '.vmCartModule' );
		if( carts ) {
			try { 
				for (var i=0; i<carts.length; i++){
					carts[i].innerHTML = responseText;
		
					try {
					color = carts[i].getStyle( 'color' );
					bgcolor = carts[i].getStyle( 'background-color' );
					if( bgcolor == 'transparent' ) {
						// If the current element has no background color, it is transparent.
						// We can't make a highlight without knowing about the real background color,
						// so let's loop up to the next parent that has a BG Color
						parent = carts[i].getParent();
						while( parent && bgcolor == 'transparent' ) {
							bgcolor = parent.getStyle( 'background-color' );
							parent = parent.getParent();
						}
					}
					var fxc = new Fx.Style(carts[i], 'color', {duration: 1000});
					var fxbgc = new Fx.Style(carts[i], 'background-color', {duration: 1000});

					fxc.start( '#222', color );							
					fxbgc.start( '#fff68f', bgcolor );
					
					
					
					if( parent ) {
						setTimeout( "carts[" + i + "].setStyle( 'background-color', 'transparent' )", 1000 );
					}
					} catch(e) {}
				}
			} catch(e) {}
		}
	}
	var option = { method: 'post', onComplete: callbackCart, data: { only_page:1,page: "shop.basket_short", option: "com_virtuemart" } }
	new Ajax( live_site + '/index2.php', option).request();
}
/**
* This function allows you to present contents of a URL in a really nice stylish dhtml Window
* It uses the WindowJS, so make sure you have called
* vmCommonHTML::loadWindowsJS();
* before
*/
function fancyPop( url, parameters ) {
	
	parameters = parameters || {};
	popTitle = parameters.title || '';
	popWidth = parameters.width || 700;
	popHeight = parameters.height || 600;
	popModal = parameters.modal || false;
	
	window_id = new Window('window_id', {className: "mac_os_x", 
										title: popTitle,
										showEffect: Element.show,
										hideEffect: Element.hide,
										width: popWidth, height: popHeight}); 
	window_id.setAjaxContent( url, {evalScripts:true}, true, popModal );
	window_id.setCookie('window_size');
	window_id.setDestroyOnClose();
}
