$(document).ready( function(){ initGala()});
function initGala()
{

	$(".jbtns").button();
}

function submitForm(_this)
{
	try{
	_url = $(_this).attr('action');
	_name = $(_this).attr('name');
	_callBack = window[_clear(_name)];
	
	_method = $(_this).attr('method');
	_methodFunction =window["do"+_method];
	_data = $(_this).serialize();	
	if(! $.isFunction(_callBack))
	{
		throw "Err1: "+_clear(_name);
	}
	
	if($.isFunction(_methodFunction))
	{
		_methodFunction(_url,_data,_callBack,_this)
	}else
	{
		throw "Err1: "+_method;
	} 
	
	}catch(e){ alert(e)}
	
	return false;
	
}

function _clear(str)
{
	regexp = new RegExp( /^[A-Za-z0-9]$/);
	_return=str.replace(regexp,'');
	_return = _return.replace('-','');
	return _return;
}
var dopost = function(_url,_data,_callBack,_this)
{
	/*alert(_url);
	alert(_data);
	alert(_callBack);*/
	$.post(_url,_data,function(data){_callBack(data,_this)});
}
var votingform = function (_html,_this){ $(_this).replaceWith(_html);}


var youtubePlayer=function (url,element)
{
	
	_string = '<object width="420" height="300">'+
  '<param name="movie" value="'+url+'">'+
  '</param>'+
  '<param name="allowFullScreen" value="true">'+
  '</param>'+
  '<param name="allowscriptaccess" value="always">'+
  '</param>'+
  '<embed src="'+url+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"  width="420" height="300"></embed>'+
'</object>';
$(element).animate({width:420, height:300},50,function(){ $(element).html(_string);});
	
}

var youtubePlayerThumbAnumate=function(place)
{
	
	_over = place.replace('#',"#ov_");
	_p = $(place).position();
	_w  = $(place).width();
	_h  = $(place).height();
	
	_nt = _p.top+ Math.round(_h/2)-8;
	_nl = _p.left+ Math.round(_w/2)-8;
	
	//$(_over).css({'position':'absolute','top':_nt,left:_nl,opacity:0.8});
	
	$(place).find('img').filter(':first').remove().appendTo(place);
	
	setTimeout("youtubePlayerThumbAnumate('"+place+"')",5000);
	
	
}

var  viewPlayer_Jw = function(place,thumb,bideo)
{
	
	//skin=http%3A//content.longtailvideo.com/skins/glow/glow.zip&amp;stretching=fill&amp;controlbar.position=over
	
	jwplayer(place).setup({
		flashplayer: "/upload/player.swf",
		file: bideo,
		image:thumb,
		height: 270,
		width: 480,
		skin:'/upload/glow.zip',
		stretching:'fill'
		
});
}
function reloadCaptcha(path)
{
	$("#captImage").attr('src','/kcaptcha/index.php?chk='+Math.random(150000));
}


/*ARCHIVE PAGE*/
var  _data = new Array();
var  beforeShowDayS =function(date){
	
	dateX = date.valueOf();
var _exist = 	$.inArray(dateX , _data );


	if(_exist > -1)
	{
		//$("#archive_calendar2").append("-<i>"+dateX+"</i>-");
		 return [true,"ui-state-highlight",""];

	}
	else
	{
		//$("#archive_calendar2").append("-<u>"+dateX+"</u>-");
		return [false, ""];
	} }
function __initArchivePage(){
for(i in _jsonData)
{
	d = new Date(_jsonData[i].data_days);
	_d = d.valueOf()
	_data.push(_d);
	
	
	
	
};

$('#archive_calendar').datepicker({dateFormat: 'yy/mm/dd',beforeShowDay:beforeShowDayS,onSelect:onDateSelect });
 }
var onDateSelect= function(dateText, inst) { window.location = "/home/archive/"+dateText; }

	

