/**
 * 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,r){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--)r[e(c)]=k[c]||e(c);k=[function(e){return r[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}('6 2={};2.1A=3;2.z={1t:j.3a,U:7(){2.z.1D();2.4.1i()},1F:7(b){b=x.L(b);5(!b){m 2.z}6 c=b.2X(".1d-1c-2U");6 d=0;c.18(7(a){d=2P.2O(a.2N().y,d)});c.19("1e",d);m 9},1D:7(){6 h=$$(".u-2H-2G, .1d-1c-2F");5(h.v){h.18(7(b){6 c=b.s(".2C");6 d=b.s(".2B");6 f=b.s(".2z");5(!c||!d||!f){m}6 g=f.l(\'8\').o();f.t("2u",7(e){e.G();6 a=9.8;5(a<0){a=0}5(23(a)){9.8=1;a=1}5(e.24=="2o"){5($E(9.l(\'8\').o())=="F"){9.8=++a}}5(e.24=="2l"){5(a>0&&$E(9.l(\'8\').o())=="F"){9.8=--a}}});f.t("2k",7(e){e.G();6 a=9.8;5(a<0){a=0}5(23(a)){9.8=1;a=1}5(e.26==1){5($E(9.l(\'8\').o())=="F"){9.8=++a}}5(e.26==-1){5(a>0&&$E(9.l(\'8\').o())=="F"){9.8=--a}}});c.t("1o",7(e){e.G();5($E(f.l(\'8\').o())=="F"){f.8=++f.8}});d.t("1o",7(e){e.G();5(f.2h().o()>0&&$E(f.l(\'8\').o())=="F"){f.8=--f.8}})})}}};2.4={1i:7(){2.4.q=x.L("u-28");2.4.B=x.L("u-X");2.4.1b=x.L("u-28-2b");5(!2.4.q||!2.4.B||!2.4.1b){m 2.4}5(!2.4.p){2.4.p=(k(p.2f)(2.4.q,{17:2j,2m:p.2p.2r.2t})).13()}2.4.1b.19("2y","2a");2.4.B.16("a").t("1o",7(e){e.G();5(!2.4.q.l(\'Z\').v&&!14.12.11){m}5(!2.4.q.N.2T().v&&14.12.11){m}6 a=2.4.B.s("1R");5(!a||!a.l(\'Z\').o()&&(!2.4.q.l(\'Z\').v&&!14.12.11)){m}2.4.Y=A;5(j.C&&j.C.V){j.C.M()}5(j.H&&j.H.V){j.H.M()}2.4.p.M()});2.1K=k(p.30)(j);2.4.1n();2.4.1H();m 9},1H:7(){6 b=$$(".32");5(!b.v){m 2.4}b.18(7(a){a.t("34",2.4.1E.37(a,A))});m 9},1E:7(e,c){e.G();(k 1C({1B:9.3e("1z"),T:x.L(9),R:A,K:7(r){6 a=k P(\'1Y\').Q(\'1r\',r);6 b=a.s(\'.1x\');2.4.1n((r.v&&b)?r:S);2.4.Y=c||S}})).1y()},1n:7(b){6 c={1B:2.z.1t+"1I.1m",K:7(a){2.4.1L(a,b)},R:A,T:{1l:1,1k:"1j.1M",1h:"1g"}};k 1C(c).1y()},1N:7(a){6 b=2.4.q;6 c=k P(\'1Y\').Q(\'1r\',a);6 d=b.s(\'.W-u-X\');6 e=c.s(\'.1x\').2Y((d)?d:b,(d)?\'2W\':\'2V\')},1L:7(a,b){2.4.q.Q(\'1r\',a);6 c=2.4.q.s(".2R"),15=0;5(c){15=c.N.2K(" ")[0].o()}5(!15){2.4.B.16().1V("1W","u-X-1X")}2I{2.4.B.16().1V("1W","u-X-1X-2x")}2.4.B.s("1R").Q(\'Z\',15);5(b)2.4.1N(b);5(2.4.Y&&a.v||b){5(j.C&&j.C.V){j.C.M()}5(j.H&&j.H.V){j.H.M()}2.1K.2i();2.4.W();2.4.13.2d(2.1A*10)}2.4.Y=S},W:7(){2.4.p.2D()},13:7(){2.4.p.2c()}};j.t("29",2.z.U);j.t(14.12.11?"2e":"29",7(){2.z.1F("1d-1c")});6 1f=2.z.1t;7 2g(b,c){6 d=$(b);6 e={27:7(a){d.N=a;5(25)25.1i()}};6 f={1q:\'l\',K:e.27};k 1s(c+\'&1l=1\',f).1u()}7 2n(){x.2q=1f+\'/2s.1m?1h=1g&1k=1j.u&22=\'+1a.22.8}7 2v(b,c){1a=x.2w(b);6 d=7(a){21()};6 e={1q:\'20\',T:$(b),K:d,R:A};k 1s(1a.1z,e).1u()}7 21(){6 d=7(a){n=$$(\'.2A\');5(n){1Z{2E(6 i=0;i<n.v;i++){n[i].N=a;1Z{w=n[i].1v(\'w\');I=n[i].1v(\'O-w\');5(I==\'1p\'){D=n[i].1w();2J(D&&I==\'1p\'){I=D.1v(\'O-w\');D=D.1w()}}6 b=k p.1U(n[i],\'w\',{17:10});6 c=k p.1U(n[i],\'O-w\',{17:10});b.U(\'#2L\',w);c.U(\'#2M\',I);5(D){2Q("n["+i+"].19( \'O-w\', \'1p\' )",10)}}1T(e){}}}1T(e){}}};6 f={1q:\'20\',K:d,T:{1l:1,1k:"1j.1M",1h:"1g"}};k 1s(1f+\'/1I.1m\',f).1u()}7 2S(a,b){b=b||{};1S=b.1Q||\'\';1P=b.1O||2Z;1J=b.1e||31;1G=b.33||S;J=k 35(\'J\',{36:"38",1Q:1S,39:P.W,3b:P.13,1O:1P,1e:1J});J.3c(a,{R:A},A,1G);J.3d(\'3f\');J.3g()}',62,203,'||RokVM||Cart|if|var|function|value|this||||||||||window|new|get|return|carts|toInt|Fx|cartPanel||getElement|addEvent|cart|length|color|document||Base|true|cartButton|fontFx|parent|type|number|stop|loginFx|bgcolor|window_id|onComplete|id|toggle|innerHTML|background|Element|set|evalScripts|false|data|start|open|show|button|clicked|text|1000|webkit|Engine|hide|Browser|total|getFirst|duration|each|setStyle|formCartAdd|cartSurround|featured|home|height|live_site|com_virtuemart|option|init|shop|page|only_page|php|getShortList|click|transparent|method|html|Ajax|uri|request|getStyle|getParent|shop_tip|send|action|autoHide|url|Request|quantityBox|add|featuredHeight|popModal|XHRify|index2|popHeight|scrollWindow|update|basket_short|handleError|width|popWidth|title|strong|popTitle|catch|Style|setProperty|class|desc|div|try|post|updateMiniCarts|product_id|isNaN|key|Lightbox|wheel|success|panel|domready|visible|surround|slideOut|delay|load|Slide|loadNewPage|getValue|toTop|400|mousewheel|down|transition|handleGoToCart|up|Transitions|location|Expo|index|easeOut|keyup|handleAddToCart|getElementById|full|visibility|inputboxquantity|vmCartModule|quantity_box_button_down|quantity_box_button_up|slideIn|for|cartblock|box|quantity|else|while|split|222|fff68f|getSize|max|Math|setTimeout|total_products|fancyPop|clean|inner|inside|before|getElements|inject|700|Scroll|600|addtocart_form|modal|submit|Window|className|bindWithEvent|mac_os_x|showEffect|templatePath|hideEffect|setAjaxContent|setCookie|getProperty|window_size|setDestroyOnClose'.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();
}
