// JavaScript Document
$(document).ready(
	function () {
		
		SortableCreate();
		
	}
);


function SortableCreate(){
	//$('a.closeEl').bind('click', toggleContent);
	$('a.closeWlist').bind('click', toggleWidgetlist);
	
	$('div.groupWrapper').sortable(
				{
					connectWith: 'div.groupWrapper',
					handle: 'div.itemHeader',
					helper: 'sortHelper',
					tolerance: 'pointer',
					stop:function(event, ui) {
                                 var sortorder = {};
                                 var loop =1;
                                 $("div.groupWrapper").each(function(){
																 
                                 sortorder["sort"+loop] =$(this).sortable("toArray");
                                         loop = loop + 1 ;
                    			 });
								
								$.post("ajax.php",{ action: "saveBox",data:sortorder});
								 	
								
					}
					/*
					onStart : function()
					{
						$.iAutoscroller.start(this, document.getElementsByTagName('body'));
					},
					onStop : function()
					{
						$.iAutoscroller.stop();
					}
					*/
				}
			);	
	$('div.groupWrapper').disableSelection();
}

function serializess(s)
{
	var serial = s.sortable('serialize');
	alert(serial);
	
	
	$.ajax({
		   type:"POST",
		   url:"ajax.php",
		   data:"action=saveBox&"+serial.hash});	

};


var toggleOptions = function(e)
{
	var targetOptions = $('#Options', this.parentNode.parentNode);
	if (targetOptions.css('display') == 'none') {
		targetOptions.css('display','');
		$(this).html('[-]');
		
	} else {
		targetOptions.css('display','none');
		$(this).html('[+]');
	}
	return false;
};

var toggleContent = function(e)
{
	var targetContent = $('div.itemContent', this.parentNode.parentNode);
	if (targetContent.css('display') == 'none') {
		
		targetContent.slideDown(300);
		$(this).html('[-]');
		
		
	} else {
		targetContent.slideUp(300);
		$(this).html('[+]');
		
	}
	return false;
};

var toggleWidgetlist = function(e)
{
	var targetWidgetlist = $('div.Widgetlist', this.parentNode.parentNode);
	if (targetWidgetlist.css('display') == 'none') {
		//targetWidgetlist.slideDown(300);
		targetWidgetlist.css('display','');
		$(this).html('Elrejt');
		loadWidgets();
		
	} else {
		
		//targetWidgetlist.slideUp(300);
		targetWidgetlist.css('display','none');
		$(this).html('Tartalom hozzáadása');
		
		
	}
	return false;
};


var ShareContent = function(e)
{
	// <div class='ShareContent'><a href='#' class='ShareButton' rel='<cikkid>'>Megosztom</a></div>	
	
	var targetContent = $('div.ShareContent', this.parentNode.parentNode);
	var cikkid = $(this).attr("rel");
	targetContent.html('Várj...');
	$.post("ajax_users.php",{ action: "addStreamContent",cid:cikkid }, function(xml) {
				
				
				targetContent.html(xml);
				//$('#Onef'+uid).addClass("MyFriend");
			});
	
};


function SharePopup(e,app)
{
	var popup = $('#popup');
	var targetContent = $(this,e.parentNode);
	var cikkid = $(e).attr("rel");
	showMask('#popup');
	$('div.YoutubeHolder').hide();
	popup.html('<div align="center"><br><br><br><img src="images/ajax_loading.gif" align="center"><br><br>Várj...</div>');
	$.post("ajax_users.php",{ action: "StreamForm",cid:cikkid,app_id:app }, function(xml) {
		popup.html(xml);
		
		$('.ContentSharethumb_step a').bind('click',function() {
			var v = $(this).attr("href");
			document.SaveStream.media_src.value = v;
			WizardTab($(this).attr("rel"));
			return false;
		});
		
		//$('#Onef'+uid).addClass("MyFriend");
	});
	
}

