var PageIsLoaded = false;

function execute(page) {

	$(document).ready(function() {
							   
		//browsers
		if (CheckIE6()==true)window.location='ie6.php?lang='+SiteLanguage;
		//if (CheckIE()==true)loadjscssfile("page/css/browser.ie.css", "css");
		//if (CheckOpera()==true)loadjscssfile("page/css/browser.opera.css", "css");
		//if (CheckGecko()==true)loadjscssfile("page/css/browser.gecko.css", "css");
		
	
		if (page=='main')execute_main();
		if (page=='modal')execute_modal();
		if (page=='edit')execute_edit();
		
		PageIsLoaded = true;
	
	});	
}


function execute_main() {
	
	FBshareWidgets();
	//KeyCaptureInstall();
	SimpleDropDownMenu();
	Pagination();
	$('div.work_item_content_nav_zoomin').bind('click', function() {ZoomIn(this);});
	$('div.work_item_content_nav_zoomout').bind('click', function() {ZoomOut(this);});
	$('div.work_item_content_nav_imgreload').bind('click', function() {ImgReload(this);});
	$('div.work_item_content_nav_hinton').bind('click', function() {HintShow(this);});
	$('div.work_item_content_nav_hintoff').bind('click', function() {HintHide(this);});
	$("#search_input").autocomplete('search.php',{ 
		delay: 500 ,
		width: 214,
		autoFill: true,
		selectFirst: false,
		formatItem: function(row, i, max) {
			return row[0];
		},
		formatMatch: function(row, i, max) {
			return row[0];
		},
		formatResult: function(row) {
			return row[0];
		}
	});
	$("#search_input").result(function(){ 
		$("#search").submit(); 
	}); 
	CommentsJS();
	TooltipsDraw();

	//if ($('div.myworks_item_bar_count').length > 0) {$('div.myworks_item_bar_count').css("width",$('div.myworks_item_bar_count').attr('title')+"px").removeAttr('title');}
	//if ($('div.myworks_item_bar_comments').length > 0) {$('div.myworks_item_bar_comments').css("width","40px").removeAttr('title');}
	
	if ($('div.myworks_item_bar_count').length > 0) {$('div.myworks_item_bar_count').make_bar();}
	if ($('div.myworks_item_bar_comments').length > 0) {$('div.myworks_item_bar_comments').make_bar();}
	
	$('#body_top_search_butt').bind('click', function() {$('#search').submit();});
	$('#body_top_clear_butt').bind('click', function() {$('#search_input').val('');$('#search').submit();});
	
	$('#search_input').bind('keyup', function() {clearbutton_toogle();});
	
	$('#body_top_searchoptions_trigger').bind('click', function() {searchoptions_toogle()});
	$('#body_top_searchoptions_close').bind('click', function() {searchoptions_toogle()});

	clearbutton_toogle();
	
	if ($('#search_input').length > 0 && $('#search_input').val().length>0 && $('#search_no_results').length==0) {$('#body_top_searchinfo > strong').html("''"+$('#search_input').val()+"''");$('#body_top_searchinfo').slideDown(300);setTimeout(function(){$('#body_top_searchinfo').slideUp(500);}, 3000 );}
	
	if (typeof ShowInfo != 'undefined' && ShowInfo.length>0){ModalOpen(ShowInfoTitle,ShowInfo,440,115,false);}
	
	if (typeof MakeComment != 'undefined' && MakeComment.length>0){SetComment();}
	
	$("a.anchorLink").anchorAnimate();
   
	
	var isInIFrame = (window.location != window.parent.location) ? true : false;
	if (typeof userIsCorrectlyLogged != 'undefined' && userIsCorrectlyLogged==false && isInIFrame==false){$('body').empty();ModalOpen(ShowModalTitle,ShowModalLink+"&return="+ShowModalReturn,360,220,true);}
	if (typeof userIsCorrectlyLogged != 'undefined' && userIsCorrectlyLogged==false && isInIFrame==true){self.parent.ModalOpen(ShowModalTitle,ShowModalLink,360,220,true);}
	
	adblockerClean();
	
	if ($('div.fbconnect').length > 0) {$('div.fbconnect').bind('click', function() {connectFBinit();});}
	
	if (typeof NetworkShowAll != 'undefined' && NetworkShowAll.length>0) {
		$("div.body_foot_info").append('<div id="NetworkShowAll">'+NetworkShowAll+'</div><div id="NetworkShowShort" style="display:none">'+NetworkShowShort+'</div>');
		$('#NetworkShowAll').bind('click', function() {$('#networkads').html('<div class="networkads_waiter"></div>').css("height","auto");setNetworkAds(Network_Url);$('#NetworkShowAll').css("display","none");$('#NetworkShowShort').css("display","block");});
		$('#NetworkShowShort').bind('click', function() {$("#networkads").animate({height: "110px"}, 300 );$('#NetworkShowAll').css("display","block");$('#NetworkShowShort').css("display","none");});
	}
	
	if ($('div.work_item_content_data_youtubecontainer').length > 0) {
		$('div.work_item_content_data_youtubecontainer').bind('click', function() {
			YouTubeStart($(this));
		});
		$('div.work_item_content_data_youtubecontainer').bind('mouseenter', function() {
			$(this).children("img").animate({opacity: "0.9"}, 200 );
			if(CheckIE()==false) {$(this).children("div").children("table").animate({opacity: "0.8"}, 200 );}
		});
		$('div.work_item_content_data_youtubecontainer').bind('mouseleave', function() {
			$(this).children("img").animate({opacity: "0.6"}, 200 );
			if(CheckIE()==false) {$(this).children("div").children("table").animate({opacity: "1"}, 200 );}
		});
	}

}




function execute_modal() {
	Custom.init();
	InputFocus();
	$('form').attr('autocomplete', 'off');
	if ($('input.password_meter').length > 0) {$('input.password_meter').password_strength();}
	if ($('#username').length > 0) {$('#username').filter_input({regex:'[a-zA-Z0-9_]'});}
	$('#username').bind('paste', function (){var el = $(this);tmp_val = $(el).val();setTimeout(function() {$(el).val(tmp_val);}, 1);});
	if ($('#email').length > 0 && $('#email_hint').length > 0) {
		$('#email').filter_input({regex:'[a-zA-Z0-9_@.]'});
		$('#email').bind('focusout', function() {checkEmailAddress($(this));});
	}
	if($('textarea.textarea_counter').length > 0) {$('textarea.textarea_counter').bind('keyup', function() {limitChars($(this), 100);});}
	
	if (typeof ShowInfo != 'undefined' && ShowInfo.length>0){self.parent.ModalOpen(ShowInfoTitle,ShowInfo,440,115,false);}
	
	if (typeof userIsCorrectlyLogged != 'undefined' && userIsCorrectlyLogged==true){self.parent.location.reload();}
	
	ModalEscCaptureInstall();
	
	//if (typeof userIsCorrectlyLogged != 'undefined' && userIsCorrectlyLogged==false){self.parent.ModalOpen(ShowModalTitle,ShowModalLink,360,220,true);}
}



function setNetworkAds(url) {
	$('#networkads').load(url, function() {
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: $('#network').offset().top }, 300);
	});
}


function SetComment() {
	setTimeout(function(){ $('#comments-form-comment').focus() }, 300);$("html:not(:animated),body:not(:animated)").animate({ scrollTop: $(document).height() }, 300);
}


function CommentsJS() {
	$('div.rbox').unbind();
	$('div.rbox').bind('mouseenter', function() {CommentShowButtons(this);});
	$('div.rbox').bind('mouseleave', function() {CommentHideButtons(this);});
}

jQuery.fn.anchorAnimate = function() {

	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault();
			var locationHref = window.location.href;
			var elementClick = $(caller).attr("href");
			tmpid=elementClick.substring(1,elementClick.length);
			var destination = $("#"+tmpid).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 300, function() {
				window.location.hash = elementClick;
			});
		  	return false;
		})
	})
}



$.fn.make_bar = function() {
	this.each(function() {
		$(this).css("width",$(this).attr('title')+"px").removeAttr('title');
	});
}




function limitChars(obj, limit){
var text = obj.val(); 
var textlength = text.length;
if(textlength > limit){
	obj.val(text.substr(0,limit));
	return false;
	}else{
	$('div.textarea_info').html(limitCharsInfo + ': <strong>' + (limit - textlength) +'</strong>');
	return true;
	}
}
 
 
 

function searchoptions_toogle() {
	$('#body_top_searchoptions_trigger').toggleClass('body_top_searchoptions_trigger_on');
	$('#body_top_searchoptions').slideToggle(200);
}


function clearbutton_toogle() {
	if ($('#search_input').length > 0){
		if ($('#search_input').val().length>0) {
			$('#body_top_clear_butt').css("display","block");
			$('#body_top_clear_butt_inactive').css("display","none");
		}else{
			$('#body_top_clear_butt').css("display","none");
			$('#body_top_clear_butt_inactive').css("display","block");
		}
	}
}



function InputFocus() {
	$('input.activeinput').focus();
	$('input.modal_input').bind('focus', function() {
		this.select();
	});
}

function SearchString(str) {
	$('#search_input').val(str);
	$('#search').submit();	
	//self.location.href="?search="+str+"&authoronly";
}


function SimpleDropDownMenu() {

	$('#usermenu > .simpledropdownmenu_title').mouseenter(function() {
		$('.body_top_element').css("z-index","5000");
		$('#usermenu > .simpledropdownmenu_ul').slideDown(200);
	});
	
	$('#usermenu').mouseleave(function() {
		$('#usermenu > .simpledropdownmenu_ul').slideUp(200, function() {
			$('.body_top_element').css("z-index","1000");
		});
	});

	$('#langmenu > .simpledropdownmenu_title').mouseenter(function() {
		$('.body_top_element').css("z-index","5000");
		$('#langmenu > .simpledropdownmenu_ul').slideDown(200);
	});
	
	$('#langmenu').mouseleave(function() {
		$('#langmenu > .simpledropdownmenu_ul').slideUp(200, function() {
			$('.body_top_element').css("z-index","1000");
		});
	});
	
}

