﻿// New Ajax using ProtoTypefunction ajax_request(area, url, data) {	 		//document.getElementById('interface_err_messages').innerHTML = "Loading...";		var anyTime = new Date;    var myAjax = new Ajax.Updater(        area,url,        {method: 'post', parameters: data, onComplete: ajax_response,onFailure: reportError, evalScripts: true}    );				}function ajax_ReLoadArea(layer,url,pars){	var url;	var pars;	var layers;	var myAjax = new Ajax.Updater(		{success: layer},		url,		{			method: 'post',			parameters: pars,			onFailure: reportError,			evalScripts: true		});} function reportError(request){	alert('Sorry. There was an error.'+request);}function ajax_request_without_area(url, data){		var anyTime = new Date;    var myAjax = new Ajax.Request(        url,        {method: 'post', parameters: data, evalScripts: true}    );}function ajax_response(originalRequest) {    if(!bHasRedirect) {        document.getElementById(area).innerHTML = originalRequest.responseText();        //process originalRequest.responseText;    }    else {        bHasRedirect = false;    }}// Confirm Link		function confirmLink(theLink, confirmMsg){    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {        return true;    }    var is_confirmed = confirm(confirmMsg);    if (is_confirmed) {        theLink.href += '&is_js_confirmed=1';    }    return is_confirmed;} 	// AJAX LOADERfunction ajaxLoader(url,id) {  if (document.getElementById) {    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();  }  if (x) {    x.onreadystatechange = function() {      if (x.readyState == 4 && x.status == 200) {        el = document.getElementById(id);                el.innerHTML = x.responseText;      }    }    x.open("GET", url, true);    x.send(null);  }}// Expand and Collapsefunction expandCollapse() {	for (var i=0; i<expandCollapse.arguments.length; i++) {		var element = document.getElementById(expandCollapse.arguments[i]);		element.style.display = (element.style.display == "none") ? "block" : "none";	}}function toggleBox(szDivID, iState) // 1 visible, 0 hidden{	if(iState=='0'){		document.getElementById(szDivID).setStyle({ top: '-10000',left:'-10000'});	}    if(document.layers)	   //NN4+    {       document.layers[szDivID].visibility = iState ? "show" : "hide";    }    else if(document.getElementById)	  //gecko(NN6) + IE 5+    {        var obj = document.getElementById(szDivID);        obj.style.visibility = iState ? "visible" : "hidden";    }    else if(document.all)	// IE 4    {        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";    }}//////  Layer Positioningvar hide  = true;function showhide(obj){	var x = new getObj(obj);	hide = !hide;	x.style.visibility = (hide) ? 'hidden' : 'visible';	setLyr(obj,'testP');}function putCenter(item) {	item = $(item);	var xy = item.getDimensions();	var win = this.windowDimensions();	var scrol = this.scrollOffset();	if((win[0] / 2) + scrol[0] - (xy.width / 2)<0){		item.style.left=0+ "px";	}else{		item.style.left = (win[0] / 2) + scrol[0] - (xy.width / 2) + "px";	}	if((win[1] / 2) + scrol[1] - (xy.height / 2)<0){		item.style.top = 0+"px";	}else{		item.style.top = (win[1] / 2) + scrol[1] - (xy.height / 2) + "px";	}}function fullScreen(item) {  item = $(item);  var win = this.windowDimensions();  var scrol = this.scrollOffset();  item.style.height = scrol[1] + win[1] + "px";}function windowDimensions() {  var x, y;  if (self.innerHeight) {    // all except Explorer    x = self.innerWidth;    y = self.innerHeight;  } else if (document.documentElement && document.documentElement.clientHeight) {    // Explorer 6 Strict Mode    x = document.documentElement.clientWidth;    y = document.documentElement.clientHeight;  } else if (document.body) {    // other Explorers    x = document.body.clientWidth;    y = document.body.clientHeight;  }  if (!x) x = 0;  if (!y) y = 0;  arrayWindowSize = new Array(x,y);  return arrayWindowSize;}function scrollOffset() {  var x, y;  if (self.pageYOffset) {    // all except Explorer    x = self.pageXOffset;    y = self.pageYOffset;  } else if (document.documentElement && document.documentElement.scrollTop) {    // Explorer 6 Strict    x = document.documentElement.scrollLeft;    y = document.documentElement.scrollTop;  } else if (document.body) {    // all other Explorers    x = document.body.scrollLeft;    y = document.body.scrollTop;  }  if (!x) x = 0;  if (!y) y = 0;  arrayScrollOffset = new Array(x,y);  return arrayScrollOffset;}function setMenuLyr(obj,lyr,xloc,yloc){		var newX = findPosX(obj);	var newY = findPosY(obj);	var x = new getObj(lyr);		var totalY=parseFloat(newY)+parseFloat(yloc);	var totalX=parseFloat(newX)+parseFloat(xloc);	// places the div in the proper position for the initial load	x.style.top = totalY + 'px';	x.style.left = totalX + 'px';		// shows the layer when activated	x.style.visibility = 'visible';}function setLyr(obj,lyr,xloc,yloc){		var newX = findPosX(obj);	var newY = findPosY(obj);	var x = new getObj(lyr);	if(yloc!=''){		var totalY=parseFloat(newY)+parseFloat(yloc);	}else{		var totalY=20;	}	if(xloc!=''){		var totalX=parseFloat(newX)+parseFloat(xloc);	}else{		var totalX=20;	}		x.style.top = totalY + 'px';	x.style.left = totalX + 'px';}function findPosX(obj){	var curleft = 0;	if (obj.offsetParent)	{		while (obj.offsetParent)		{			curleft += obj.offsetLeft			obj = obj.offsetParent;		}	}	else if (obj.x)		curleft += obj.x;	return curleft;}function findPosY(obj){	var curtop = 0;	var printstring = '';	if (obj.offsetParent)	{		while (obj.offsetParent)		{			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;			curtop += obj.offsetTop			obj = obj.offsetParent;		}	}	else if (obj.y)		curtop += obj.y;	window.status = printstring;	return curtop;}function getObj(name){ if (document.getElementById) {	   this.obj = document.getElementById(name);	   this.style = document.getElementById(name).style; } else if (document.all) {	   this.obj = document.all[name];	   this.style = document.all[name].style; } else if (document.layers) {	   if (document.layers[name])	   {	   	this.obj = document.layers[name];	   	this.style = document.layers[name];	   }	   else	   {	    this.obj = document.layers.testP.layers[name];	    this.style = document.layers.testP.layers[name];	   } }}//////////////function loading_msg(lyr,msg) {var msg;msg=msg+'<img src="/admin/images/blank.gif" alt="" width="16" height="16" align="absmiddle" border="0">';document.getElementById(lyr).innerHTML=msg;}function loading_img(lyr) {var msg;msg='<img src="/admin/ajax/loading1.gif" alt="Loading..." width="64" height="52" align="absmiddle" border="0"><BR>';document.getElementById(lyr).innerHTML=msg;}function popUp(URL,width,height) {day = new Date();id = day.getTime();eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + "');");}function openPopUp() {		window.self.name = "MainWindow";	NewWindow = window.open('/modules/ImageManager/admin_default.php?image_full=<? print $my_content_rows["image_full"]; ?>','SmartSitePopup','width=450, height=400, toolbar=no, status=no, resizeable=no, scrollbars=yes');	if (!NewWindow.opener) NewWindow.opener = self;	//new_window.focus();}/// Live Edit Functionsfunction stopDoingSomething(e){	if (!e) var e = window.event;	e.cancelBubble = true;	if (e.stopPropagation) e.stopPropagation();}var buildDropDown=function(area_id, args){	var content='<div id="dropDownLiveEditMenu_#{id}" class="ADMIN_QUICKLINK"><ul class="Option_Area_DropDown"><li><a class="contentAreaName" onclick="alert(\"creating style_options id=${id}\")" href="javascript:void(null)"><img width="17" height="17" alt="Styles" src="/images/live_edit/styles.png"/> <span>Styles</span></a></li><li><a onclick="loading_img(\'LiveEditWindow\');toggleBox(\'LiveEditWindow\',1);putCenter(\'LiveEditWindow\');ajax_request(\'LiveEditWindow\',\'/modules/Pages/ajax_edit_wrapper_mod.php\',\'content_type=TextImage&mod=Pages&pg=ajax_edit_mod&request=edit&weight=1.00&page_id=1&location_id=3&page_data_id=299\');" href="javascript:void(null)"><img width="16" height="17" alt="Icon Editbar Edit" src="/images/live_edit/icon_editbar_edit.png"/> <span>Edit</span</a></li><li><a class="contentAreaName" onclick="alert(\"creating new_content_area id=${id}\")" href="javascript:void(null)"><img width="15" height="17" alt="Icon Editbar New" src="/images/live_edit/icon_editbar_new.png"/> <span>New</span></a></li><li><a href="javascript:void(null)" onclick="alert(\"Toggleing area for draft id=${id}\")"><img width="12" height="17" alt="Set as Active" src="/images/live_edit/icon_editbar_activate_on.png"/> <span>Hide</span></a></li><li><a onclick="return confirmLink(this, \'Are you sure you want to delete this?\')" href="javacript:void(null)"><img width="17" height="17" alt="Icon Editbar Delete" src="/images/live_edit/icon_editbar_delete.png"/> <span>Delete</span></a></li></ul></div>';	DropDown=new Template(content);	output= DropDown.evaluate({id: area_id});	var output=document.createElement('div');	output.id='testing';	alert(output.id);}var buildNewContentArea=function(page_id, page_data_id, location_id, weight, postion_under, single_column, top_offset, left_offset, ancestor){	if($('LiveEditDiv')){		$('LiveEditDiv').remove();	}	var LiveEditDiv=document.createElement('div');	LiveEditDiv.id='LiveEditDiv';	if(ancestor==undefined||$(ancestor)==undefined){		ancestor='LiveEditWindow';	}	var LiveEditWindowAncestors=$(ancestor).ancestors();	LiveEditWindowAncestors[0].appendChild(LiveEditDiv);	$('LiveEditDiv').addClassName('SmallColumnRow');	loading_img('LiveEditDiv');	//alert(top_offset);	if(top_offset==undefined){		gotop=-5;	}else{		gotop=top_offset;	}	if(left_offset==undefined){		goleft=17;	}else{		goleft=left_offset;	}		setLyr($(postion_under),'LiveEditDiv',gotop,goleft);	toggleBox('LiveEditDiv',1);	//Load New area 	ajax_request('LiveEditDiv', '/modules/Pages/admin_page_content_block_editor_mod.php', 'request=new&page_id='+page_id+'&location_id='+location_id+'&page_data_id='+page_data_id+'&weight='+weight+'&single_column='+single_column);	Event.observe($('LiveEditDiv'), 'mouseout', function(event){			if(checkMouseLeave (this, event)){				$("LiveEditDiv").remove();			};		}	);	}var dropdown_area = Class.create();//Object.extend(dropdown_area.prototype, MySuperClass);dropdown_area.prototype = {		initialize: function() {		this.page_id;		this.location_id;		this.page_data_id;		this.weight;		this.display;		this.area_parent;		this.wrapper;	},	get_dropdown: function(){		ajax_request('contentAreaDropDown_'+this.page_data_id, '/ajax_calls/edit_dropdown.php', "page_id="+this.page_id+"&location_id="+this.location_id+"&page_data_id="+this.page_data_id+"&weight="+this.weight+"&display="+this.display);		//alert(this);		Event.stopObserving($('contentAreaDropDownTrigger_'+this.page_data_id), 'mouseover', this.get_dropdown_fx);	},	build_area: function(){		var add_shortCuts=$('contentAreaDropDownTrigger_'+this.page_data_id);		var wrapper = document.createElement('div');		wrapper.id='contentAreaDropDown_'+this.page_data_id;		wrapper=$(wrapper);		var LiveEditWindowAncestors=$('LiveEditWindow').ancestors();		LiveEditWindowAncestors[0].appendChild(wrapper);		wrapper=$('contentAreaDropDown_'+this.page_data_id);		wrapper.addClassName('edit_dropdown_container');		wrapper.addClassName('initial_hidden');		wrapper.addClassName('drop_down_reset_items');		//alert(this.page_data_id);		setLyr(add_shortCuts,'contentAreaDropDown_'+this.page_data_id, 1,1);		this.wrapper=wrapper;	}}var hideLiveEditWindow=function(){	new Effect.MoveBy("LiveEditWindow", "-999", "-999");}var setMenu=function (menu_type) {	document.getElementById('menu_type_page').style.display = "none";	document.getElementById('menu_type_link').style.display = "none";	document.getElementById('menu_type_module').style.display = "none";	document.getElementById('menu_type_pulldown').style.display = "none";	if (menu_type == 'Page') { document.getElementById('menu_type_page').style.display = "block";}	if (menu_type == 'Link') { document.getElementById('menu_type_link').style.display = "block";}	if (menu_type == 'Module') { document.getElementById('menu_type_module').style.display = "block";}	if (menu_type == 'Pulldown') { document.getElementById('menu_type_pulldown').style.display = "block";}}//-->