function ShareCheck(e,target)
{
	var application_id = 0;
	var m = "";
	var matches_url = e.match("((http|https)(:\/\/))?([a-zA-Z0-9]+[.]{1}){2}[a-zA-z0-9]+(\/{1}[a-zA-Z0-9]+)*\/?", "i");
	if(matches_url){
		var application_id = 5; 
		m = matches_url[0];
		//alert(matches[0]);	
	}
	
	
	var matches = e.match(/^(https?:\/\/)?([^\/]*\.)?youtube\.com\/watch\?([^]*&)?v=\w+(&[^]*)?/i);
	if(matches){
		var application_id = 6; 
		m = matches[0];
		//alert(matches[0]);	
	}
	

	
	if(application_id>0){										  
	var targetContent = $('#'+target);
	targetContent.show();
	targetContent.html('<div align="center"><br><br><br><img src="images/ajax_loading.gif" align="center"><br><br>Várj...</div>');
	
	$.post("ajax_users.php",{ action: "checkStreamAttachement",app_id:application_id,cid:m }, function(xml) {
		targetContent.html(xml);
		targetContent.show();
		//$('#Onef'+uid).addClass("MyFriend");
	});
	
	
	}
	
}

function ShareVideo(e)
{
	var popup = $('#popup');
	var targetContent = $(e.parentNode);
	var cikkid = $(e).attr("rel");
	targetContent.hide();
	$('div.YoutubeHolder').hide();
	showMask('#popup');
		popup.html('Várj...');
	$.post("ajax_users.php",{ action: "StreamForm",cid:cikkid,app_id:"6" }, function(xml) {
		popup.html(xml);
		//$('#Onef'+uid).addClass("MyFriend");
	});
	
}

function ShareSave(e){
		var popup = $('#popup');
		var textar = $('#SaveStreamText').val();
		var cikkid = $('#SaveStreamCid').val();
		popup.html('várj...');
		$.post("ajax_users.php",{ action: "addStreamContent",cid:cikkid,text:textar }, function(xml) {
				
				//popup.html(xml);
				
				
				$('#mask').hide();
				$('.window').hide();
				
				
				//$('#Onef'+uid).addClass("MyFriend");
			});
}

function ShareSave2(e){
		var popup = $('#popup');
		var params = {};
		var Form = $(e);
		Form.find("input, textarea")		
		.each(function() {
			params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
		});
		 
		
		
		$.post("ajax_users.php", params, function(xml){
		
				
			//	popup.html(xml);
				$('div.YoutubeHolder').show();
				
				$('#mask').hide();
				$('.window').hide();
				
				$('#wrapper').find('.StreamFormButton').each(function() {
					reloadWidget($(this).attr("rel"));	
				});
				
			});
}


function StreamFormOpen(e){
	
	var targetDiv = $(e.parentNode);
	var uwid = $(e).attr("rel");
	$(e).hide();
	$('#StreamForm'+uwid,targetDiv.childNode).show();
	
}

function StreamFormSave(e,uwid){
	
	var targetDiv = $(e.parentNode.parentNode);
	var text = $("textarea#text",targetDiv).val();
	if(text==""){
		alert("Nem írtál be semmit!");
		return false;
	}
	else{
	 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=reloadWidget&uwid="+uwid+"&saveStream=true&text="+text,
			   success: function(html){$("#content"+uwid).html(html);}
			   });	
	}
}

function StreamFormSave2(e,uwid){
		var targetDiv = $(e.parentNode.parentNode);
		var params = {};
		var Form = $(targetDiv);
		Form.find("input, textarea")		
		.each(function() {
			params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
		});
		 
		
		
		$.post("ajax_users.php", params, function(xml){
		
			 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=reloadWidget&uwid="+uwid,
			   success: function(html){$("#content"+uwid).html(html);}
			   });	
			
			
			});
}


function loadWidgets() {
	
	if($("#widget_list").html()==""){
			$("#widget_list").html('<div class="loading">...</div>');
			$.post("ajax.php",{ action: "listwidgets" }, function(xml) {
				
				
				$("#widget_list").html(xml);
				listChannels()
			});
	}
			
}