function KeyCaptureInstall() {
	if (CheckIE()==true){
		document.body.onkeydown = function() {KeyCapture(window.event)};
	}else{
		document.onkeydown = function(event) {KeyCapture(event)};
	}
}

function KeyCapture(e) {
	if (e.keyCode==39) {
		location.href='komiks.php?losowy='+Math.floor(Math.random()*101);
	}
	if (e.keyCode==37) {
		history.back();
	}
}


function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}

function checkEmailAddress(obj) {
	if (isValidEmailAddress(obj.val())==true){
		$('#email_hint').html(EmailAddressHint);
		$('#email_hint').removeClass('modal_hint modal_error').addClass('modal_hint');
	}else{
		$('#email_hint').html(EmailAddressIsWrong);
		$('#email_hint').removeClass('modal_hint modal_error').addClass('modal_error');
	}
}


function adblockerClean() {
    if ($('.emptyAdTest').height() == 0)$('.removableAd').remove();
}
























function YouTubeStart(obj) {
	tmp_id=obj.attr("id");
	tmp_ytid=obj.children("img").attr("id")
	obj.html("<div id='"+tmp_id+"'></div>").removeAttr("id").unbind();
	if (CheckChrome()==true) {tmpwmode="window"}else{tmpwmode="transparent"}
	var params = { allowScriptAccess: "always", wmode: tmpwmode, allowFullScreen: "true" };
	var atts = { id: tmp_id };
	swfobject.embedSWF("http://www.youtube.com/e/"+tmp_ytid+"?enablejsapi=1&playerapiid=js_"+tmp_id+"&autohide=1&fs=1&autoplay=1&iv_load_policy=3&rel=0&showinfo=0",tmp_id, "710", "370", "8", null, null, params, atts);
}

function onYouTubePlayerReady(playerId) {
	if(playerId == "js_youtubeplayer_1") {
		ytplayer_1 = document.getElementById("youtubeplayer_1");
		ytplayer_1.addEventListener("onStateChange", "onytplayerStateChange_1");
	}
	if(playerId == "js_youtubeplayer_2") {
		ytplayer_2 = document.getElementById("youtubeplayer_2");
		ytplayer_2.addEventListener("onStateChange", "onytplayerStateChange_2");
	}
	if(playerId == "js_youtubeplayer_3") {
		ytplayer_3 = document.getElementById("youtubeplayer_3");
		ytplayer_3.addEventListener("onStateChange", "onytplayerStateChange_3");
	}
	if(playerId == "js_youtubeplayer_4") {
		ytplayer_4 = document.getElementById("youtubeplayer_4");
		ytplayer_4.addEventListener("onStateChange", "onytplayerStateChange_4");
	}
	if(playerId == "js_youtubeplayer_5") {
		ytplayer_5 = document.getElementById("youtubeplayer_5");
		ytplayer_5.addEventListener("onStateChange", "onytplayerStateChange_5");
	}
}

function onytplayerStateChange_1(newState) {
	if (newState==2) {YouTubePlayerPausemode();}
	if (newState==1) {YouTubePlayerPlaymode(1);}
}

function onytplayerStateChange_2(newState) {
	if (newState==2) {YouTubePlayerPausemode();}
	if (newState==1) {YouTubePlayerPlaymode(2);}
}

function onytplayerStateChange_3(newState) {
	if (newState==2) {YouTubePlayerPausemode();}
	if (newState==1) {YouTubePlayerPlaymode(3);}
}

function onytplayerStateChange_4(newState) {
	if (newState==2) {YouTubePlayerPausemode();}
	if (newState==1) {YouTubePlayerPlaymode(5);}
}

function onytplayerStateChange_5(newState) {
	if (newState==2) {YouTubePlayerPausemode();}
	if (newState==1) {YouTubePlayerPlaymode(5);}
}

function YouTubePlayerPlaymode(x) {
	$('.body_top_element').css("z-index","1000");
	removeVideoBlocks();
	$(".videoblock_"+x).css("z-index","1002");
	$.blockUI({ 
		message: null, 
		overlayCSS: { backgroundColor: '#000' } 
	});
	$(".work_item_content_data_cornerleft").fadeOut();
	$(".work_item_content_data_cornerright").fadeOut();
	if (x==1)setTimeout(function(){window.document.youtubeplayer_1.focus();}, 500 );
	if (x==2)setTimeout(function(){window.document.youtubeplayer_2.focus();}, 500 );
	if (x==3)setTimeout(function(){window.document.youtubeplayer_3.focus();}, 500 );
	if (x==4)setTimeout(function(){window.document.youtubeplayer_4.focus();}, 500 );
	if (x==5)setTimeout(function(){window.document.youtubeplayer_5.focus();}, 500 );
}

function YouTubePlayerPausemode() {
	$.unblockUI();
	$(".work_item_content_data_cornerleft").fadeIn();
	$(".work_item_content_data_cornerright").fadeIn();
}

function removeVideoBlocks() {
	$(".videoblock_1").css("z-index","60");
	$(".videoblock_2").css("z-index","61");
	$(".videoblock_3").css("z-index","62");
	$(".videoblock_4").css("z-index","63");
	$(".videoblock_5").css("z-index","64");
}



















//fb

function FBshareWidgets() {
	$('.FBshare').each(function() {
		FBshareGetCount($(this),$(this).attr('url'));
		var FBshareStatus=false;
		$(this).children('div.button').bind('click',function(){
			ShareFacebook($(this).parent().attr('url'));
			if(FBshareStatus==false){
				$(this).parent().children('div.count').html(parseInt($(this).parent().children('div.count').html())+1);
				FBshareStatus=true;
			}
		});
	})
}

function FBshareGetCount(obj,url){
	$.getJSON('http://graph.facebook.com/?id='+url, function(data) {
		tmp_count=0;
		$.each(data, function(key, val) {
			if(key=="shares"){tmp_count=val;}
		});
		obj.append('<div class="count">'+tmp_count+'</div><div class="clr"></div>');
	});

}

var FBinitStatus=false;
function connectFBinit() {
/*	if ($("#fb-root").length > 0){connectFBlogincheck();}else{
		globalWaiter();
		$('body').append('<div id="fb-root"></div>');
		$.getScript(document.location.protocol + '//connect.facebook.net/'+SiteLanguage.substring(0,2)+'_'+SiteLanguage.substring(3,5)+'/all.js', function() {
			FB.init({appId: CustomFBappId, status: true, cookie: true, xfbml: true});
			connectFBlogincheck();
		});
	}*/
	if (FBinitStatus==false){FB.init({appId: CustomFBappId, status: true, cookie: true, xfbml: true});FBinitStatus=true;}
	globalWaiter();
	connectFBlogincheck();
}


function connectFBlogincheck() {
	FB.getLoginStatus(function(response) {
		if (response.status === 'connected') {
			dafungooLogin();
		} else {
			if ($("#FBLoginForm").length > 0){$("#FBLoginForm").remove();}
			$('body').append('<div id="FBLoginForm"><table style="width:100%"><tbody><tr><td class="ModalWindowTL notxt">&nbsp;</td><td class="ModalWindowTC">'+FacebookConnect+'<div onclick="$.unblockUI()" class="ModalWindowClose"></div>&nbsp;</td><td class="ModalWindowTR notxt">&nbsp;</td></tr></tbody></table><div style="padding:20px;color:#101010">'+FacebookConnectInfo+'<div class="modal_submit_1" id="FBLoginButton" style="margin-top:10px;margin-left:auto;margin-right:auto">'+FacebookConnectButton+'</div></div></div>');
			$('#FBLoginButton').bind('click', function() {connectFBlogin();});
			$.blockUI({ 
				message: $('#FBLoginForm'),
				fadeIn:  200,
				css: { 
					top:  ($(window).height() - (100+51)) /2 + 'px', 
					left: ($(window).width() - 350) /2 + 'px', 
					height: (100+51)+'px',
					width: 350+'px'
				},
				overlayCSS: {
					backgroundColor: '#333333',
					opacity: 0.3
				}
			});
		}
	});
}



function connectFBlogin() {
	FB.login(function(response) {
	  if (response.authResponse) {
		  $.unblockUI();
		  dafungooLogin();
	  } else {
		// user is not logged in
	  }
	}, {scope:'email'});
}

function dafungooLogin() {
	globalWaiter();
	$('body').append('<iframe src="index2.php?option=com_user&view=faceme&step=1" style="display:none"></iframe>');
}



function globalWaiter() {
$('body').append('<div id="global_waiter"></div>');
$.blockUI({ 
message: $('#global_waiter'),
fadeIn:  200,
css: { 
top:  ($(window).height() - 60) /2 + 'px', 
left: ($(window).width() - 110) /2 + 'px', 
height: 60+'px',
width: 110+'px'
},
overlayCSS: {
backgroundColor: '#333333',
opacity: 0.3
}
});
}


//functions ==========================================================================================================



function loadjscssfile(filename, filetype){
 if (filetype=="js"){
  var fileref=document.createElement('script');
  fileref.setAttribute("type","text/javascript");
  fileref.setAttribute("src", filename);
 }
 else if (filetype=="css"){
  var fileref=document.createElement("link");
  fileref.setAttribute("rel", "stylesheet");
  fileref.setAttribute("type", "text/css");
  fileref.setAttribute("href", filename);
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref);
}




