;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

function updateTips(object,text)
{object.text(text).effect("highlight",{color:"#eee"},1500);}
function checkLength(o,n,min,max,tips){if(o.attr('value').length>max||o.attr('value').length<min){o.addClass('ui-state-error');$(tips).tips({text:"Length of "+n+" must be between "+min+" and "+max+"."});return false;}else{return true;}}
function checkDigit(o,n,tips){if(o.attr('value').length>0){return true;}else{$(tips).tips({text:n});return false;}}
function prepareUrl(url)
{var d=new Date();var result='';if(url.substring(url.length-1)=='/'){result=url+d.getTime();}else{result=url+'/'+d.getTime();}
return result;}
function checkRegexp(o,regexp,n,tips){if(!(regexp.test(o.val()))){o.addClass('ui-state-error');$(tips).tips({text:n});return false;}else{return true;}}
function lowerlights(value){if(value=="true"){var body=$('body');$('.vp-body').css('background','#333333');$('#menu').css('visibility','hidden');$('#content').css('visibility','hidden');if($('.shadow_wrapper').length){$('.shadow_wrapper').show();}else{var div=jQuery('<div />');$(div).addClass('shadow_wrapper');$(body).append(div);}}else{$('.shadow_wrapper').hide();$('.vp-body').css('background','transparent');$('#menu').css('visibility','visible');$('#content').css('visibility','visible');}}
var popUpObject={Id:'',Url:'',Scene:''};function popFlashModule(timeelapsed){if(!popUpObject.Id||!popUpObject.Url){return false;}
var res;if(timeelapsed!=undefined){var time=timeelapsed.substr(timeelapsed.indexOf(':')+1);var stream=timeelapsed.substr(0,timeelapsed.indexOf(':'));res=openWindow(presets.base_url+popUpObject.Url+popUpObject.Id+'/'+stream+'/'+time+'/'+popUpObject.Scene,'winflash','height='+screen.height+', width='+screen.width+',fullscreen=yes,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');}else{res=openWindow(presets.base_url+popUpObject.Url+popUpObject.Id+'/'+popUpObject.Scene,'winflash','height='+screen.height+', width='+screen.width+',fullscreen=yes,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');}
return res;}
windowChat=function()
{if(!popUpObject.Id){return false;}
return openWindow(presets.base_url+'hdcam/chat_pop_up/'+popUpObject.Id,'win','height=550,width=630,fullscreen=yes,'+'scrollbars=no,resizable=yes,toolbar=no,'+'directories=no,location=no,menubar=no,status=no,left=0,top=0');};function openWindow(url,name,props){return!openWindowOpener(url,name,props).closed;}
function openWindowOpener(url,name,props){if(false){var windowRef=window.open("",name,props);windowRef.close();}
var windowRef=window.open(url,name,props);if(windowRef){if(!windowRef.opener){windowRef.opener=self;}
windowRef.focus();}
return windowRef}
function change_credits(credits)
{$('#credits_count').html(credits);return true;}
function refresh_user()
{$.ajax({url:presets.base_url+'account/refresh_user_ajax/',type:"post",dataType:"json"});return true;}
jQuery.fn.tips=function(o){var cfg={text:'',effect:false,params:{},time:0};jQuery.extend(cfg,o);this.each(function(){$(this).text(cfg.text);if(cfg.effect){$(this).effect(cfg.effect,cfg.params,cfg.time);}});};function reset_form(class_name)
{var items=$("#content .sidebar ."+class_name+" .jquery-selectbox-item.item-0");$(items).each(function(){var thisListElement=jQuery(this);var thisReplacment=thisListElement.parents('.jquery-selectbox');var thisIndex=thisListElement[0].className.split(' ');for(k1 in thisIndex){if(/^item-[0-9]+$/.test(thisIndex[k1])){thisIndex=parseInt(thisIndex[k1].replace('item-',''),10);break;}}
var thisValue=thisListElement[0].className.split(' ');for(k1 in thisValue){if(/^value-.+$/.test(thisValue[k1])){thisValue=thisValue[k1].replace('value-','');break;}}
thisReplacment.find('.jquery-selectbox-currentItem').text(thisListElement.text());thisReplacment.find('select').val(thisValue);});return false;}
function showFlashData(type,message,duration)
{var class_name,dialog_title;switch(type){case'success':class_name='msg-success';dialog_title='Info';break;case'error':class_name='msg-error';dialog_title='Error'
break;default:class_name:'msg-success';dialog_title='Info';break;}
var dialog=$('#'+class_name+'-dialog');dialog.dialog('destroy');dialog.attr('title',dialog_title);dialog.children('.msg-content').html(message);dialog.dialog({modal:true,draggable:false,resizable:false,buttons:{Ok:function(){$(this).dialog('close');}}});}
function bookmark_me(entity,id)
{$.ajax({url:presets.base_url+'account/bookmark_ajax/',type:"post",data:{entity_id:id,entity:entity},dataType:"json",success:function(data){if(data.success){showFlashData('success',data.message,5000);}else{showFlashData('error',data.message,5000);}}});}
function remind_me(entity,id)
{$.ajax({url:presets.base_url+'account/reminder_ajax/',type:"post",data:{entity_id:id,entity:entity},dataType:"json",success:function(data){if(data.success){showFlashData('success',data.message,5000);}else{showFlashData('error',data.message,5000);}}});}
function buy_product(entity,id)
{if(confirm('Are you sure you want to buy this?')){$.ajax({url:presets.base_url+'account/buy_product_ajax/',type:"post",data:{entity_id:id,entity:entity},dataType:"json",success:function(data){if(data.success){showFlashData('success',data.message,2000);setTimeout(function(){location.reload();},3000);}else{showFlashData('error',data.message,5000);}}});}else{return false;}}
jQuery.fn.extend({blinkText:function(){this.each(function(){var temp_text=$(this).attr('value');$(this).focus(function(){if($(this).attr('value')==temp_text)
{$(this).empty();$(this).attr('value','');}});$(this).blur(function(){if($(this).attr('value')=='')
{$(this).attr('value',temp_text);}});});}});jQuery.fn.rollOverCollection=function(o){var cfg={pathes:{},timeout:1000,className:'hightlight'};jQuery.extend(cfg,o);var timer;function change(o){if(($(o).data('num'))==undefined){$(o).attr('src',$(o).data('path')[0]);$(o).data('num',0);}else{var num=(parseInt($(o).data('num'))+1);if(num==5)num=0;$(o).attr('src',$(o).data('path')[num]);$(o).data('num',num);}
var f=function(){change(o);};timer=setTimeout(f,900);}
function stop(o)
{clearTimeout(timer);$(o).attr('src',$(o).data('original'));$(o).data('num',0);}
for(var i=0;i<this.length;i++){$(this[i]).data('path',cfg.pathes[i]);$(this[i]).data('original',cfg.pathes[i][0]);}
this.each(function(){$(this).hover(function(){$(this).addClass(cfg.className);change($(this));},function(){$(this).removeClass(cfg.className);stop($(this));});});};selectHashCombo=function(url,selector){var params=url.replace('#','').match(/((?:[^\/]+)\/(?:[^\/]+)){0,}[\/]{0,}/g);$('select',selector).val('').trigger('change');$.each(params,function(index,item){if(item==''){return;}
var split=item.split('/');if(split.length<2){return;}
var entity=split[0];var value=split[1];if(!entity){return;}
if($('#'+entity).length){$('#'+entity).val(value).trigger('change');}});};proccess_hash_search=function(url)
{var array=url.split('#');var hash=(typeof(array[1])!='undefined')?array[1]:'';if(hash==''&&typeof(arguments[1])!='undefined'){array=url.split(arguments[1]);hash=(typeof(array[1])!='undefined')?array[1]:'';}
return hash;};Date.prototype.fromMysql=function(string){var parts=String(string).split(/[- :]/);this.setFullYear(parts[0]);this.setMonth(parts[1]-1);this.setDate(parts[2]);this.setHours(parts[3]);this.setMinutes(parts[4]);this.setSeconds(parts[5]);this.setMilliseconds(0);return this;};

