//   Антиспам
//==============
String.prototype.printAddr = function ($hamper,$prefix,$postfix,$face){
	$hamper=$prefix+"@"+this+($postfix || '')
	document.write(($face||$hamper));
}


String.prototype.printAddrName = function ($hamper,$prefix,$postfix,$face, $name){
	$hamper="<a href='mailto:"+$prefix+"@"+this+	($postfix || '')+"'>"+$hamper+"</a>"
	document.write(($face||$hamper));
}


//   Таймер закрытия окна
//==============

function close_timer() {
	var $timeID = "close_time";
	var $e = document.getElementById($timeID);
	var $cTicks = parseInt($e.innerHTML);
	var $timer = setInterval(function(){
		if ( $cTicks ) {$e.innerHTML = --$cTicks;}
		else { 
			clearInterval($timer);
			window.close();
			}
		}, 1000);
	}

//  Галерея
//==============

function initGallery() {
	var h = $("h1.title").html();
	var th = $(".gallery").find("li a");
	
	$(th).attr("rel", "prettyPhoto[gallery]");
	$(th).each(function(i){
		//var t = h;
		var t = $(this).find('img').attr('alt') ? $(this).find('img').attr('alt') : h;
		$(this).attr("title", t);
	});	
	$(th).prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'dark_rounded', /* dark_rounded / dark_rounded / light_square / dark_rounded */
		callback: function(){}
	});
}




//  Попап
//==============

function initCf() {
	hrf = $('a.clssf').attr('href');
	$('a.clssf').attr("rel", "prettyPhoto[iframes]");
	$('a.clssf').attr("href", hrf+"?iframe=true&width=880&height=590");
	$('a.clssf').attr("title", "");

	$('a.clssf').prettyPhoto({
		allowresize: false, 
		showTitle: false,
		theme: 'dark_rounded'
		});
	}



function initPopup() {
/*
	var href = $(this).attr('href');
	var params = {};
		params.scrollbars = "yes";
		params.status = "yes";
		params.menubar = "yes";
		params.screenX=100; 
		params.screenY=100; 
		params.width = 850; 
		params.height = 600;

	var param_a = [];
	for (var name in params) {
		param_a.push(name + "=" + params[name]);
		}
	var param_str = param_a.join(',');
	var name = "popup";
	wnd = window.open(href, name, param_str);
	wnd.focus();
	//wnd = window.open(href,'contactWindow','width=600,height=550,toolbar=no,statusbar=no,menubar=no,scrollbars=yes,top=50,left=50');

	return false;
	})
		

	$('a.winclose').click(function() {
		window.close();
		return false;
	});
*/
}


function initPop() {
	$(".popup").each(function(i){
		var th = $(this);
		var hrf = th.attr('href');
		var par = th.attr('rel').split('|');
			var w = par[0] ? par[0] : '800';
			var h = par[1] ? par[1] : '600';

		th.attr("rel", "prettyPhoto[iframes]");
		th.attr("href", hrf + "?iframe=true&width=" + w + "&height=" + h + "");
		th.attr("title", "");

		th.prettyPhoto({
			allowresize: false, 
			showTitle: false,
			theme: 'light_square'
			});
	});

	$('a.winclose').click(function() {
		window.close();
		return false;
	});
}



/* initVideo
 */
	function initVideo(id) {
		var s1 = new SWFObject("/js/video/movie_player.swf","ply","384","288","8","#FFFFFF");
	//Global
		s1.addParam("allowfullscreen","true");
		s1.addParam("allowscriptaccess","always");
		s1.addParam("scale", "noscale");
		//s1.addParam("wmode", "transparent");
		s1.addParam("wmode", "opaque");
	//Skin
		s1.addVariable("skin","/js/video/skins/able.swf"); s1.addVariable("controlbar","over");
		//s1.addVariable("skin","/js/video/skins/vimeo.swf"); s1.addVariable("controlbar","over");
	//Colors
		s1.addVariable("backcolor","#130F0C"); //background color of the controlbar and playlist. This is white with the default skin. 
		s1.addVariable("frontcolor","#ffffff"); //color of all icons and texts in the controlbar and playlist. 
		s1.addVariable("lightcolor","#99CC00"); //color of an icon or text when you rollover it with the mouse. 
		s1.addVariable("screencolor","#EFEFEF"); //background color of the display.
	//Behaviour
		s1.addVariable("volume ","50");
	//File properties
		s1.addVariable("image","/netcat_files/Media/Video/"+id+".jpg");
		s1.addVariable("file","/netcat_files/Media/Video/"+id+".flv");
	//Поехали! (c)Гагарин
		s1.write(id);
	};










$(document).ready(function() {
	initGallery();
	initPop();
	initCf();

	var w = $(window).width();
	if (w>1100) {
		//$('.hots').css('width', '300px');
		$('.hots').css('margin-left', '7%');
		}
	if (w<1100) {
		$('div#logo').css('left', '12.5%');
		$('.mlddm ul li a').css('padding', '2px 10px');
		//$('.hots').css('margin-top', '-30px');
		}
	//IE сцуко
	// apply to all png images and to div#logo 
	//$('img[@src$=.png]').ifixpng(); 
});





	