//browsers

function CheckIE6(){
	var sAgent = navigator.userAgent.toLowerCase() ;
	if ( sAgent.indexOf("msie") != -1 && navigator.appVersion.indexOf("MSIE 7.")==-1 && navigator.appVersion.indexOf("MSIE 8.")==-1 && navigator.appVersion.indexOf("MSIE 9.")==-1 && navigator.appVersion.indexOf("MSIE 10.")==-1 && navigator.appVersion.indexOf("MSIE 11.")==-1){
		return true
	}else{
		return false
	}
}

function CheckIE(){
	var sAgent = navigator.userAgent.toLowerCase() ;
	if ( sAgent.indexOf("msie") != -1 && navigator.appVersion.indexOf("MSIE 5.")==-1 && navigator.appVersion.indexOf("MSIE 6.")==-1 ){
		return true
	}else{
		return false
	}
}

function CheckOpera(){
	var sAgent = navigator.userAgent.toLowerCase() ;
	if ( sAgent.indexOf("opera") != -1){
		return true
	}else{
		return false
	}
}

function CheckGecko(){
	var sAgent = navigator.userAgent.toLowerCase() ;
	if ( sAgent.indexOf("gecko") != -1){
		return true
	}else{
		return false
	}
}

function CheckFirefox(){
	var sAgent = navigator.userAgent.toLowerCase() ;
	if ( sAgent.indexOf("firefox") != -1){
		return true
	}else{
		return false
	}
}

function CheckChrome(){
	var sAgent = navigator.userAgent.toLowerCase() ;
	if ( sAgent.indexOf("chrome") != -1){
		return true
	}else{
		return false
	}
}






function windowRecalculateWidth(x) {
	if (CheckIE()==true){
		x=x+10;
	}
	if (CheckFirefox()==true){
		x=x+18;
	}
	
	if (CheckChrome()==true){
		x=x+16;
	}
	
	if (CheckOpera()==true){
		x=x+20;
	}
	
	if(x>window.screen.availWidth)x=window.screen.availWidth;

	return x;
}

function windowRecalculateHeight(y) {
	if (CheckIE()==true){
		y=y+86;
	}
	if (CheckFirefox()==true){
		y=y+100;
	}
	
	if (CheckChrome()==true){
		y=y+64;
	}
	
	if (CheckOpera()==true){
		y=y+60;
	}
	
	if(y>window.screen.availHeight)y=window.screen.availHeight;
	
	return y;
}






function ConfirmOpenUrl(url,txt){
	var r=confirm(txt);
	if (r==true){self.location.href=url;}
}



//modal

var ModalIsOpen=false;

function ModalEscCaptureInstall() {
	if (CheckIE()==true){
		document.body.onkeydown = function() {ModalEscCapture(window.event)};
	}else{
		document.onkeydown = function(event) {ModalEscCapture(event)};
	}
}

function ModalEscCapture(e) {
	if (e.keyCode==27) {
		if ($("body").hasClass("ModalWindow")) {
			parent.ModalClose();
		}else{
			ModalClose();
		}
	}
}

function ModalClose(title,url,modalwidth,modalheight,closebutt) {
	setTimeout(function() {$('#ModalWindow').empty();}, 199);
	$.unblockUI({ 
		fadeOut: 200,
		onUnblock: function(){
			$('#ModalWindow').remove();
			if ($('#global_waiter').length>0) $('#global_waiter').remove();
			ModalIsOpen=false;
			if (title) {
				ModalOpen(title,url,modalwidth,modalheight,closebutt);
			}
		} 
	});
}


function ModalOpen(title,url,modalwidth,modalheight,closebutt) {
	

	if (ModalIsOpen==true){
		ModalClose(title,url,modalwidth,modalheight,closebutt);
	}else{
	
	
	var tmp_closebutt="<div class='ModalWindowClose' onclick='ModalClose()'></div>";
	if (closebutt==false) {
		tmp_closebutt="";
	}else{
		ModalEscCaptureInstall();
	}
	$('body').append('<div id="ModalWindow"></div>');
	$('#ModalWindow').html("<table style='width:"+modalwidth+"px;height:"+(modalheight+51)+"px'><tr><td class='ModalWindowTL notxt'>&nbsp;</td><td class='ModalWindowTC'>"+title+tmp_closebutt+"&nbsp;</td><td class='ModalWindowTR notxt'>&nbsp;</td></tr><tr><td colspan='3' style='height:"+modalheight+"px' class='ModalWindowC'><iframe id='iFrameModalWindow' scrolling='no' frameborder='0' src='' style='width:"+modalwidth+"px;height:"+modalheight+"px'></iframe></td></tr><tr><td class='ModalWindowBL notxt'>&nbsp;</td><td class='ModalWindowBC notxt'>&nbsp;</td><td class='ModalWindowBR notxt'>&nbsp;</td></tr></table>");
	$('#ModalWindow').css({'width': +modalwidth+'px', 'height': (modalheight+51)+'px'});
	$('#iFrameModalWindow').attr("src",url);
	setTimeout(function(){$('#iFrameModalWindow').attr("src",url);}, 1 );
	$.blockUI({ 
		message: $('#ModalWindow'),
		fadeIn:  200,
		css: { 
			top:  ($(window).height() - (modalheight+51)) /2 + 'px', 
			left: ($(window).width() - modalwidth) /2 + 'px', 
			height: (modalheight+51)+'px',
			width: modalwidth+'px',
			zIndex: 9001
		},
		overlayCSS: {
			backgroundColor: '#333333',
			opacity: 0.3,
			zIndex: 9000
		}
	});
	
	ModalIsOpen=true;
	
	}
}






//window

function WindowOpen(url,width,height) {
	if (width=="full"){width=window.screen.availWidth;marginleft=0}else{marginleft=parseInt((screen.width-width)/2)};
	if (height=="full"){height=window.screen.availHeight;margintop=0}else{margintop=parseInt((screen.height-height)/2)};
	specs = "width="+width+",height="+height+",left="+marginleft+",top="+margintop+",toolbar=no,toolbar=0,status=no,status=0,scrollbars=yes,scrollbars=1,resizable=no,resizable=0,menubar=no,menubar=0,location=no,location=0";
	window.open(url,'_blank',specs,false);
}


function WindowOpenEdit(url) {
	tmpWidth=windowRecalculateWidth(400);
	tmpHeight=windowRecalculateHeight(310);
	marginleft=(screen.width-tmpWidth)/2;
	margintop=(screen.height-tmpHeight)/2;
	specs = "width="+tmpWidth+",height="+tmpHeight+",left="+marginleft+",top="+margintop+",toolbar=no,toolbar=0,status=no,status=0,scrollbars=yes,scrollbars=1,resizable=no,resizable=0,menubar=no,menubar=0,location=no,location=0";
	tmpnewwindow=window.open(url,'_blank',specs,false);
	tmpnewwindow.resizeTo(tmpWidth,tmpHeight);
}

function windowResizeSmooth(w,h) {
	windowresizer=setInterval(function() {
		changeX = w-windowWidth;
		changeY = h-windowHeight;
		windowWidth=windowWidth+Math.ceil((changeX/6));
		windowHeight=windowHeight+Math.ceil((changeY/6));
		if (changeX==0 && changeY==0) {
			clearInterval(windowresizer);
			$(".NewWindow").css("overflow","auto");
			$(".NewWindowContent").css("padding-top","25px").fadeIn();
		}else{
			windowCenter(windowWidth,windowHeight);
		}
	}, 10);
}

function windowCenter(w,h) {
	window.resizeTo(w,h);
	window.moveTo((screen.width-w)/2,(screen.height-h)/2);	
}






