jQuery.extend({historyCurrentHash:undefined,historyCallback:undefined,historyInit:function(callback){jQuery.historyCallback=callback;var current_hash=location.hash;jQuery.historyCurrentHash=current_hash;if(jQuery.browser.msie){if(jQuery.historyCurrentHash==''){jQuery.historyCurrentHash='#';}
$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentWindow.document;iframe.open();iframe.close();iframe.location.hash=current_hash;}
else if($.browser.safari){jQuery.historyBackStack=[];jQuery.historyBackStack.length=history.length;jQuery.historyForwardStack=[];jQuery.isFirst=true;}
jQuery.historyCallback(current_hash.replace(/^#/,''));setInterval(jQuery.historyCheck,100);},historyAddHistory:function(hash){jQuery.historyBackStack.push(hash);jQuery.historyForwardStack.length=0;this.isFirst=true;},historyCheck:function(){if(jQuery.browser.msie){var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentDocument||ihistory.contentWindow.document;var current_hash=window.location.hash;if(current_hash.indexOf('#')!==0){current_hash='#'+current_hash;}
if(current_hash!=jQuery.historyCurrentHash){location.hash=current_hash;jQuery.historyCurrentHash=current_hash;jQuery.historyCallback(current_hash.replace(/^#/,''));}}else if($.browser.safariz){if(!jQuery.dontCheck){var historyDelta=history.length-jQuery.historyBackStack.length;if(historyDelta){jQuery.isFirst=false;if(historyDelta<0){for(var i=0;i<Math.abs(historyDelta);i++)jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop());}else{for(var i=0;i<historyDelta;i++)jQuery.historyBackStack.push(jQuery.historyForwardStack.shift());}
var cachedHash=jQuery.historyBackStack[jQuery.historyBackStack.length-1];if(cachedHash!=undefined){jQuery.historyCurrentHash=location.hash;jQuery.historyCallback(cachedHash);}}else if(jQuery.historyBackStack[jQuery.historyBackStack.length-1]==undefined&&!jQuery.isFirst){if(document.URL.indexOf('#')>=0){jQuery.historyCallback(document.URL.split('#')[1]);}else{var current_hash=location.hash;jQuery.historyCallback('');}
jQuery.isFirst=true;}}}else{var current_hash=location.hash;if(current_hash!=jQuery.historyCurrentHash){jQuery.historyCurrentHash=current_hash;jQuery.historyCallback(current_hash.replace(/^#/,''));}}},historyLoad:function(hash){var newhash;if(jQuery.browser.safari){newhash=hash;}
else{newhash='#'+hash;location.hash=newhash;}
jQuery.historyCurrentHash=newhash;if(jQuery.browser.msie){var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentWindow.document;iframe.open();iframe.close();iframe.location.hash=newhash;jQuery.historyCallback(hash);}
else if(jQuery.browser.safari){jQuery.dontCheck=true;this.historyAddHistory(hash);var fn=function(){jQuery.dontCheck=false;};window.setTimeout(fn,200);jQuery.historyCallback(hash);location.hash=newhash;}
else{jQuery.historyCallback(hash);}}});
