// JavaScript Document
var globalDivId;
function changeParentMenu(alignment){
   $.ajax({
   type: "GET",
   url: globalJSLiveURL+"ajax.php",
   data: "choice=changeParentMenu&align="+alignment,
   success: function(responseTxt){
     $("#parentMenuId").html(responseTxt);
   }
 });

	/*
	Please dont delete the following code the above code needs to be tested
	$.post("../ajax.php?choice=changeParentMenu&align="+alignment, function (responseTxt){																			
																			$("#parentMenuId").html(responseTxt);
																			});*/
	}

function showSubMenu(masterId){	
if(masterId!=0){	
	var globalJSLiveURL="../";
	$.ajax({
	type: "GET",
	url: globalJSLiveURL+"ajax.php", 
    data: "choice=showSubMenu4Content&masterId="+masterId,	
	success: function(responseTxt){
		var arrayresponse=responseTxt.split(":#;");
		var value=arrayresponse[0];
		var extra=arrayresponse[1];
		$("#hiddenHasSubMenu").val(extra);
		$("#id2DisplaySubMenu").html(value);	 
	}	
	});	
}
}

function showpage(myurl, pg, div_id, code){	
	
	var extraData='';	
	if(trimAll(code)!='')
		extraData+="&code="+code;
	
	$.ajax({
	type: "GET",
	url: globalJSLiveURL+"ajax.php", 
    data: "choice="+myurl+"&pg="+pg+"&div_id="+div_id+extraData,
	beforeSend:function(){	
		//alert("i m loading");	
		$("#"+div_id).html("Loading...");
		},
	success: function(responseTxt){
		//alert("success");
	 $("#"+div_id).html(responseTxt);
	}	
	});	
}

function myAjax(myurl,myData){
	$.ajax({
	type: "GET",
	url: myurl, 
    data: myData,
	beforeSend:function(){
		$("#"+globalDivId).html("Updating...");
		},
	success: function(responseTxt){	 
	 $("#"+globalDivId).html(responseTxt);
	}
	});	
	}
function cancelAjaxChange(typeFor, idDIV, idofRow){	
	$("#"+idDIV).html("<div id=div"+idDIV+" onclick='showTxtBox2Edit(\""+typeFor+"\",\""+idDIV+"\",\""+idofRow+"\")'>"+$("#oldValue_"+typeFor+"_"+idDIV).val()+"</div>");	
	}
function showTxtBox2Edit(typeFor, idDIV, idofRow){		
		var textBoxNSaveCancel='<input type="hidden" name="oldValue_'+typeFor+'_'+idDIV+'" id="oldValue_'+typeFor+'_'+idDIV+'" value="'+($("#div"+idDIV).html())+'"  /><input type="text" name="newValue_'+typeFor+'_'+idDIV+'" id="newValue_'+typeFor+'_'+idDIV+'" value="'+($("#div"+idDIV).html())+'"  /> <a href="javascript:void(0)" onclick="saveNewContent(\''+typeFor+'\',\''+idDIV+'\',\''+idofRow+'\')">save</a>&nbsp;&nbsp;<a href="javascript:void(0)" onclick="cancelAjaxChange(\''+typeFor+'\',\''+idDIV+'\',\''+idofRow+'\')">cancel</a>';		
		$("#"+idDIV).html(textBoxNSaveCancel);		
}
function saveNewContent(typeFor,idDIV, idofRow){
	globalDivId=idDIV;
	var newValue=$("#newValue_"+typeFor+"_"+idDIV).val();
	var masterValue=$("#newValue").val();	
	myAjax("../ajax.php","choice="+typeFor+"&idDIV="+idDIV+"&idofRow="+idofRow+"&newValue="+newValue);
	}