function Pagination() {
	if ($('div.pagination').length>0){if (PaginationCount>1) {
		

		$('body').append('<div id="tmpholder" style="width:'+PaginationCount*50+'px;position:absolute"></div>');
		tmp_html = '<div class="pagination_slider">';
		for(var i=2; i<PaginationCount; i++){
			if (i==PaginationCurrent){
				tmp_html += '<div class="pagination_current">'+PaginationCurrent+'</div>';
			}else{
				tmp_html += '<a href="'+PaginationMakeUrl(i)+'" class="pagination_item">'+i+'</a>';
			}
		}
		tmp_html += '</div>';
		$('#tmpholder').html(tmp_html);
		tmp_sliderwidth = $('div.pagination_slider').width();

			
		tmp_html = '<div class="pagination_items">';
		if (PaginationCurrent==1) {
			tmp_html += '<div class="pagination_current" style="margin-left:0px;margin-right:0px">'+PaginationCurrent+'</div>';
		}else{
			tmp_html += '<a class="pagination_prev" href="'+PaginationMakeUrl((PaginationCurrent-1))+'">'+PaginationPrev+'</a>';
			tmp_html += '<a class="pagination_range" href="'+PaginationMakeUrl('1')+'">1</a>';
		}
		tmp_html += '<div class="pagination_links"></div>';

		if (PaginationCurrent==PaginationCount) {
			tmp_html += '<div class="pagination_current" style="margin-left:0px;margin-right:0px">'+PaginationCurrent+'</div>';
		}else{
			tmp_html += '<a style="margin-left:0px" class="pagination_range" href="'+PaginationMakeUrl(PaginationCount)+'">'+PaginationCount+'</a>';
			tmp_html += '<a class="pagination_next" href="'+PaginationMakeUrl((PaginationCurrent+1))+'">'+PaginationNext+'</a>';
		}
		tmp_html += '<div>';
		$('div.pagination').html(tmp_html);
		
		$('div.pagination_links').html($('#tmpholder').html());
		$('#tmpholder').remove();

		
		if ($('div.pagination_items').width()<=970) {
			
			tmp_paddingleft = ((990-$('.pagination_items').width())/2);
			
			fadeleft=fadeleft=tmp_paddingleft+150;
			faderight=tmp_paddingleft+$('.pagination_items').width()-180;
			
			if (PaginationCurrent==1) {fadeleft-=150;}
			if (PaginationCurrent==PaginationCount) {faderight+=150;}
			
			
			$('div.pagination').css("padding-left",tmp_paddingleft+"px");
			$('div.pagination').html($('div.pagination').html()+'<div class="pagination_fadeleft" style="left:'+fadeleft+'px"></div><div class="pagination_faderight" style="left:'+faderight+'px"></div>');
		}else{
			$('div.pagination_slider').css("width",tmp_sliderwidth+"px");
			paginlinks=660;
			if (PaginationCurrent==1) {fadeleft=10;paginlinks=770;}else{fadeleft=160;}
			if (PaginationCurrent==PaginationCount) {faderight=950;paginlinks=770;}else{faderight=800;}
			$('div.pagination_links').css("width",paginlinks+"px");
			$('div.pagination').html($('div.pagination').html()+'<div class="pagination_fadeleft" style="left:'+fadeleft+'px"></div><div class="pagination_faderight" style="left:'+faderight+'px"></div>');

			div = $('div.pagination_links');
			div.scrollLeft(tmp_sliderwidth*PaginationCurrent/PaginationCount-450);
			
			var mousextmp;
			div.mousemove(function(e){
				var procent = (e.pageX-60-div.offset().left)/(paginlinks-90);
				if (procent<0)procent=0;
				if (procent>1)procent=1;
				var left = procent*(tmp_sliderwidth-610);
				//div.scrollLeft(left);
				
				setTimeout(function(){mousextmp = e.pageX;}, 100 );
				//setTimeout(function(){if (Math.abs(mousextmp-e.pageX)>100) {div.animate({ scrollLeft: left+'px' }, { queue: false, duration: 500, easing: 'easeOutQuart' });}}, 200 );
				if (Math.abs(mousextmp-e.pageX)>10) {div.animate({ scrollLeft: left+'px' }, { queue: false, duration: 500, easing: 'easeOutQuart' });}
			});

		}

	}else{$('div.pagination').toggleClass('pagination_none');}}
}



function PaginationMakeUrl(obj) {
	if (PaginationUrl.indexOf(',?')>0){
		tmpurl = PaginationUrl.substring(0,PaginationUrl.indexOf(',?')+1)+obj+PaginationUrl.substring(PaginationUrl.indexOf(',?')+1,PaginationUrl.length);
	}else{
		tmpurl = PaginationUrl+obj;
	}
	return tmpurl;
}




function ZoomIn(obj) {
	if ($(obj).parent().parent().children(".work_item_content_data_a").length>0) {
		tmplink = $(obj).parent().parent().children(".work_item_content_data_a");
		tmplink.replaceWith( "<div class='"+tmplink.attr('class')+"' title='"+tmplink.attr('title')+"' href='"+tmplink.attr('href')+"'>" + tmplink.html() + "</div>" );
		tmp_contentdata = $(obj).parent().parent().children(".work_item_content_data_a").children("div.work_item_content_data");
	}else{
		tmp_contentdata = $(obj).parent().parent().children(".work_item_content_data_div").children("div.work_item_content_data");
	}
	tmp_name = $(obj).parent().parent().children("input").val();
	tmp_contentdata.html('<img class="work_item_content_data_img" src="'+tmp_name+'" style="position:absolute" /><img class="work_item_content_data_img_big" src="'+tmp_name.substring(0,tmp_name.length-4) + '_big.jpg'+'" style="position:absolute" />').css("display","block").attr("onclick", "").css("cursor", "default");
	tmp_contentdata.children("img.work_item_content_data_img").load(function() {
		tmp_contentdata.children("img.work_item_content_data_img").css("width",tmp_contentdata.children("img.work_item_content_data_img").width()*2).css("left",-(tmp_contentdata.children("img.work_item_content_data_img").width()-tmp_contentdata.width())/2).css("top",-(tmp_contentdata.children("img.work_item_content_data_img").height()-tmp_contentdata.height())/2);
		tmp_contentdata.children("img.work_item_content_data_img_big").css("left",-(tmp_contentdata.children("img.work_item_content_data_img").width()-tmp_contentdata.width())/2).css("top",-(tmp_contentdata.children("img.work_item_content_data_img").height()-tmp_contentdata.height())/2);
	});
	
	tmp_contentdata.parent().bind('mousemove', function(e) {
			var divWidth = $(this).width();
			var divHeight = $(this).height();
			var igW = $(this).children('.work_item_content_data').children('img').width();
			var igH = $(this).children('.work_item_content_data').children('img').height();
			var dOs = $(this).children('.work_item_content_data').offset();
			var leftPan = (e.pageX - dOs.left) * (divWidth - igW) / (divWidth);
			var topPan = (e.pageY - dOs.top) * (divHeight - igH) / (divHeight);
			$(this).children('.work_item_content_data').children('img').css({left: leftPan, top: topPan});	
	}).bind('click', function(e) {
		
		tmp_contentdata.removeAttr("style");
		
		tmp_contentdata.html('<img src="'+tmp_name+'">');
		
		tmp_contentdata.parent().parent().children("div.work_item_content_nav").children("div.work_item_content_nav_zoomout").css("display","none");
		tmp_contentdata.parent().parent().children("div.work_item_content_nav").children("div.work_item_content_nav_zoomin").css("display","block");
		
		tmplink = $(obj).parent().parent().children(".work_item_content_data_a");
		if (tmplink.length>0) {
			tmplink.replaceWith( "<a class='"+tmplink.attr('class')+"' title='"+tmplink.attr('title')+"' href='"+tmplink.attr('href')+"'>" + tmplink.html() + "</a>" );
		}
		


	});
	$(obj).css("display","none");
	$(obj).parent().children("div.work_item_content_nav_zoomout").css("display","block");
}

function ZoomOut(obj) {
	if ($(obj).parent().parent().children(".work_item_content_data_a").length>0) {
		tmplink = $(obj).parent().parent().children(".work_item_content_data_a");
		tmplink.replaceWith( "<a class='"+tmplink.attr('class')+"' title='"+tmplink.attr('title')+"' href='"+tmplink.attr('href')+"'>" + tmplink.html() + "</a>" );
		tmp_contentdata = $(obj).parent().parent().children("a.work_item_content_data_a").children("div.work_item_content_data");
	}else{
		tmp_contentdata = $(obj).parent().parent().children(".work_item_content_data_div").children("div.work_item_content_data");
	}
	tmp_contentdata.removeAttr("style");
	tmp_name = $(obj).parent().parent().children("input").val();
	tmp_contentdata.html('<img src="'+tmp_name+'">');
	$(obj).css("display","none");
	$(obj).parent().children("div.work_item_content_nav_zoomin").css("display","block");
}


function ImgReload(obj) {
	tmp_obj=$(obj).parent().parent().children().children(".work_item_content_data").children("img");
	tmpsrc=tmp_obj.attr('src');
	tmp_obj.attr("src","").attr("src",tmpsrc);
}

function HintShow(obj) {
	$(obj).parent().parent().children().children(".work_item_content_hint").css("display","block");
	$(obj).css("display","none");
	$(obj).parent().children("div.work_item_content_nav_hintoff").css("display","block");
}

function HintHide(obj) {
	$(obj).parent().parent().children().children(".work_item_content_hint").css("display","none");
	$(obj).css("display","none");
	$(obj).parent().children("div.work_item_content_nav_hinton").css("display","block");
}






function WindowMode(imgurl) {
	
	windowWidth=1420;
	windowHeight=740;
	if (screen.width<=1280)windowWidth=1250;
	if (screen.width<=1024)windowWidth=1000;
	marginleft=parseInt((screen.width-windowWidth)/2);
	margintop=parseInt((screen.height-windowHeight)/2);
	specs = "width="+windowWidth+",height="+windowHeight+",left="+marginleft+",top="+margintop+",toolbar=no,toolbar=0,status=no,status=0,scrollbars=no,scrollbars=0,resizable=no,resizable=0,menubar=no,menubar=0,location=no,location=0";
	bigimgwindow = window.open('/windowmode.php?imgsrc='+imgurl.substring(0,imgurl.length-4)+'_big.jpg','_blank',specs,false);
}

function ShareFacebook(url) {
	specs = "width=600,height=340,left="+parseInt((screen.width-600)/2)+",top="+parseInt((screen.height-340)/2)+",toolbar=no,toolbar=0,status=no,status=0,scrollbars=yes,scrollbars=1,resizable=no,resizable=0,menubar=no,menubar=0,location=no,location=0";
	window.open('http://www.facebook.com/share.php?u=' + encodeURIComponent(url),'_blank',specs,false);
}







function CommentShowButtons(obj) {
	$(obj).children("div.comment-box").css("display","block");
	$(obj).css("background","#F5F5F5");
}

function CommentHideButtons(obj) {
	$(obj).children("div.comment-box").css("display","none");
	$(obj).css("background","#ffffff");
}











function AjaxRating(obj,id_num,vote,juri_base,group){
	$.ajax({
		url: juri_base+'/index.php?option=com_ajaxmanager&task=ajaxVote&vote='+vote+'&group='+group+'&id_num='+id_num,
		success: function(data) {
			$(obj).parent().html(data);
			AjaxRatingSuccess();
		},
		error : function(data) {
			alert('AJAX error, please try again');
		}
	});
}


function TooltipsDraw() {
	$('.showtooltip').tipsy({gravity: 's',html: true,delayIn: 200,delayOut: 0});
}

function TooltipsDelete() {
	$('.tipsy').remove();
}