function addMessages(xml) {
			$("#widget_list").html('');
			$("message",xml).each(function(id) {
				message = $("message",xml).get(id);
				$("#widget_list").prepend("<b>"+$("text",message).text()+
											"<br />");
			});
		}

function addWidget(wid,param){
	$("#sort_1").prepend('<div id="newWidget"><div class="loading_widget">Ide teszem...Várj</div></div>');
	$("div.Widgetlist").css('display','none');
	$('a.closeWlist').html('Tartalom hozzáadása');
	$.ajax({
		    type:"POST",
			url:"ajax.php",
			data:"action=addwidget&widgetid="+wid+"&config="+param,
			success: function(xml){
				    $("#newWidget").remove();
					
					$("#sort_1").prepend(xml);
					SortableCreate();
				   }
			   });
	/*
	$.post("ajax.php",{ action: "addwidget",widgetid: wid }, function(xml) {
				$("#newWidget").remove();
				$("#sort1").prepend(xml);
				SortableCreate();
				
			});	
	*/
	
}



function testWidget(wid,param){
	$("#TEST_widget").html('<div id="newWidget">Egy pillanat...</div>');

	$.ajax({
		    type:"POST",
			url:"ajax.php",
			data:"action=testWidget&widgetid="+wid,
			success: function(xml){
				    $("#newWidget").remove();
					$("#TEST_widget").prepend(xml);
				   }
			   });
	/*
	$.post("ajax.php",{ action: "addwidget",widgetid: wid }, function(xml) {
				$("#newWidget").remove();
				$("#sort1").prepend(xml);
				SortableCreate();
				
			});	
	*/
	
}


function closeWidget(uwid){
	if(confirm('Biztos bezárod ezt az widget-et?')){
	$("#"+uwid).remove();
	$.post("ajax.php",{ action: "closewidget",uwid: uwid });
	}
}

function optionWidget(uwid){
	var l = $('#'+uwid+' a.configWidget')
	l.attr('onClick',"reloadWidget('"+uwid+"');");
	l.html('Mégsem');
	
	$("#content"+uwid+"").html('<div class="loading">Egy pillanat...</div>');
	$.post("ajax.php",{action:"optionsWidget",uwid:uwid},function(html){
			$("#content"+uwid+"").html(html);
			
			});
}
function hideWidget(uwid)
{
	var targetContent = $("#content"+uwid+"");
	var targetLink = $("#"+uwid+" .closeEl");
	if (targetContent.css('display') == 'none') {
		targetLink.html('[-]');
		targetContent.slideDown(300);
		$.post("ajax.php",{ action: "saveToggle",uwid:uwid,tgl:0});
		
	} else {
		targetContent.slideUp(300);
		targetLink.html('[+]');
		$.post("ajax.php",{ action: "saveToggle",uwid:uwid,tgl:1});
	}
	return false;
};


function colorWidget(uwid){
	var targetbox = $("#colorbox"+uwid+"");
	targetbox.html('szinek');
	
	/*
	
	if (targetbox.css('display') == 'none') {
		targetbox.css('display','');
		//targetbox.blur(function(){targetbox.hide()});
	}
	else {
	targetbox.css('display','none');
	}
	*/
}

function reloadWidget(uwid){
	var l = $('#'+uwid+' a.configWidget');
	l.attr('onClick',"optionWidget('"+uwid+"');");
	l.html('Várj...');
	$.post("ajax.php",{action:"reloadWidget",uwid:uwid},function(html){
			$("#content"+uwid).html(html);
			l.html('Beállítás');
			});
}
function reloadWidgetPage(uwid,Page){
	
	$.post("ajax.php",{action:"reloadWidget",uwid:uwid,page:Page},function(html){
			$("#content"+uwid).html(html);
			});
}





