﻿$(document).ready(function(){
	var bodyClass = $('body').attr('class');
	if ((bodyClass != 'order_template') && (bodyClass != 'otzyvy_template')){
		disableSelection(document.body);
		}
	Social();

	// Setting Sidebar height
	var sidebarHeight = $('.content').css('height');
	$('.sidebar-inner').height(sidebarHeight);	
	
	//Gallery
	$('#gallery').find('a').attr('rel', 'shadowbox;width=500;height=273');
	Shadowbox.init({
		displayCounter: false,
		fadeDuration: 0.1,
		overlayOpacity: 0.4
	});
		
	$('table.tab tr:first-child').css('background','#E1EFF8');
	$('table.tab tr:nth-child(2n+1)').css('background','#F1F7FB');
		

	if( $.browser.opera ){
		$('#gallery img').wrap('<div class="opera" />');
		$('#gallery img').imgr({radius:"5px"}); 
  		$('.content img').imgr({radius:"10px"}); 
	}


}); 

//var maxWidth = 300;    
//if ( $('SELECTOR').width() > maxWidth ) $('SELECTOR').width(maxWidth);
//just for IE6
//if (jQuery.browser.msie) { if(parseInt(jQuery.browser.version) == 6) { etc


function Social() {
	new Ya.share({
        element: 'ya_share1',
            elementStyle: {
                'type': 'button',
                'quickServices': ['yaru', 'vkontakte', 'odnoklassniki', 'facebook', 'twitter', 'moimir', 'lj']
            },
            popupStyle: {
                blocks: {
                    'Поделитесь с друзьями!': ['yaru', 'vkontakte', 'odnoklassniki', 'facebook', 'twitter', 'lj', 'moikrug', 'moimir']
                },
            copyPasteField: true
            }
});
};

function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none"
else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
target.style.cursor = "default"
}

var headID = document.getElementsByTagName("head")[0];         
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = '/js/shadowbox/shadowbox.js';
headID.appendChild(newScript);

var headID = document.getElementsByTagName("head")[0];         
var cssNode = document.createElement('link');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.href = '/js/shadowbox/shadowbox.css';
cssNode.media = 'screen';
headID.appendChild(cssNode);


var headID = document.getElementsByTagName("head")[0];         
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = '/js/jquery.imgr.min.js';
headID.appendChild(newScript);