function ImgPreviewOpen(obj,imgsrc) {
	$('body').append('<div class="myworks_imgpreview"><img src="'+imgsrc+'" /></div>');
	$('div.myworks_imgpreview').css("top",($(obj).offset().top-6)+"px");
	$('div.myworks_imgpreview').css("left",($(obj).offset().left+65)+"px");
}

function ImgPreviewClose() {
	$('div.myworks_imgpreview').remove();
}











function getElementValue(obj,type) {
	if (type=='width')return parseInt(document.getElementById(obj).style.width);
	if (type=='height')return parseInt(document.getElementById(obj).style.height);
	if (type=='top')return parseInt(document.getElementById(obj).style.top);
	if (type=='left')return parseInt(document.getElementById(obj).style.left);
}

function DigitsOnly(obj) {
	
	objtextbox = obj;
	var exp = /[^\d]/g;
	objtextbox.value = objtextbox.value.replace(exp,'');
	
}


function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}


  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }



function getElementByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

function getStyle(el,styleProp){
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}


































//======================================
//jcomments-v2.1.js




function JCommentsEvents(){}
function JCommentsInput(){}
function JCommentsIndicator(){this.init();}
function JCommentsForm(id,editor){this.init(id,editor);}
function JCommentsEditor(textarea,resizable){this.init(textarea,resizable);}
function JComments(oi,og,r){this.init(oi,og,r);}

JCommentsEvents.prototype = {
	add: function(o,e,f){if(o.addEventListener){o.addEventListener(e,f,false);return true;}else if(o.attachEvent){return o.attachEvent("on"+e,f);}else{return false;}},
	remove: function(o,e,f){if(o.removeEventListener){o.removeEventListener(e,f,false);}else if(o.detachEvent){o.detachEvent( "on"+e,o[e+f] );o[e+f]=null;o["e"+e+f]=null;}},
	cancel: function(e){if(e.stopPropagation){e.cancelBubble=true;e.preventDefault();e.stopPropagation();}e.returnValue=false;return false;},
	target: function(e){var t;if(!e)e=window.event;if(e.target)t=e.target;else if(e.srcElement)t=e.srcElement;if(t.nodeType==3)t=t.parentNode;return t;}
};

JCommentsInput.prototype = {
	register: function(el){if(el){var th=this,events=new JCommentsEvents();events.add(el,'focus',function(e){return th.onFocus(e);});events.add(el,'blur',function(e){return th.onBlur(e);});}},
	unregister: function(el){if(el){var th=this,events=new JCommentsEvents();events.remove(el,'focus',function(e){return th.onFocus(e);});events.remove(el,'blur',function(e){return th.onBlur(e);});}},
	onFocus: function(e){var t=JCommentsEvents.prototype.target(e);if(t!=null){t.className=t.className.replace('error','')+' selected';}},
	onBlur: function(e){var t=JCommentsEvents.prototype.target(e);if(t!=null){var c=t.className.replace('error','');c=c.replace('error','');c=c.replace('selected','');t.className=c.replace(/^\s+/g,"");}}
};

JCommentsEditor.prototype = {
	ta: null,
	l10n: {},
	tags: {},
	smiles: {},
	events: null,
	counter: null,
	focused: false,
	resizable: true,

	init: function(textareaID, r) {
		this.ta=JComments.prototype.$(textareaID);
		this.panelElements={};
		this.l10n={counterPre:'',counterPost:' symbols left',enterValue: 'Enter value'};
		this.resizable=r;
		this.events=new JCommentsEvents();
		this.defaultHeight=this.ta.clientHeight;
		this.defaultRows=this.ta.rows;
		if(this.resizable){this.addGrippie();}
		this.isWebkit=/webkit/.test(navigator.userAgent.toLowerCase());

		var th = this;
		this.events.add(document,!window.opera&&document.all?'keydown':'keypress',function(e){return th.onKeyPress(e);});
		this.events.add(this.ta,'click',function(e){th.closeSmiles();return th.storeCaret(this.ta);});
		this.events.add(this.ta,'select',function(e){return th.storeCaret(this.ta);});
		this.events.add(this.ta,'change',function(e){th.onChange(); return th.storeCaret(this.ta);});
		this.events.add(this.ta,'keyup',function(e){return th.onChange();});
		this.events.add(this.ta,'focus',function(e){th.closeSmiles(); return th.focused=true;});
		this.events.add(this.ta,'blur',function(e){return th.focused=false;});
	},
	onKeyPress: function(e) {
		if (!this.focused){return;}
		var r=false,k=String.fromCharCode(e.keyCode?e.keyCode:e.charCode),t=null;
		for(var id in this.tags){
			t=this.tags[id];
			if(!t.key||k.toUpperCase()!=t.key.toUpperCase())continue;
			if(t.ctrl&&!e[t.ctrl+"Key"])continue;
			this.insertTag(id);
			return this.events.cancel(e);
		}
		return e.returnValue;
	},
	defined: function(v){return (typeof(v)!="undefined");},
	clear: function(){this.ta.value='';if(this.defaultHeight){this.ta.style.height=this.defaultHeight+'px';}this.updateCounter();},
	focus: function(){this.ta.focus();},
	storeCaret: function(){var ta=this.ta;if(ta.createTextRange)ta.caretPos=document.selection.createRange().duplicate();},
	getElementPos: function(e){var p={left:0,top:0,right:0,bottom:0};while(e!=null){p.left+=e.offsetLeft;p.top+=e.offsetTop;e=e.offsetParent;}p.right+=p.left;p.bottom+=p.top;return p;},
	getSelection: function(){var ta=this.ta,s='';if(document.selection&&document.selection.createRange){s=document.selection.createRange().text;}else{s=ta.value.substr(ta.selectionStart,ta.selectionEnd-ta.selectionStart);}return s;},
	insertText: function(text) {
		var ta=this.ta;
		if(this.defined(ta.caretPos)&&ta.createTextRange){ta.focus();var sel=document.selection.createRange();sel.text=sel.text+text;ta.focus();}
		else if(this.defined(ta.selectionStart)){
			var ss=ta.value.substr(0, ta.selectionStart);
			var se=ta.value.substr(ta.selectionEnd),sp=ta.scrollTop;
			ta.value=ss+text+se;
			if(ta.setSelectionRange){ta.focus();ta.setSelectionRange(ss.length+text.length,ss.length+text.length);}
			ta.scrollTop=sp;
		} else {ta.value+=text;ta.focus(ta.value.length-1);}
	},
	surroundText: function(t1,t2) {
		var ta=this.ta;
		if (this.defined(ta.caretPos) && ta.createTextRange){
			var cp=ta.caretPos,tl=cp.text.length;
			cp.text=cp.text.charAt(cp.text.length-1)==' '?t1+cp.text+t2+' ':t1+cp.text+t2;
			if(tl==0){cp.moveStart("character",-t2.length);cp.moveEnd("character",-t2.length);cp.select();}
			else{ta.focus(cp);}
		}else if(this.defined(ta.selectionStart)){
			var ss=ta.value.substr(0,ta.selectionStart),se=ta.value.substr(ta.selectionEnd);
			var sl=ta.value.substr(ta.selectionStart,ta.selectionEnd-ta.selectionStart);
			var nc=ta.selectionStart,sp=ta.scrollTop;
			ta.value=ss+t1+sl+t2+se;
			if(ta.setSelectionRange){
				if(sl.length==0){ta.setSelectionRange(nc+t1.length,nc+t1.length);}
				else{ta.setSelectionRange(nc,nc+t1.length+sl.length+t2.length);}
				ta.focus();
			}
			ta.scrollTop=sp;
		}else{ta.value+=t1+t2;ta.focus(ta.value.length-1);}
	},
	insertTag: function(id) {var tag=this.tags[id],ta=this.ta,s='';if(!tag)return;s=this.getSelection();if(s.length>0){this.surroundText(tag.open,tag.close);}},
	initTags: function(){
		if (this.bbc==null||this.bbc.length==0){
			this.bbc={};
			this.bbc['b']={id:'bbcode-b',open:'[b]',close:'[/b]',key:'B',ctrl:'ctrl',hint:'Bold'};
			this.bbc['i']={id:'bbcode-i',open:'[i]',close:'[/i]',key:'I',ctrl:'ctrl',hint:'Italic'};
			this.bbc['u']={id:'bbcode-u',open:'[u]',close:'[/u]',key:'u',ctrl:'ctrl',hint:'Underline'};
			this.bbc['s']={id:'bbcode-s',open:'[s]',close:'[/s]',key:null,ctrl:null,hint:'Strikeout'};
			this.bbc['img']={id:'bbcode-img',open:'[img]',close:'[/img]',key:null,ctrl:null,hint:'Image'};
			this.bbc['url']={id:'bbcode-url',open:'[url]',close:'[/url]',key:null,ctrl:null,hint:'Link'};
			this.bbc['hide']={id:'bbcode-hide',open:'[hide]',close:'[/hide]',key:null,ctrl:null,hint:'Hidden'};
			this.bbc['quote']={id:'bbcode-quote',open:'[quote]',close:'[/quote]',key:'Q',ctrl:'ctrl',hint:'Quote'};
			this.bbc['list']={id:'bbcode-list',open:'[list][*]',close:'[/list]',key:'L',ctrl:'ctrl',hint:'List'};
		}
	},

	createButton: function(i,t,c,f,img){
		var e;if(img==null||img==""){e=document.createElement('a');e.style.display='block';e.setAttribute('href','#');}
		else{e=document.createElement('img');if(t){e.setAttribute('alt',t);}e.setAttribute('src',img);if(!c){c='custombbcode'};}
	       	if(i){e.setAttribute('id',i);}if(t){e.setAttribute('title',t);}if(c){e.className=c;}
       		var ee=e;e.onclick=(f!=null?function(){f(ee); return false;}:function(){return false;});
	       	return e;
	},

	addButton: function(id,h,p,ot,ct,css,img) {
		if(this.ta){
			this.initTags();
			var tag=this.bbc[id],th=this;
			if(!tag){
				if(ot&&ct) {
					this.bbc[id]={id:id,open:ot,close:ct,key:null,ctrl:null,hint:h};
					tag=this.bbc[id];
				} else { return; }
			}
			if(this.bbcPanel==null){
				this.bbcPanel=document.createElement('span');
				this.bbcPanel.className='bbcode';
				this.bbcPanel.style.display='block';
				this.ta.parentNode.insertBefore(this.bbcPanel,this.ta);
			}
			var f=function(){var s=th.getSelection();if(s.length>0){th.surroundText(tag.open,tag.close);}else{var v=prompt(p,'');if(null!=v && ''!=v){th.insertText(tag.open+v+tag.close);}}return false;};
			tag.e=this.createButton(tag.id,(h!=null?h:tag.hint),(css?css:tag.id),f,img);
			this.bbcPanel.appendChild(tag.e);
       		this.tags[tag.id]=tag;
		}
	},

	initSmiles: function(p){this.smilesPath=p;
		if(this.ta){
			this.smilesPanel=document.createElement('div');
			if(this.bbcPanel){
				document.body.appendChild(this.smilesPanel);
				this.smilesPanel.id='comments-form-smilespanel';
				this.smilesPanel.setAttribute('style','display:none;top:0;left:0;position:absolute;');
				this.smilesPanel.onclick=function(){this.style.display='none';};
				var jc=this,f=function(e){
					var sp=jc.smilesPanel,p=jc.getElementPos(e);
					if(sp){var sps=sp.style;sps.display=(sps.display=='none'||sps.display==''?'block':'none');sps.left=p.left+"px";sps.top=p.bottom+e.offsetHeight+"px";sps.zIndex=99;}
					return false;
				};
				this.bbcPanel.appendChild(this.createButton(null,null,'bbcode-smile',f));
			} else {
				this.smilesPanel.className='smiles';this.ta.parentNode.insertBefore(this.smilesPanel, this.ta);
			}
		}
	},
	closeSmiles: function(){if(this.smilesPanel&&this.bbcPanel){this.smilesPanel.style.display='none';}},

	addSmile: function(code,image){
		if(this.ta){
			if(!this.smilesPath||!this.smilesPanel){return;}
       			var th=this,e=document.createElement('img');
       			e.setAttribute('src',this.smilesPath+'/'+image);
       			e.setAttribute('alt',code);
       			e.className='smile';
	       		e.onclick=function(){th.insertText(' '+code+' ');};
       			this.smilesPanel.appendChild(e);
		}
	},
	addCounter: function(m,pre,post,className){
		if(this.ta){
			if(pre!=null){this.l10n.counterPre=pre;}if(post!=null){this.l10n.counterPost=post;}
			var ch=document.createElement('span');ch.className=className!=null?className:'';
			var t1=document.createTextNode(this.l10n.counterPre+' '),t2=document.createTextNode(' '+this.l10n.counterPost);
			var c=document.createElement('span');ch.appendChild(t1);ch.appendChild(c);ch.appendChild(t2);
			if(this.resizable){if(this.grippie!=null){this.grippie.appendChild(ch);}}
			else{var d=document.createElement('div');d.className='counterpanel';this.ta.parentNode.insertBefore(d,this.ta.nextSibling);d.appendChild(ch);}
			this.counter={e:c,max:m};
			this.updateCounter();
		}
	},
	addGrippie: function() {
		this.offset=null;this.dragging=false;
		this.grippie=document.createElement('div');this.grippie.className='grippie';
		this.ta.parentNode.insertBefore(this.grippie,this.ta.nextSibling);
	        var th=this;this.events.add(this.grippie,'mousedown',function(e){return th.onMouseDown(e);});
	},
	updateCounter: function(){if(this.counter!=null){var ta=this.ta,e=this.counter.e;try{var n=document.createElement(e.tagName),v=this.counter.max-ta.value.length;n.innerHTML=(v>=0)?v:0;e.parentNode.replaceChild(n,e);this.counter.e=n;}catch(ex){}}},
	mousePosition: function(e){var px=0,py=0;if(!e){e=window.event;}if(e.pageX||e.pageY){px=e.pageX;py=e.pageY;}else if(e.clientX||e.clientY){px=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;py=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;}return {x:px,y:py};},
	onChange: function(){this.updateCounter();if(this.ta&&!this.isWebkit){var l=this.ta.value.split('\n');this.ta.rows=(l.length<this.defaultRows)?this.defaultRows:l.length+1;}return false;},
	onMouseDown: function(e){this.offset=this.mousePosition(e).y;this.height=this.ta.clientHeight;this.dragging=true;var th=this;this.events.add(document,'mousemove',function(e){return th.onMouseMove(e);});this.events.add(document,'mouseup',function(e){return th.onMouseUp(e);});return false;},
	onMouseUp: function(e){this.dragging=false;},
	onMouseMove: function(e){if(this.dragging)this.ta.style.height=Math.max(this.defaultHeight, this.height+this.mousePosition(e).y-this.offset)+'px';return false;}
};

