var Pyra={initProduct:function(){var m=available=false;var n=$('.productOptions').length;if(n==0){m=true}$('.productOptions select').change(function(){var h=$(this).attr('name').substr(14,1);for(var i=0;i<n;i++){if(h==i||h>i){continue}else{$("select[name='productOption["+i+"]']").get(0).selectedIndex=0}}if(h==n-1){var j=$(this).get(0).form;var k={id:$('#product_id').val()};var l=true;for(var i=0;i<n;i++){k['po['+i+']']=j.elements["productOption["+i+"]"].value;if(j.elements["productOption["+i+"]"].value==''){l=false}}if(l){$.post('/xml_http_req/product_option',k,function(a){m=true;var b=a.documentElement.childNodes[0].firstChild.nodeValue;var c=a.documentElement.childNodes[1].firstChild.nodeValue;var d=a.documentElement.childNodes[2].firstChild.nodeValue;var e=a.documentElement.childNodes[3].firstChild.nodeValue;var f=a.documentElement.childNodes[4].firstChild.nodeValue;var g=a.documentElement.childNodes[5].firstChild.nodeValue;if(g>0){available=true}$('.pdPrice').html(d);$('.saveTxt').html(e)})}}});$('#pForm').submit(function(){if($('#optionsRequired').val()==0){m=true;available=true}if(m){if(available){return true}else{if(n==0){return true}else{alert('Item out of stock');return false}}}else{alert('Please choose all options');return false}});$('#loginForm').submit(function(){if($('#email').val()!=''&&$('#psswrd').val()!=''){$.post('/xml_http_req/auth_user',{e:$('#email').val(),p:$('#psswrd').val()},function(a){if(a.documentElement.firstChild.nodeValue==1){$('#postComment').show();$('#commentSignin').hide();$('#commentSignup').hide()}else{$('#postComment').hide()}})}else{alert('Please complete all form fields.')}return false});$('#postBtn').submit(function(){if($('#comment').val()!=''){$.post('/xml_http_req/post_comment',{c:$('#comment').val(),i:$('#product_id').val(),r:1},function(a){if(a.documentElement.firstChild.nodeValue==1){alert('Your comment has been posted successfully, and will be visible once reviewed.');$('#comment').val('')}else{alert('Comment post unsuccessful.')}})}else{alert('Please type your comment in the box provided.')}return false});$('.image-show').mouseover(function(){$('.p-image').hide();$('#'+$(this).get(0).id+'-lg').fadeIn()});$("#preview-dialog").dialog({bgiframe:true,autoOpen:false,width:500,height:530,draggable:false,modal:true})},newsletterFields:function(){$("select[name='list_id']").change(function(){var b=$(this);$.post('/xml_http_req/custom_fields',{l:b.val()},function(a){$('#newsletterFields').html(a.documentElement.firstChild.nodeValue)})})},vmjMenu:function(){$.post('/xml_http_req/vmj_menu',{},function(a){$('#vmj-menu').html(a.documentElement.firstChild.nodeValue);$('#vmjsrcfld').addClass('vmj-search-off');$('#vmjsrcfld').val('Enter a word or phrase...');$('#vmjsrcfld').blur(function(){if($(this).val()==''){$(this).val('Enter a word or phrase...').addClass('vmj-search-off')}});$('#vmjsrcfld').focus(function(){if($(this).val()=='Enter a word or phrase...'){$(this).val('')}$(this).removeClass('vmj-search-off')});$('#vmjsrcf').submit(function(){if($('#vmjsrcfld').val()==''||$('#vmjsrcfld').val()=='Enter a word or phrase...'){return false}else{return true}})})},previewImg:function(f,i){var i=typeof(i)!='undefined'?i:'';var a='';var b='';if(i!=''){a='/uploads/images/'+i;b='<br />Click image to enlarge'}$('#preview-dialog').html('<div style="text-align:center;"><a href="'+a+'" target="_blank"><img src="'+f+'" /></a>'+b+'</div>');$('#preview-dialog').dialog('open')}};$(document).ready(function(){Pyra.vmjMenu()});