


function mypopup(url,height,width)
{
    mywindow = window.open(url, "mywindow", "location=0,status=0,scrollbars=1,  width="+height+",height="+width+"");
    mywindow.moveTo(0, 0);
}

function emptyText(d){
	
$(d).val("");	
}


$(function() {
	
	
	
	
	
	//create the buttons	
	$(".button a").button();
		
	
	
	//uploading button
	$('.submit').bind('click', function() {


	
	});

	
	
	
	});

function toggle(d){
	
	$(d).slideToggle('slow');

	
}
function openModalDefined(d,h,y){
		    $(d).dialog({
		
			height: h,
			width: y,
			modal: true
			

			});
	
	
	
	
}
function ajaxModal(d,h,y,url){
		    $(d).dialog({
		
			height: h,
			width: y,
			modal: true

			});
	
	
	$(d).load(url +"&ms=" + new Date().getTime());
	
}
function startEditor(){
	
	tinyMCE.init({
	// General options
	 mode : "exact",
    elements : "txaEditableContent",

	theme : "advanced",
	plugins : "style,layer,advhr,advimage,advlink,emotions,inlinepopups,paste,directionality,noneditable,nonbreaking,template,",

	// Theme options
	theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect,emotions",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor|,forecolor,backcolor",


	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : false,
 
  relative_urls : true




});

}
function showHide(show,hide){
	
$(hide).hide();
$(show).show();
	
}

function loadPage(div,page){
	
	var timestamp = Number(new Date()); 
$(div).load("ajax.php?function=getpage&page=" + page + "&time=" + timestamp);

	
}

function ajaxForm(form,update){
	
	
	
// prepare the form when the DOM is ready 
$(document).ready(function() { 
    // bind form using ajaxForm 
    $(form).ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: update, 
 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() { 
            $(update).fadeIn('slow'); 
			$('.hide').html('<img src=/images/loading.gif >');
        } 
    }); 
});


	
	
	
}




function postToAjax(formname,messagecontainer,posturl){
			
			   
    	$.ajax({
			 
		  type: "POST",
		  url:  "ajax.php?function=" + posturl,
		 
		  data:  $('#' + formname).serialize(),
		  success: function(msg){
   								$('#' + messagecontainer).empty();
								$('#' + messagecontainer).append( msg);
								
							  }
 		});
		
	
	
}


function confirmModal(div,refreshpage){
	
$(document).ready(function() { 
		$(div).dialog({
			modal: true,
			buttons: {
				Ok: function() {
					if(refreshpage == 1){
						
					}else{
					$(this).dialog('close');
					}
				}
			}
		});	
});
	
}



function openModal(div){
			
	$(div).dialog({
			modal: true,
			width: 720
		});

	

	
}

function openModalwithEdtior(div){
			
	tinyMCE.execCommand('mceRemoveControl', false, 'txaEditableContent');
	
$(div).dialog({
			modal: true,
			width: 720
		});

	tinyMCE.execCommand('mceAddControl', false, 'txaEditableContent');
	
tinyMCE.execCommand('mceFocus', false, 'txaEditableContent');                    

	

	
}