JCommentsForm.prototype = {
	id:null,
	form: null,
	events: null,
	editor: null,
	elements: {},
	store: new Array('name','email','homepage'),
	fadeTimer: null,

	init: function(id,editor){var f=this;this.id=id;this.form=this.$(id);this.editor=editor;this.events=new JCommentsEvents();this.setElements(new Array('name','email','homepage','title','comment'));this.restoreValues();this.clear('captcha');this.setCaptcha();},
	setCaptcha: function(){this.captchaImage=this.$(this.id+'-captcha-image');this.register('captcha');},
	setEditor: function(e){this.editor=e;},
	setElements: function(e){for(i=0;i<e.length; i++){try{this.register(e[i]);}catch(e){}}},
	$:function(e){return JComments.prototype.$(e);},
	register: function(n){var f=this,e=this.$(this.id+'-'+n);if(e){this.elements[n]=e;JCommentsInput.prototype.register(e);this.events.add(e,!window.opera&&document.all?'keydown':'keypress',function(e){return f.keypress(e);});}},
	error: function(m,n){var e=this.elements[n];if(e){e.focus();e.className='error';}},
	clear: function(n){
		if(n==null){if(this.form!=null){this.form.reset();}return;}
		switch(n){
			case 'comment':if(this.editor!=null){this.editor.clear();}break;
			case 'captcha':var cim=this.captchaImage,cin=this.elements['captcha'];if(cim){cim.src=cim.src.replace(/&ac=\d+/g, '&ac='+new String(Math.floor(Math.random()*100000)));}if(cin){cin.value='';}break;
			default:var e=this.elements[n];if(e){e.value='';}break;					
		}
	},
	focus:function(n){var e;if(n==null){for(var nm in this.elements){e=this.elements[nm];if(e){e.focus();break;}}}else{e=this.elements[n];if(e){e.focus();}}},
	keypress: function(e){if(e.ctrlKey &&(e.keyCode==13||(e.type=='keypress'&&e.keyCode==10))){this.submit();e.returnValue=false;return this.events.cancel(e);}return this.keypressed(e);},
	add: function(n,i,v){if(this.form!=null){var e=document.createElement('input');e.setAttribute('type', 'hidden');e.setAttribute('name', n);e.setAttribute('id', i);e.setAttribute('value', v);this.form.appendChild(e);}},
	remove: function(i){var e=this.$(i);if(e){e.value=0;e.parentNode.removeChild(e);}},
	setText: function(n,t){if(n=='comment'){if(this.editor!=null){this.editor.clear();this.editor.insertText(t);}}else{var e=this.elements[n];if(e){e.value=t;}}},
	insertText: function(n,t){if(n=='comment'){if(this.editor!=null){this.editor.insertText(t);}}else{var e=this.elements[n];if(e){e.value+=t;}}},
	storeValues: function(){for(var i=0;i<this.store.length; i++){try{var el=JComments.prototype.$(this.id+'-'+this.store[i]);if(el){JComments.prototype.setCookie(this.store[i],encodeURIComponent(el.value),14);}}catch(e){}}},
	restoreValues: function(){for(var i=0;i<this.store.length; i++){try{var el=JComments.prototype.$(this.id+'-'+this.store[i]);if(el){if(el.type&&el.type=='hidden'){return;}else{el.value=decodeURIComponent(JComments.prototype.getCookie(this.store[i]));}}}catch(e){}}},
	submit: function(){},
	keypressed: function(e){}
};

JCommentsIndicator.prototype = {
	e: null,
	init: function(){if(this.e==null){this.e=document.createElement('div');this.e.className='busy';}},
	move: function(p,b){if(p){if(this.e.parentNode){this.e.parentNode.removeChild(this.e);}if(b){p.insertBefore(this.e,b);}else{p.appendChild(this.e);}}},
	show: function(){this.e.style.display='block';},
	hide: function(){this.e.style.display='none';},
	start: function(p,b){this.move(p,b);this.show();},
	stop: function(){this.hide();}
};