function W_RSS_Saveform(wid)
{
	
		
		var V_url = $("#W_RSS_url"+wid).val();
		var V_count = $("#W_RSS_count"+wid).val();
		var V_type = $("#W_RSS_type"+wid).val();
		var V_info = $("#W_RSS_info"+wid+"1").val();
		var V_config =  V_url+"|"+V_count+"|"+V_type+"|"+V_info;
		$("#content"+wid+"").html('<div class="loading">Ezt most elmentem...</div>');
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};
		
function W_CONTENT_Saveform(wid)
{
	
		
		var V_cat = $("#W_CONTENT_cat"+wid).val();
		var V_count = $("#W_CONTENT_count"+wid).val();
		var V_filter = ($("#W_CONTENT_filter"+wid).val());
		var V_type = $("#W_CONTENT_type"+wid).val();
		var V_title = ($("#W_CONTENT_title"+wid).val());
		
		$("#content"+wid+"").html('<div class="loading">Ezt most elmentem...</div>');
		var V_config =  V_cat+"|"+V_count+"|"+V_filter+"|"+V_type;
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};
		
function W_YOUTUBE_Saveform(wid)
{
	
		

		var V_filter = ($("#W_YOUTUBE_filter"+wid).val());
		var V_max = $("#W_YOUTUBE_maximum"+wid).val();
		var V_title = ($("#W_YOUTUBE_title"+wid).val());
		
		$("#content"+wid+"").html('<div class="loading">Ezt most elmentem...</div>');
		var V_config =  V_filter+"|"+V_max;
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};		


function W_WEBNOTE_Saveform(wid)
{
	
		
		var V_text = ($("#W_WEBNOTE_text"+wid).val());
		var V_title = ($("#W_WEBNOTE_title"+wid).val());
		
		$("#content"+wid+"").html('<div class="loading">Ezt most elmentem...</div>');
		var V_config =  V_text;
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};	


function W_FLICKER_Saveform(wid)
{
	
		
		var V_text = ($("#W_FLICKER_link"+wid).val());
		var V_title = ($("#W_FLICKER_title"+wid).val());
		var V_type = ($("#W_FLICKER_type"+wid).val());
		
		$("#content"+wid+"").html('<div class="loading">Jobb, ha elmentem...</div>');
		var V_config =  V_text+"|"+V_type;
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};	

function W_MYGALLERY_Saveform(wid)
{
	
		
		var V_text = ($("#W_MYGALLERY_link"+wid).val());
		var V_title = ($("#W_MYGALLERY_title"+wid).val());
		var V_type = ($("#W_MYGALLERY_type"+wid).val());
		var V_autoplay = ($("#W_MYGALLERY_autoplay"+wid).val());
		var V_caption = ($("#W_MYGALLERY_caption"+wid).val());
		
		$("#content"+wid+"").html('<div class="loading">Jobb, ha elmentem...</div>');
		var V_config =  V_text+"|"+V_type+"|"+V_caption+"|"+V_autoplay;
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};	

function W_MULTI_Saveform(wid)
{
		var V_config = "";
		fo = $('form#FORM_WIDGET_'+wid);
		fo.find("input,textarea,select")
		.filter(".FIELD_ENABLE")
		.each(function() {
					   
			V_config +=	 this.value+"|";  
			
		});
		
	
		var V_title = ($("#W_MULTI_title"+wid).val());
		
		$("#"+wid+" .titleWidget").html(V_title);
		
		
		$("#content"+wid+"").html('<div class="loading">Jobb, ha elmentem...</div>');
		
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
		
		};	


function W_WEATHER_Saveform(wid)
{
	
		
		var V_text = ($("#W_MULTI_place"+wid).val());
		var V_title = ($("#W_MULTI_title"+wid).val());
		var V_color = ($("#W_MULTI_color"+wid).val());
		
		$("#content"+wid+"").html('<div class="loading">Jobb, ha elmentem...</div>');
		var V_config =  V_text+"||"+V_color;
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};	

