$.tabs=function(selector,start){$(selector).each(function(i,element){$($(element).attr('rel')).css('display','none');$(element).click(function(){$(selector).each(function(i,element){$(element).removeClass('selected');$($(element).attr('rel')).css('display','none');});$(this).addClass('selected');$($(this).attr('rel')).css('display','block');});});if(!start){start=$(selector+':first').attr('rel');}$(selector+'[rel=\''+start+'\']').trigger('click');};var JSonData=ConstJS.constants;function checkname()
{var str=document.getElementById('first_name').value;var filter=/^[А-ЯA-Z]{2,}( +)?([А-ЯA-Z]{2,})?( +)?$/i;if(filter.test(str)){document.getElementById('name_div').style.visibility="hidden";document.getElementById('name_pic').style.visibility="visible";}else{document.getElementById('name_pic').style.visibility="hidden";document.getElementById('name_div').style.visibility="visible";}}
function checksurname()
{var str=document.getElementById('last_name').value;var filter=/^[А-ЯA-Z]{2,}( +)?([А-ЯA-Z]{2,})?( +)?$/i;if(filter.test(str)){document.getElementById('surname_div').style.visibility="hidden";document.getElementById('surname_pic').style.visibility="visible";}else{document.getElementById('surname_pic').style.visibility="hidden";document.getElementById('surname_div').style.visibility="visible";}}
function checkmail()
{var str=document.getElementById('email').value;var filter=/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/;if(filter.test(str)){document.getElementById('mail_div').style.visibility="hidden";document.getElementById('mail_pic').style.visibility="visible";}else{document.getElementById('mail_pic').style.visibility="hidden";document.getElementById('mail_div').style.visibility="visible";}}
function checkphone()
{var str=document.getElementById('phone').value;var filter=/^(?:8|\+7)? ?\(\d{1,5}\)? ?\d{1,5}\-\d{2}\-\d{2}$/;if(str!=""){document.getElementById('phone_div').style.visibility="hidden";document.getElementById('phone_pic').style.visibility="visible";}else{document.getElementById('phone_pic').style.visibility="hidden";document.getElementById('phone_div').style.visibility="visible";}}
function open_window(link,w,h)
{var win="width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";newWin=window.open(link,'newWin',win);newWin.focus();}
function validate_custinfo()
{var strFName=document.getElementById('first_name').value;var filterFName=/^[А-ЯA-Z]{2,}( +)?([А-ЯA-Z]{2,})?( +)?$/i;if(!filterFName.test(strFName))
{alert(JSonData.ERROR_INPUT_NAME);return false;}
var strSName=document.getElementById('last_name').value;var filterSName=/^[А-ЯA-Z]{2,}( +)?([А-ЯA-Z]{2,})?( +)?$/i;if(!filterSName.test(strSName))
{alert(JSonData.ERROR_INPUT_NAME);return false;}
var strEmail=document.getElementById('email').value;var filterEmail=/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/;if(!filterEmail.test(strEmail))
{alert(JSonData.ERROR_INPUT_EMAIL);return false;}
var strPhone=document.getElementById('phone').value;var filterPhone=/^(?:8|\+7)? ?\(\d{1,5}\)? ?\d{1,5}\-\d{2}\-\d{2}$/;if(str="")
{alert(JSonData.ERROR_INPUT_PHONE);return false;}
return true;}
function checkSubmit(){if(document.getElementById("idto").value!="")return true;else
{alert("Введите номер телефона в формате 9059103456");return false;}}
function moduleSearch()
{location="./index.php?searchstring="+$('#mod_search_searchword').attr('value');}
function cart_update(obect)
{var array_input=document.getElementsByTagName('input');for(var i=0;i<array_input.length;i++)
{if((array_input[i].name.split('_')[1])=='instock')
{id=array_input[i].name.split('_')[2];if((Math.round(array_input[i].value*100)/100)<(Math.round(document.getElementById('count_'+id).value*100)/100))
{alert('Перевышено максимально возможное количество для '+document.getElementById('name'+id).innerHTML);return false;}}}
$('#'+obect).submit();}
function currencyFormat(num,dec){num=Math.round(num/dec)*dec;num=new Number(num).toFixed(2);var s=0;var str='';for(var i=num.toString().length-1;i>=0;i--){s++;str=num.toString().charAt(i)+str;if(num.toString().charAt(i)=='.')s=0;if(s>0&&!(s%3))str=" "+str;}
return str;}
function googleTranslateElementInit()
{new google.translate.TranslateElement({pageLanguage:json_const.PAGE_LANG,includedLanguages:'en, ru'},'google_translate_element');}
if(document.getElementsByClassName){getElementsByClass=function(classList,node){return(node||document).getElementsByClassName(classList)}}else{getElementsByClass=function(classList,node){var node=node||document,list=node.getElementsByTagName('*'),length=list.length,classArray=classList.split(/\s+/),classes=classArray.length,result=[],i,j
for(i=0;i<length;i++){for(j=0;j<classes;j++){if(list[i].className.search('\\b'+classArray[j]+'\\b')!=-1){result.push(list[i])
break}}}
return result}}
$(document).ready(function(){$('.ajaxcart').click(function(){var curid=this.id.split('_')[1];var option='';var table=document.getElementById('products');var new_priceid="newprice"+curid;var countp='count_'+curid;if(document.getElementById(countp))$kol=document.getElementById(countp).value;else $kol=1;var new_price=document.getElementById(new_priceid).value;var array_options=document.getElementsByTagName('select');if(new_price)new_price=new_price.replace(' ','');else new_price='';for(var oi=0;oi<array_options.length;oi++)
{if((array_options[oi].name.split('_')[2])==curid)
{if(oi==0)
option=array_options[oi].name.split('_')[3]+':'+array_options[oi].value.split(':')[0];else option=option+','+array_options[oi].name.split('_')[3]+':'+array_options[oi].value.split(':')[0];}}
poststr="shopping_cart=yes&add2cart="+curid+"&type=ajax&kol="+$kol+"&opt="+option+"&newprice="+new_price;$.ajax({type:"GET",url:"./includes/shopping_cart.php",data:poststr,success:function(response)
{if(response==-1){alert('Перевышено максимально возможное количество данного товара');return false;}
var return_data=eval("("+response+")");$('#sci').text(return_data.info.count);$('#scs').text(return_data.info.cost);var image=$('#dp'+curid).offset();var cart=$('#module_cart').offset();$('#dp'+curid).before('<img src="'+$('#dp'+curid).attr('src')+'" id="temp" style="position: absolute; top: '+image.top+'px; left: '+image.left+'px;" />');params={top:cart.top+'px',left:cart.left+'px',opacity:0.0,width:$('#module_cart').width(),heigth:$('#module_cart').height()};$('#temp').animate(params,'slow',false,function(){$('#temp').remove();});}});return false;});$(".carouselDiv .jCarouselLite").jCarouselLite({auto:JSonData.CONF_HITS_FRIQ,speed:JSonData.CONF_HITS_SPEED,vertical:true,visible:JSonData.CONF_SCROLL_HITS,easing:"easeinout"});var fadeTime=2000*(JSonData.CONF_HITS_FRIQ/10000);var i=$('.slide').length;var x=0;showSlide();function showSlide(){curSlide="#slide"+x;if(x==0){prevSlide="#slide"+(i-1);}else{prevSlide="#slide"+(x-1);}$(prevSlide).fadeOut(fadeTime,function(){$(curSlide).fadeIn(fadeTime);if(x==(i-1)){x=0;}else{x++;}});setTimeout(showSlide,JSonData.CONF_HITS_FRIQ);}
if(JSonData.REVIEW_SAVED!=1){$.tabs('.tabs a');}else{$.tabs('.tabs a','#tab_review');}
$('#mod_search_searchword').keydown(function(e){if(e.keyCode==13){moduleSearch();}});if(document.getElementById('tag'))
{var rnumber=Math.floor(Math.random()*9999999);var so=new SWFObject("./core/tagcloud.swf?r="+rnumber,"tagcloudflash","160","160","9","#ffffff");so.addParam("allowScriptAccess","always");so.addParam("wmode","transparent");so.addVariable("tcolor","0x565656");so.addVariable("tspeed","150");so.addVariable("distr","true");so.addVariable("mode","tags");so.addVariable("tagcloud",JSonData.TAGS_CLOUD);so.write("wpcumuluscontent");}});$(document).ready(function(){$("a.thickbox").fancybox();$("a[rel=example_group]").fancybox({'transitionIn':'none','transitionOut':'none','titlePosition':'over','titleFormat':function(title,currentArray,currentIndex,currentOpts){return'<span id="fancybox-title-over">Image '+(currentIndex+1)+' / '+currentArray.length+(title.length?' &nbsp; '+title:'')+'</span>';}});$("a[rel=example_group1]").fancybox({'transitionIn':'none','transitionOut':'none','titlePosition':'over','titleFormat':function(title,currentArray,currentIndex,currentOpts){return'<span id="fancybox-title-over">Image '+(currentIndex+1)+' / '+currentArray.length+(title.length?' &nbsp; '+title:'')+'</span>';}});});$(document).ready(function(){$("#poll").submit(formProcess);if($("#poll-results").length>0){animateResults();}
if(document.getElementById('idvote'))
{idvote=document.getElementById('idvote').value;if($.cookie('vote_id_'+idvote)){$("#poll-container").empty();votedID=$.cookie('vote_id_'+idvote);$.getJSON("poll.php?vote=none",loadResults);}}});function formProcess(event){event.preventDefault();var id=$("input[@name='poll']:checked").attr("value");id=id.replace("opt",'');idvote=document.getElementById('idvote').value;$("#poll-container").fadeOut("slow",function(){$(this).empty();votedID=id;$.getJSON("poll.php?vote="+id+'&idvote='+idvote,loadResults);$.cookie('vote_id_'+idvote,id,{expires:365,path:'/'});});}
function animateResults(){$("#poll-results div").each(function(){var percentage=$(this).next().text();$(this).css({width:"0%"}).animate({width:percentage},'slow');});}
function loadResults(data){var total_votes=0;var percent;for(id in data){total_votes=total_votes+parseInt(data[id][OPT_VOTES]);}
var results_html="<div id='poll-results'>\n<dl class='graph'>\n";for(id in data){percent=0;if(data[id][OPT_VOTES]>0)
percent=Math.round((parseInt(data[id][OPT_VOTES])/parseInt(total_votes))*100);if(data[id][OPT_ID]!==votedID){results_html=results_html+"<dd  style='float:left;' class='bar-container'><div id='bar"+data[id][OPT_ID]+"'style='width:0%; float:left; '><nobr><b>"+data[id][OPT_TITLE]+"</b></nobr></div><strong>"+percent+"%</strong></dd>\n";}else{results_html=results_html+"<dd class='bar-container' style='float:left;'><div id='bar"+data[id][OPT_ID]+"'style='width:0%;background-color:#FD5300; float:left;'><nobr><b>"+data[id][OPT_TITLE]+"</b></nobr></div><strong>"+percent+"%</strong></dd>\n";}}
results_html=results_html+"</dl><p style='clear: both;'>Total Votes: "+total_votes+"</p></div>\n";$("#poll-container").append(results_html).fadeIn("slow",function(){animateResults();});}
if((typeof LOGINZA=="undefined")||!LOGINZA){var LOGINZA={'loaded':false,'token_url':null,'selected_provider':null,'providers_set':null,'service_host':'http://loginza.ru','lang':null,'ajax':false,'callback':null,'hash':''};}
LOGINZA.show=function(){LOGINZA.selected_provider=LOGINZA.getQueryStringValue(this,'provider');LOGINZA.providers_set=LOGINZA.getQueryStringValue(this,'providers_set');LOGINZA.token_url=LOGINZA.getQueryStringValue(this,'token_url');LOGINZA.lang=LOGINZA.getQueryStringValue(this,'lang');if(!LOGINZA.loaded){var cldDiv=document.createElement("div");cldDiv.id='loginza_auth_form';cldDiv.style.overflow='visible';cldDiv.style.backgroundColor='transparent';cldDiv.style.zIndex='10000';cldDiv.style.position='fixed';cldDiv.style.display='block';cldDiv.style.top='0px';cldDiv.style.left='0px';cldDiv.style.textAlign='center';cldDiv.style.height='878px';cldDiv.style.width='1247px';cldDiv.style.paddingTop='125px';cldDiv.style.backgroundImage='url('+LOGINZA.service_host+'/img/widget/overlay.png)';var cntDiv=document.createElement("div");cntDiv.style.position='relative';cntDiv.style.display='inline';cntDiv.style.overflow='visible';var img=document.createElement("img");img.onclick=LOGINZA.close;img.style.position='relative';img.style.left='348px';img.style.top='-332px';img.style.cursor='hand';img.style.width='7px';img.style.height='7px';img.style.border='0';img.alt='X';img.title='Close';img.src=LOGINZA.service_host+'/img/widget/close.gif';var iframe=document.createElement("iframe");iframe.id='loginza_main_ifr';iframe.width='359';iframe.height='350';iframe.scrolling='no';iframe.frameBorder='0';iframe.src="javascript:'<html><body style=background-color:transparent><h1>Loading...</h1></body></html>'";cntDiv.appendChild(img);cldDiv.appendChild(cntDiv);cldDiv.appendChild(iframe);try{cldDiv.style.paddingTop=(window.innerHeight-350)/2+'px';}catch(e){cldDiv.style.paddingTop='100px';}
cldDiv.style.paddingLeft=0;cldDiv.style.height='2000px';cldDiv.style.width=document.body.clientWidth+50+'px';document.body.appendChild(cldDiv);LOGINZA.loaded=true;if(LOGINZA.ajax){setInterval(LOGINZA.hashParser,500);}}
if(!LOGINZA.token_url){alert('Error token_url value!');}else{document.getElementById('loginza_main_ifr').setAttribute('src',LOGINZA.service_host+'/api/widget.php?overlay=true&w='+document.body.clientWidth+'&token_url='+encodeURIComponent(LOGINZA.token_url)+'&provider='+encodeURIComponent(LOGINZA.selected_provider)+'&providers_set='+encodeURIComponent(LOGINZA.providers_set)+'&lang='+encodeURIComponent(LOGINZA.lang)+'&ajax='+(LOGINZA.ajax?'true':'false'));}
document.getElementById('loginza_auth_form').style.display='';return false;}
LOGINZA.close=function(){document.getElementById('loginza_auth_form').style.display='none';}
LOGINZA.resize=function(){var frm=document.getElementById('loginza_auth_form');if(frm){frm.style.width=document.body.clientWidth+50+'px';try{frm.style.paddingTop=(window.innerHeight-350)/2+'px';}catch(e){frm.style.paddingTop='100px';}}}
LOGINZA.getQueryStringValue=function(link,key){var url_str=link.href;var match=null;var query_str=url_str.match(/^[^?]*(?:\?([^#]*))?(?:$|#.*$)/)[1]
var _query_regex=new RegExp("([^=]+)=([^&]*)&?","g");while((match=_query_regex.exec(query_str))!=null)
{if(decodeURIComponent(match[1])==key){return decodeURIComponent(match[2]);}}
return null;}
LOGINZA.findClass=function(str,node){if(document.getElementsByClassName)return(node||document).getElementsByClassName(str);else{var node=node||document,list=node.getElementsByTagName('*'),length=list.length,Class=str.split(/\s+/),classes=Class.length,array=[],i,j,key;for(i=0;i<length;i++){key=true;for(j=0;j<classes;j++)if(list[i].className.search('\\b'+Class[j]+'\\b')==-1)key=false;if(key)array.push(list[i]);}
return array;}}
LOGINZA.addEvent=function(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,false);}else if(obj.attachEvent){obj.attachEvent("on"+type,fn);}else{obj["on"+type]=fn;}}
LOGINZA.init=function(){if(document.getElementById('loginza')&&document.getElementById('loginza').href!=undefined){document.getElementById('loginza').onclick=LOGINZA.show;}
var i,list=LOGINZA.findClass('loginza'),length=list.length;for(i=0;i<length;i++){if(list[i].href!=undefined){list[i].onclick=LOGINZA.show;}}
LOGINZA.addEvent(window,'resize',LOGINZA.resize);LOGINZA.addEvent(document,'keydown',function(e){e=e||window.event;if(e.keyCode==27){LOGINZA.close();}
return true;});}
LOGINZA.widget=function(){var iframeNode=document.getElementById('loginza_main_ifr');if(iframeNode.contentDocument)return iframeNode.contentDocument
if(iframeNode.contentWindow)return iframeNode.contentWindow.document
return iframeNode.document}
LOGINZA.hashParser=function(){var func,param;var hash=LOGINZA.widget().location.hash.substr(1);var commands=hash.split(';');var callbacks=[['token:','getToken']];if(hash!=LOGINZA.hash){for(var k=0;k<commands.length;k++){for(var i=0;i<callbacks.length;i++){func=callbacks[i][1];param=commands[k].substr(callbacks[i][0].length);if(commands[k].indexOf(callbacks[i][0])===0){LOGINZA[func](param);}}}
LOGINZA.hash=hash;}}
LOGINZA.getToken=function(token){LOGINZA.close();LOGINZA.callback(token);}
LOGINZA.addEvent(window,'load',LOGINZA.init);