JComments.prototype = {
	oi:null,
	og:null,
	debug: false,
	requestURI: '',
	oldRequestURI: '',
	busy: null,
	form: null,
	cache: {},
	mode:'add',
	readyList: [],
	isReady: false,

	init: function(oi,og,r){var ua=navigator.userAgent.toLowerCase();this.browser={safari: /webkit/.test(ua),opera: /opera/.test(ua),msie: /msie/.test(ua) && !(/opera/.test(ua)),mozilla: /mozilla/.test(ua) && !(/(compatible|webkit)/.test(ua))};this.oi=oi;this.og=og;this.busy=new JCommentsIndicator();this.requestURI=r;var th=this;jtajax.startLoading=function(){th.busy.show();};jtajax.finishLoading=function(){th.busy.hide();};},
	reinit: function(oi,og){this.oi=oi;this.og=og;var foi=this.$('object_id');if(foi){foi.value=oi;};var fog=this.$('object_group');if(fog){fog.value=og;}this.showPage(oi,og,0);},
	setForm: function(f){this.form=f;this.form_id=f.id;this.setMode('add',null);var jc=this;this.form.submit=function(){jc.saveComment();};this.form.keypressed=function(e){if(e.keyCode==27&&jc.mode=='reply'){jc.restoreForm(false);}};this.formLoaded();},
	setList: function(l){this.list_id=l;},
	setMode: function(m,i){var b=this.$('comments-form-cancel'),jc=this;if(b!=null){b.style.display=(m!='add')?'':'none';b.onclick=(m=='edit'?function(){jc.cancelEdit(i);}:(m=='reply'?function(){jc.cancelReply();}:null));}this.mode=m;},
	$: function(id){if(!id){return null;}var e=document.getElementById(id);if(!e&&document.all){e=document.all[id];}return e;},
	ajax: function(f,a,fid){var r,prevURI;try{prevURI=jtajax.options.url;jtajax.setup({url:this.requestURI});r=jtajax.call(f,a,'post',fid);jtajax.options.url=prevURI;}catch(e){jtajax.options.url=prevURI;}return r;},
	initOnReady : function(){if(this.isReadyInited) return;this.isReadyInited=1;var jc=this;
	      	if(this.browser.mozilla||this.browser.opera){JCommentsEvents.prototype.add(document, 'DOMContentLoaded',jc.ready);}
        	else if(this.browser.msie) {(function(){try{document.documentElement.doScroll('left');}catch(e){setTimeout(arguments.callee, 50);return;}jc.ready();})();}
        	else if(this.browser.safari){(function(){if(jc.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}jc.ready();})();}
         	JCommentsEvents.prototype.add(window, 'load', function(){jc.ready(jc);});
	},
	onReady: function(f){if(this.isReady){f();}else{var jc=this;jc.readyList.push(f);jc.initOnReady();}},
	ready: function(){var jc=window.jcomments;if(jc.isReady||jc.readyList==null) return;jc.isReady=1;for(var i=0,len=jc.readyList.length;i<len;i++){try{jc.readyList[i]();}catch(e){}}jc.readyList=null;},
	setAntiCache: function(c,p,f){this.aca=c;this.acp=p;this.acf=f;this.onReady(this.loadComments);},
	loadComments: function(){var jc=window.jcomments;var l=document.location.href,lc=true,i=l.lastIndexOf('#comment-');jc.clear('captcha');if(jc.aca){if(i!=0){var c=l.substring(i+9,l.length);if(!isNaN(c)){lc=false;jc.showComment(c);}}}if(jc.acp){if(lc){jc.showPage(jc.oi,jc.og,0);}}if(jc.acf){if(l.lastIndexOf('#addcomment')!=-1){jc.showForm(jc.oi,jc.og,'comments-form-link');}}},
	setCookie: function(n,v,d){var e='';if(d){var dt=new Date();dt.setTime(dt.getTime()+(d*24*60*60*1000));e="; expires="+dt.toGMTString();}document.cookie = "jc_"+n+"="+v+e+"; path=/";},
	getCookie: function(n){var re=new RegExp( "(\;|^)[^;]*(" + "jc_"+n + ")\=([^;]*)(;|$)" );var r=re.exec(document.cookie);return r != null ? r[3] : '';},
	removeCookie: function(n){this.setCookie(n,"",-1);},
	scrollTo: function(n){if(n!=null){var e=this.$(n),t=0;if(e){t=e.offsetTop;for(var p=e.offsetParent;p;p=p.offsetParent){t+=p.offsetTop;}scrollTo(0,t);}}},
	scrollToList: function(){this.scrollTo(this.list_id);},
	scrollToForm: function(id){this.scrollTo(this.form_id);},
	scrollToComment: function(id){this.scrollTo('comment-'+id);},
	moveElement: function(e,p,b){if(e){if(p){if(e.parentNode){e.parentNode.removeChild(e);}if(b){p.insertBefore(e,b);}else{p.appendChild(e);}}}},
	createElement: function(t,i,c){var e=document.createElement(t);if(i){e.setAttribute('id',i);}if(c){e.className=c;}return e;},
	fade: function(id,s,e,m){var speed=Math.round(m/100),timer=0;if(s>e){for(i=s;i>=e;i--){setTimeout("JComments.prototype.setOpacity('"+id+"',"+i+")",(timer*speed));timer++;}var o=JComments.prototype.$(id);if(o){setTimeout(function(){o.style.display='none';},((s-e)*speed));}}else if(s<e){for(i=s;i<=e;i++){setTimeout("JComments.prototype.setOpacity('"+id+"',"+i+")",(timer*speed));timer++;}}},
	setOpacity: function(id,opacity){var e=this.$(id);if(e){var s=e.style;s.opacity=(opacity/100);s.MozOpacity=(opacity/100);s.KhtmlOpacity=(opacity / 100);s.filter="alpha(opacity="+opacity+")";}},
	clear:function(n){if(this.form!=null){this.form.clear(n);}},
	insertText:function(t){if(this.form!=null){this.form.insertText('comment',t);}else{var jc=this;window.setTimeout(function(){jc.insertText(t);},500);}},
	busyList: function(){if(this.list_id){var l=this.$(this.list_id);if(l){this.busy.move(l.parentNode,l);}}},
	busyForm: function(){if(this.form_id){var f=this.$(this.form_id);if(f){this.busy.move(f.parentNode,f);}}},
	busyComment: function(i){this.busy.move(this.$('comment-item-'+i),null);},
	saveComment: function(i){var f='';if(this.mode!='edit'){f='JCommentsAddComment';this.busyForm();if(this.form){this.form.storeValues();}this.busy.show();}else{f='JCommentsSaveComment';this.busy.show();}return this.ajax(f,null, this.form_id);},
	editComment: function(i){this.busyComment(i);var a=arguments;if(this.form==null){a=new Array(i,1);}return this.ajax('JCommentsEditComment', a);},
	cancelEdit: function(i){if((!this.cache[i])||(this.cache[i]=='')){this.$('comment-body-'+i).innerHTML=this.cache[i];this.cache[i]='';}if(this.form){this.form.remove('comment-id-hidden-'+i);this.restoreForm(true);}var t=this.$('comment-toolbar-'+i);if(t){t.style.display='';}return this.ajax('JCommentsCancelComment',arguments);},
	cancelReply: function(){if(this.form){this.form.remove('comment-parent-id-hidden');this.restoreForm(false);}},
	quoteComment: function(i){SetComment();var a=arguments;if(this.form==null){a=new Array(i,1);}return this.ajax('JCommentsQuoteComment',a);},
	publishComment: function(i){if(this.form){this.restoreForm();}this.busyComment(i); return this.ajax('JCommentsPublishComment',arguments);},
	deleteComment: function(i){this.busyComment(i); return this.ajax('JCommentsDeleteComment',arguments);},
	jump2email: function(i){return this.ajax('JCommentsJump2email',arguments);},
	updateList: function(t,m){if(this.list_id){var l=this.$(this.list_id);if(!l){l=this.$('comments');m='a';}switch(m){case 'a':l.innerHTML=l.innerHTML+t;break;case 'p':l.innerHTML=t+l.innerHTML;break;case 'r':l.parentNode.innerHTML=t;break;}}},
	updateTree: function(t,r){var l;if(r==null){l=this.$('comments');if(l){l.innerHTML=t;}return;}l=this.$('comments-list-'+r);if(!l){var p=this.$('comment-item-'+r);if(p){this.busyComment(r);l=this.createElement('div','comments-list-'+r,'comments-list');l.innerHTML=t;p.parentNode.insertBefore(l,p.nextSibling);}}else{l.innerHTML=l.innerHTML+t;}this.restoreForm(true);},
	updateComment: function(id,t){if(t==''){var c=this.$('comment-item-'+id);c.parentNode.removeChild(c);var l=this.$('comments-list-'+id);if(l){l.parentNode.removeChild(l);} return;}this.$('comment-body-'+id).innerHTML=t;var te=this.$('comment-toolbar-'+id);if(te){te.style.display='';}if(this.form){this.form.remove('comment-id-hidden-'+id);this.restoreForm(true);}},
	voteComment: function(i){var v=this.$('comment-vote-holder-'+i);if(v){v.innerHTML='';this.busy.start(v,null);}return this.ajax('JCommentsVoteComment',arguments);},
	updateVote: function(i,t){this.busy.stop();var c=this.$('comment-vote-holder-'+i);if(c){c.innerHTML=t;}},
	showComment: function(id){return this.ajax('JCommentsShowComment',arguments);},
	showPage: function(i,g,p){if(this.form){this.restoreForm();}var l=this.$(this.list_id);if(!l){l=this.$(this.list_id+'-0');if(l){this.list_id=this.list_id+'-0';}}this.busyList();return this.ajax('JCommentsShowPage',arguments);},
	showForm: function(i,g,t){if(this.form){this.moveElement(this.form.form,this.$(t));return;}this.busyForm(); return this.ajax('JCommentsShowForm',arguments);},
	showEdit: function(id,n,e,h,t,txt){ 
		var jc=this;
	        if(this.form==null){window.setTimeout(function(){jc.showEdit(id,n,e,h,t,txt);},500);return;}
		if((!this.cache[id])||(this.cache[id]=='')){this.cache[id]=this.$('comment-body-'+id).innerHTML;}
		this.busy.stop();
		var f=this.form,ff=this.form.form,c=this.$('comment-item-'+id);
		if(ff!=null&&c!=null){
			f.add('id','comment-id-hidden-'+id,id);f.setText('name', n);f.setText('email', e);f.setText('homepage', h);f.setText('title', t);f.setText('comment', txt);
			var d=this.$('comments-inline-edit');
			if(d){d.parentNode.removeChild(d);}else{d=this.createElement('div','comments-inline-edit','comments-inline-edit');}c.appendChild(d);this.moveElement(ff,d);
			this.setMode('edit',id);var te=this.$('comment-toolbar-'+id);if(te){te.style.display='none';}
			this.scrollTo('comments-inline-edit');
			this.form.focus('comment');
		}
	},
	showReply: function(id,q){
		this.busyComment(id);this.cancelReport();
		var jc=this,c=this.$('comment-item-'+id),d=this.$('comments-inline-edit');
		if(d){d.parentNode.removeChild(d);}else{d=this.createElement('div','comments-inline-edit','comments-inline-edit');}c.appendChild(d);
		if(!this.form){
			var t='comments-inline-edit',h=this.$('comments-form-link');if(h){t='comments-form-link';}
			this.showForm(this.oi, this.og,t);var pid=id;this.formLoaded=function(){var f=jc.form;if(f!=null){f.add('parent','comment-parent-id-hidden',pid);}jc.setMode('reply',pid);jc.moveElement(jc.form.form,jc.$('comments-inline-edit'));jc.form.focus();if(q){jc.quoteComment(id);}};
		}else{
			var f=this.form,ff=this.form.form,p=this.$('comment-parent-id-hidden');
			if(ff!=null&&c!=null){if(!p){f.add('parent','comment-parent-id-hidden',id);}else{p.value=id;}this.moveElement(ff,d);this.setMode('reply',id);this.form.focus();if(q){this.quoteComment(id);}}
		}
	},
	formLoaded: function(){},
	restoreForm: function(c){var f=this.form;if(f!=null){var ff=this.form.form,jc=this;this.busy.stop();
		if(ff!=null){if(c){f.clear(null);}f.restoreValues();var a=this.$('addcomments'),p=this.$('comment-parent-id-hidden');if(p){p.value=0;}
		this.moveElement(ff,a.parentNode,a);var d=this.$('comments-inline-edit');if(d){d.parentNode.removeChild(d);}this.setMode('add',null);}
	}},
	reportComment: function(id){
		this.busyComment(id);this.cancelReply();
		var jc=this,c=this.$('comment-item-'+id),d=this.$('comments-inline-report');
		if(d){d.parentNode.removeChild(d);}else{d=this.createElement('div','comments-inline-report','comments-inline-report');}c.appendChild(d);
		var a=new Array(id,'comments-inline-report');
		return this.ajax('JCommentsShowReportForm',a);
	},
	saveReport: function(i){this.ajax('JCommentsReportComment',null, 'comments-report-form');return true;},
	cancelReport: function() {var d=this.$('comments-inline-report');if(d){d.innerHTML='';}},
	closeReport: function(m){this.cancelReport();this.showMessage(m,'info','comments-inline-report');},
	error:function(m,t,n){if(this.form!=null){this.form.error(n);}if(!t||t==''){t=this.form_id;}this.showMessage(m,'error',t);},
	message:function(m,t){if(!t||t==''){t=this.form_id;}this.showMessage(m,'info',t);},
	showMessage: function(m,c,t){
		clearTimeout(this.fadeTimer);var fe=this.$('comments-form-message');var af=this.$(t);
		if(fe){fe.parentNode.removeChild(fe);}fe=JComments.prototype.createElement('div','comments-form-message','');
		if(af){JComments.prototype.moveElement(fe,af,af.firstChild);}else{alert(m);return;}
		if(!c){c='info';}fe.className='comments-form-message-'+c;
		fe.innerHTML=m;	fe.style.display='block';JComments.prototype.setOpacity(fe.id,100);
		this.fadeTimer=setTimeout(function(){JComments.prototype.fade('comments-form-message', 100, 0, 1000);}, 6000);
	},

	subscribe: function(o,g){return this.ajax('JCommentsSubscribe',arguments);},
	unsubscribe: function(o,g){return this.ajax('JCommentsUnsubscribe',arguments);},
	updateSubscription: function(m,t){var e=this.$('comments-subscription');if(e){var jc=this;e.innerHTML=t;e.onclick=m?function(){jc.unsubscribe(jc.oi,jc.og);return false;}:function(){jc.subscribe(jc.oi,jc.og);return false;};e.blur();}},
	go: function(l){window.open(l);return false;}
};