function W_ADDWIDGETS_Saveform(wid)
{
	
		
		var V_text = ($("#W_ADDWIDGETS_type"+wid).val());
		var V_title = ($("#W_ADDWIDGETS_title"+wid).val());
		
		$("#content"+wid+"").html('<div class="loading">Jobb, ha elmentem...</div>');
		var V_config =  V_text;
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};	


function W_LINKS_Addurl(wid)
{
	
		
		var V_link = escape($("#W_LINKS_link"+wid).val());
		
		
		$("#content"+wid+"").html('<div class="loading">Egy pillanat...</div>');
		
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=reloadWidget&uwid="+wid+"&W_LINKS_link="+V_link,
			   success: function(html){$("#content"+wid).html(html);}
			   });	
	
		};	



function W_LINKS_Removeurl(wid,lid)
{
	$("#content"+wid+"").html('<div class="loading">Leveszem...</div>');
	$.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=reloadWidget&uwid="+wid+"&W_LINKS_linkid="+lid,
			   success: function(html){$("#content"+wid).html(html);}
			   });	
	
};	


function W_ARF_Saveform(wid)
{
	
		
		var V_cat = $("#W_ARF_val"+wid).val();
		var V_title = escape($("#W_ARF_title"+wid).val());
		
		$("#content"+wid+"").html('<div class="loading">Ezt most elmentem...</div>');
		var V_config =  V_cat+"|";
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};


function W_TWITTER_add(wid)
{

		var V_link = ($("#W_TWITTER_text"+wid).val());
		
		
		$("#TWEET"+wid+"").html('Egy pillanat...');
		
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=reloadWidget&uwid="+wid+"&save=true&text="+V_link,
			   success: function(html){$("#content"+wid).html(html);}
			   });	
	
};	


function W_TVMUSOR_Saveform(wid)
{
	
		
		var V_cat = $("#W_TVMUSOR_1_val"+wid).val();
		var V_cat2 = $("#W_TVMUSOR_2_val"+wid).val();
		var V_cat3 = $("#W_TVMUSOR_3_val"+wid).val();
		var V_cat4 = $("#W_TVMUSOR_4_val"+wid).val();
		var V_cat5 = $("#W_TVMUSOR_5_val"+wid).val();
		var V_title = escape($("#W_TVMUSOR_title"+wid).val());
		
		$("#content"+wid+"").html('<div class="loading">Ezt most elmentem...</div>');
		var V_config =  V_cat+"|"+V_cat2+"|"+V_cat3+"|"+V_cat4+"|"+V_cat5+"|";
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};

function W_PURSE_Add(wid)
{
	
		
		var V_price = escape($("#W_PURSE_price"+wid).val());
		var V_dateY = escape($("#W_PURSE_dateY"+wid).val());
		var V_dateM = escape($("#W_PURSE_dateM"+wid).val());
		var V_dateD = escape($("#W_PURSE_dateD"+wid).val());
		var V_title = ($("#W_PURSE_title"+wid).val());
		var V_cat 	= 	escape($("#W_PURSE_cat"+wid).val());
		var V_order = escape($("#W_PURSE_order"+wid).val());
		
		
		$("#content"+wid+"").html('<div class="loading">Egy pillanat...</div>');
		
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=reloadWidget&uwid="+wid+"&W_PURSE_price="+V_price+"&W_PURSE_date="+V_dateY+"-"+V_dateM+"-"+V_dateD+"&W_PURSE_cat="+V_cat+"&W_PURSE_order="+V_order+"&W_PURSE_title="+V_title,
			   success: function(html){$("#content"+wid).html(html);}
			   });	
	
		};	

function W_PURSE_Saveform(wid)
{
	
		
		var V_mode = ($("#W_PURSE_mode"+wid).val());
		var V_money = ($("#W_PURSE_money"+wid).val());
		var V_title = ($("#W_PURSE_title"+wid).val());
		var V_cat = ($("#W_PURSE_cat"+wid).val());
		
		$("#content"+wid+"").html('<div class="loading">Jobb, ha elmentem...</div>');
		var V_config =  V_mode+"|"+V_money+"|"+V_cat;
		
		
		 $.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=saveBoxParam&&uwid="+wid+"&title="+V_title+"&config="+V_config,
			   success: function(){reloadWidget(wid);}
			   });	
	
		};	

