/**
 * 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.A={1y:8.1C,1q:6(){2.A.1l();2.3.1e()},1o:6(D){D=$(D);4(!D){k 2.A}7 14=D.1B(".12-Q-1F");7 E=0;14.15(6(K){E=1U.E(K.1Q().1J.y,E)});14.18("1P",E)},1l:6(){7 P=$$(".o-1K-C, .12-Q-1M");4(P.m){P.15(6(C){7 I=C.f(".1R");7 M=C.f(".1L");7 c=C.f(".1T");4(!I||!M||!c){k}7 1S=c.j().d();c.i("1O",6(e){e=(b u(e)).s();7 5=9.5;4(5<0){5=0}4(16(5)){9.5=1;5=1}4(e.1d=="I"){4($z(9.j().d())=="v"){9.5=++5}}4(e.1d=="M"){4(5>0&&$z(9.j().d())=="v"){9.5=--5}}});c.i("1A",6(e){e=(b u(e)).s();7 5=9.5;4(5<0){5=0}4(16(5)){9.5=1;5=1}4(e.17==1){4($z(9.j().d())=="v"){9.5=++5}}4(e.17==-1){4(5>0&&$z(9.j().d())=="v"){9.5=--5}}});I.i("10",6(e){(b u(e)).s();4($z(c.j().d())=="v"){c.5=++c.5}});M.i("10",6(e){(b u(e)).s();4(c.j().d()>0&&$z(c.j().d())=="v"){c.5=--c.5}})})}}};2.3={1e:6(){2.3.g=$("o-B");2.3.p=$("o-J");2.3.11=$("o-B-1D");4(!2.3.g||!2.3.p||!2.3.11){k 2.3}4(!2.3.h){2.3.h=(b(h.1z)(2.3.g,{1E:1G,1H:h.1I.1N.2d})).X()}2.3.11.18("2k","2l");2.3.p.W("a").i("10",6(e){(b u(e)).s();4(!2.3.g.Z().m&&!8.Y){k}4(!2.3.g.1r.2j().m&&8.Y){k}7 l=2.3.p.f("1i");4(!l||!l.Z().d()&&!2.3.g.Z().m){k}2.3.x=G;4(8.t&&8.t.N){8.t.F()}4(8.w&&8.w.N){8.w.F()}2.3.h.F()});2.1n=b(h.2i)(8);2.3.R();2.3.1f()},1f:6(){7 13=$$(".2f");4(!13.m){k 2.3}13.15(6(T){T.i("2g",2.3.1c.2h(T,G))})},1c:6(e,x){(b u(e)).s();(b 1x(9.2n("2s"),{19:$(9),1g:G,1a:6(r){7 H=b 1t(\'K\').O(r);7 1b=H.f(\'.1v\');2.3.R((r.m&&1b)?r:V);2.3.x=x||V}})).1w()},R:6(q){7 1u={1a:6(n){2.3.1h(n,q)},1g:G,19:{2r:1,2q:"2o.1V",2p:"2m"}};(b 1x(2.A.1y+"2e.21",1u)).1w()},1m:6(n){7 B=2.3.g;7 H=b 1t(\'K\').O(n);7 L=B.f(\'.U-o-J\');7 22=H.f(\'.1v\').23((L)?L:B,(L)?\'20\':\'1Z\')},1h:6(n,q){2.3.g.O(n);7 S=2.3.g.f(".1W"),l=0;4(S){l=S.1r.1X(" ")[0].d()}4(!l){2.3.p.W().1k("1j","o-J-1s")}1Y{2.3.p.W().1k("1j","o-J-1s-24")}2.3.p.f("1i").25(l);4(q)2.3.1m(q);4(2.3.x&&n.m||q){4(8.t&&8.t.N){8.t.F()}4(8.w&&8.w.N){8.w.F()}2.1n.2b();2.3.U();2.3.X.2c(2.2a*29)}2.3.x=V},U:6(){2.3.h.26()},X:6(){2.3.h.27()}};8.i("1p",2.A.1q);8.i(8.Y?"28":"1p",6(){2.A.1o("12-Q")});',62,153,'||RokVM|Cart|if|value|function|var|window|this||new|input|toInt||getElement|cartPanel|Fx|addEvent|getValue|return|total|length|response|cart|cartButton|error||stop|fontFx|Event|number|loginFx|clicked||type|Base|panel|box|id|max|toggle|true|trash|up|button|div|panelPos|down|open|setHTML|boxes|featured|getShortList|products|form|show|false|getFirst|hide|webkit|getText|click|cartSurround|home|forms|divs|each|isNaN|wheel|setStyle|data|onComplete|tip|add|key|init|XHRify|evalScripts|update|strong|class|setProperty|quantityBox|handleError|scrollWindow|featuredHeight|domready|start|innerHTML|desc|Element|options|shop_tip|request|Ajax|uri|Slide|mousewheel|getElements|templatePath|surround|duration|inner|400|transition|Transitions|size|quantity|quantity_box_button_down|cartblock|Expo|keyup|height|getSize|quantity_box_button_up|val|inputboxquantity|Math|basket_short|total_products|split|else|inside|before|php|info|inject|full|setText|slideIn|slideOut|load|1000|autoHide|toTop|delay|easeOut|index2|addtocart_form|submit|bindWithEvent|Scroll|clean|visibility|visible|com_virtuemart|getProperty|shop|option|page|only_page|action'.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();
}