//======================================
//ajax.js





/* based on xajax Javascript library (http://www.xajaxproject.org) */
if (!window.jtajax) {

function jtAJAX()
{
	this.options = {url: '',type: 'post',nocache: true,data: ''};

	this.$ = function(id) {if(!id){return null;}var o=document.getElementById(id);if(!o&&document.all){o=document.all[id];}return o;};
	this.extend = function(o, e){for(var k in (e||{}))o[k]=e[k];return o;};
	this.encode = function(t){return encodeURIComponent(t);};
	this.setup = function(options) {this.options = this.extend(this.options, options);};

	this.xhr = function()
	{
		var xhr = null;
		if ('undefined' != typeof XMLHttpRequest) xhr = new XMLHttpRequest();
		if (!xhr && 'undefined' != typeof ActiveXObject) {
			var msxmlhttp = new Array('Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP');
			for (var i=0;i<msxmlhttp.length;i++){try{xhr=new ActiveXObject(msxmlhttp[i]);}catch(e){xhr=null;}}
		}       	
		return xhr;
	};
	
	this.form2query = function(sId)
	{
		var frm = this.$(sId);
		if (frm && frm.tagName.toUpperCase() == 'FORM') {
			var e = frm.elements, query = [];
			for (var i=0; i < e.length; i++) {
				var name = e[i].name, value;
				if (!name) continue;
				if (e[i].type && ('radio' == e[i].type || 'checkbox' == e[i].type) && false === e[i].checked) continue;
				if ('select-multiple' == e[i].type) {
					for (var j = 0; j < e[i].length; j++) {
						if (true === e[i].options[j].selected)
							query.push(name+"="+this.encode(e[i].options[j].value));
					}
				} else { query.push(name+"="+this.encode(e[i].value)); 
				}
			}
			return query.join('&');
		}
		return '';
	};

	this.startLoading = function(){};
	this.finishLoading = function(){};

	this.ajax = function(options)
	{
		TooltipsDelete();
		var xhr = this.xhr();
		if (!xhr) return false;
		var o = this.extend(this.options, options);
		var url = o.url, jtx = this;
		var r=url;var h=location.hostname,d,i1,i2;i1=r.indexOf('://');if(i1!=-1){i2=r.indexOf('/',i1+3);if(i2!=-1){d=r.substring(i1+3,i2);if(d!=h){if(location.port!=''){h=h+':'+location.port;}r=r.replace(d,h);url=r;}}}
		
		if ('get' == o.type) {
			if (true === o.nocache) {
				var ts=new Date().getTime();
				url += (url.indexOf("?")==-1 ? '?' : '&') + '_jtxr_' + ts;
			}
			if (o.data) {
				url += (url.indexOf("?")==-1 ? '?' : '&') + o.data;
				o.data = null;
			}
		}

		xhr.open(o.type.toUpperCase(), url, true);

		if ('post' == o.type)
			try {xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");}catch(e){}
		if (true === o.nocache)
			xhr.setRequestHeader('If-Modified-Since', 'Thu, 01 Jan 1970 00:00:00 GMT');

		xhr.onreadystatechange = function() {
			if (xhr.readyState != 4) return;
			jtx.finishLoading();
			if (xhr.status==200) {
				jtx.processResponse(xhr.responseText);
			}
			delete xhr;
			xhr = null;
		};
		try {
			jtx.startLoading();
			xhr.send(o.data);
		} catch(e) { jtx.finishLoading(); }

		delete jtx;
		delete xhr;
		delete o;
		return true;
		
	};

	this.call = function(sFunction, aArgs, sType, sForm)
	{
		var params = 'jtxf=' + this.encode(sFunction);
		if (aArgs) {
			for (var i=0;i<aArgs.length;i++) {
				params += '&jtxa[]=' + this.encode(aArgs[i]);
			}
		} else if (sForm) {
			params += '&' + this.form2query(sForm);
		}

		this.ajax({type: sType, data: params});
		return true;
	};

	this.processResponse = function(sText)
	{
		if(sText==='') return false;
		if(sText.substring(0,3)!='[ {'){var idx=sText.indexOf('[ {');sText=sText.substr(idx);}
		var result;try {result=eval(sText);}catch(e){}
		if ('undefined' == typeof result) {return false;}

		var cmd, id, property, data, obj = null;

		for (var i=0;i<result.length;i++) {
			cmd 		= result[i]['n'];
			id 		= result[i]['t'];
			property	= result[i]['p'];
			data 		= result[i]['d'];
			obj 		= this.$(id);

			switch(cmd) {
				case 'as': if(obj){eval("obj."+property+"=data;");} break;
				case 'al': if(data){alert(data);} break;
				case 'js': if(data){eval(data);} break;
				default: this.error('Unknown command: ' + cmd);break;
			}
		}
		
		delete result;
		delete cmd;
		delete id;
		delete property;
		delete data;
		delete obj;
		CommentsJS();TooltipsDraw();
		return true;
		
	};

	this.error = function(){};
}
var jtajax = new jtAJAX();
}






/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