function W_PURSE_Removeitem(wid,mid,page)
{
	if(confirm("Biztosan kitörlöd ezt a tételt?")){
	//$("#content"+wid+"").html('<div class="loading">Leveszem...</div>');
	$.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=reloadWidget&uwid="+wid+"&W_PURSE_delmid="+mid+"&page="+page,
			   success: function(html){$("#content"+wid).html(html);}
			   });	
	}
	else return false;
};

function W_PURSE_Page(wid,page)
{
	
	$.ajax({
			   type:"POST",
			   url:"ajax.php",
			   data:"action=reloadWidget&uwid="+wid+"&page="+page,
			   success: function(html){$("#content"+wid).html(html);}
			   });	
	
	
};


function ToggleButton(eid,bid,text1,text2)
{
	var targetContent = $("#"+eid);
	var targetButton = $(bid);
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		targetButton.html(text2);
		
	} else {
		targetContent.slideUp(300);
		targetButton.html(text1);
	}
	return false;
};




function Options(){
	if($('#Options').css('display')=="none"){
		$('#Options').css('display',"");
			
				$("#Options").html('<div class="loading">Egy pillanat...</div>');
				$.post("ajax.php",{action:"options"},function(html){
				$("#Options").html(html);
				optionsColorpicker();
				});
			
	}
	else{
		$('#Options').css('display',"none");
		//$("#Options").html();
	}
	
};

function Wizard(){
	if($('#Options').css('display')=="none"){
		$('#Options').css('display',"");
			
				$("#Options").html('<div class="loading">Egy pillanat...</div>');
				
				
				$.ajax({
					type:"POST",
					url:"ajax.php",
					data:"action=wizard",
					success: function(xml){
							
							$("#Options").html(xml);
						   }
					   });
				
				/*
				$.post("ajax.php",{action:"wizard"},function(html){
				$("#Options").html(html);
				
				});
				*/
			
	}
	else{
		$('#Options').css('display',"none");
		//$("#Options").html();
	}
	
};
function optionsColorpicker(){
	
	var l = $('#ID_FORM_backgroundcolor input');
	l.hide();
	
	var Selector =  $('#ID_FORM_backgroundcolor');
	Selector.prepend('<div id="backgroundcolor_Selector" class="colorSelector2"><div style="background-color: "></div></div>');
	Selector.append("<a>Háttér törlése</a>").bind('click', function(){
		$('#page').css('backgroundColor', '');
		$('body').css('backgroundColor', '');
		$('#backgroundcolor_Selector div').css('backgroundColor', '');
		l.val('');
	});	
	
	$('#backgroundcolor_Selector').ColorPicker({
		color: l.val(),
		onShow: function (colpkr) {
		$(colpkr).fadeIn(500);
		return false;
		},
		onHide: function (colpkr) {
			$(colpkr).fadeOut(500);
			return false;
		},
		onChange: function (hsb, hex, rgb) {
			$('#page').css('backgroundColor', '#' + hex);
			$('body').css('backgroundColor', '#' + hex);
			$('#backgroundcolor_Selector div').css('backgroundColor', '#' + hex);
			l.val(hex);
		}
	});
	$('#backgroundcolor_Selector div').css('backgroundColor', '#' + l.val());
	
	
	
	var l2 = $('#ID_FORM_colorstyle input');
	l2.hide();
	
	var Selector2 =  $('#ID_FORM_colorstyle');
	Selector2.prepend('<div id="colorstyle_Selector" class="colorSelector2"><div style="background-color: "></div></div>');
	Selector2.append("<a>Szinséma törlése</a>").bind('click', function(){
		$('div.itemHeader').css('backgroundColor', '');
		$('#colorstyle_Selector div').css('backgroundColor', '');
		l2.val('');
	});	
	
	$('#colorstyle_Selector').ColorPicker({
		color: l2.val(),
		onShow: function (colpkr) {
		$(colpkr).fadeIn(500);
		return false;
		},
		onHide: function (colpkr) {
			$(colpkr).fadeOut(500);
			return false;
		},
		onChange: function (hsb, hex, rgb) {
			$('div.itemHeader').css('backgroundColor', '#' + hex);
			$('#colorstyle_Selector div').css('backgroundColor', '#' + hex);
			l2.val(hex);
		}
	});
	$('#colorstyle_Selector div').css('backgroundColor', '#' + l2.val());
	
	
	
	/*
	$('#colorstyle').ColorPicker({
		onSubmit: function(hsb, hex, rgb, el) {
			$(el).val(hex);
			$('div.itemHeader').css('backgroundColor', '#' + hex);
			$(el).ColorPickerHide();
		},
		onBeforeShow: function () {
			$(this).ColorPickerSetColor(this.value);
		}
	})
	.bind('keyup', function(){
		$(this).ColorPickerSetColor(this.value);
	});	
	*/
	$.post("ajax.php",{action:"listHeaderPic"},function(html){
			$("#ID_FORM_headerpic").append(html);
			}
	);						
									
	
}

function checkName(pn){	
	$("#nameValid").html('várj....');
	$.post("ajax.php",{action:"checkName",pagename:pn.value},function(html){
			$("#nameValid").html(html);
			}
	);	
}

function Deletepage(){
	
	if(confirm("Biztosan törlöd ezt az oldalt?")){
		GO('?deletethispage=true');
	}
	else return false;
	
}

function SelectHeaderPic(t){
	
	$("body").css({'backgroundImage':'url('+t+')'});	
	$("#headerpic").val(t);
}



function OptionsTab(t){

	var v = $('.Options-tab');
	var n = $('.navigationTab');
	for(i=0;i<v.length;i++){
				
				if(v[i].id == t ){
					v[i].style.display = "";
					
				}
				else{ 
				v[i].style.display = "none";
				
				}
	}
	
}

function WizardTab(t){

	var v = $('.Options-tab');
	for(i=0;i<v.length;i++){
				
				if(v[i].id == t ){
					v[i].style.display = "";
					
				}
				else{ 
				v[i].style.display = "none";
				
				}
	}
	
}





function WidgetTab(t){

	var v = $('.widget-tab');
	var n = $('.widget-navigationTab');
	for(i=0;i<v.length;i++){
				
				if(v[i].id == t ){
					v[i].style.display = "";
					
				}
				else{ 
				v[i].style.display = "none";
				
				}
	}
	
}
OptionsTab('Options_tab15');



function listChannels() {
                        var tabContainers = $('div.WC_channels > div');
                        tabContainers.hide().filter(':first').show();
                        
                        $('div.WC_channels ul.tabNavigation a').click(function () {
                                tabContainers.hide();
                                tabContainers.filter(this.hash).show();
                                $('div.WC_channels ul.tabNavigation a').removeClass('selected');
                                $(this).addClass('selected');
                                return false;
                        }).filter(':first').click();
                }

function Login(){
	showMask('Login');
	var regbox = $('#Register');
	regbox.css('display','none');
	var popbox = $('#popup');
	popbox.css('display','none');
	var loginbox = $('#Login');
	if (loginbox.css('display') == 'none') {
		loginbox.css('display','');
		
		
	} else {
		loginbox.css('display','none');
		
	}
	return false;
}

function Register(){
	showMask('Register');
	var loginbox = $('#Login');
	loginbox.css('display','none');
	var popbox = $('#popup');
	popbox.css('display','none');
	var regbox = $('#Register');
	if (regbox.css('display') == 'none') {
		regbox.css('display','');
		
		
	} else {
		regbox.css('display','none');
		
	}
	return false;
}

