<?php
/*
  osCommRes, Services Online
  http://www.oscommres.com

  Copyright (c) 2005 osCommRes

  Released under the GNU General Public License
  
  Freeway eCommerce from ZacWare
http://www.zac-ware.com/freeway

Copyright 2007 ZacWare Pty. Ltd
*/
// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
  if ($messageStack->size > 0) {
    echo $messageStack->output();
  }
  if($HTTP_SESSION_VARS['new_product']) $HTTP_SESSION_VARS['new_product']="";
?>
<script language="javascript">
	var currentMenu;
	var cEvent;
	var currentPath;
	var prev_focus_id;
	var IE = document.all?true:false;
	function show_menu(path){
		//hide_cpopup(true);
		if (currentMenu){
			hide_popup(true);
		}
		show_pop=document.getElementById("pop_"+path);
		
		path_splt=path.split("_");
		currentMenu=path_splt[1];
		currentPath=path;
		var ele1=document.getElementById("menu_l2_"+currentMenu+"_1");
		var ele2=document.getElementById("menu_l2_"+currentMenu+"_2");
		var ele3=document.getElementById("menu_l2_"+currentMenu+"_3");
		var anc=document.getElementById("menu_l2_"+currentMenu+"_a");
		var tclass="";
		var tclass1="";
		ele1.prev_class=ele1.className;
		ele2.prev_class=ele2.className;
		ele3.prev_class=ele3.className;
		ele1.prev_text=ele1.innerHTML;
		if (ele1.innerHTML=="+"){
			tclass="menu_l2_hover";
			tclass1="menu_l2_hover_m";
		} else {
			tclass="menu_l2_select";
			tclass1="menu_l2_hover_nom";
		}
		ele1.innerHTML='&nbsp;';
		ele1.className=tclass+"_left";
		ele2.className=tclass+"_right";
		ele3.className=tclass1;
		anc.prev_class=anc.className;
		anc.className="menu_l2_select_hover";
		
		if (!show_pop) return;
		show_popup(show_pop);
		
		if (!IE) document.captureEvents(Event.MOUSEMOVE);
	    document.onmousemove=check_menu;
	}
	function check_menu(e){
		if(typeof(currentMenu)!="undefined"){
			var con=document.getElementById("menu_l2_"+currentMenu+"_con");
			if (IE) { // grab the x-y pos.s if browser is IE
				tempX = event.clientX + document.body.scrollLeft;
				tempY = event.clientY + document.body.scrollTop;
			}
			else {  // grab the x-y pos.s if browser is NS
				tempX = e.pageX;
				tempY = e.pageY;
			}
			//document.getElementById("test_element").innerHTML=tempY<=con.pos_y1;
			if (!(tempX>=con.pos_x && tempX<=con.pos_x1 && tempY>=con.pos_y && tempY<=con.pos_y1)){
				hide_popup(true);
			}
		}
	}
	function hide_menu(path){
		path_splt=path.split("_");
		currentMenu=path_splt[1];
		show_pop=document.getElementById("pop_"+path);
		if (!show_pop) return;
		hide_popup(true);
	}
	function show_popup(){ 
		if(typeof(currentMenu)!="undefined"){
			show_pop=document.getElementById("pop_"+currentPath);
			if (!show_pop) return;
			var con=document.getElementById("menu_l2_"+currentMenu+"_con");
			var ele2=document.getElementById("menu_l2_"+currentMenu+"_2");		
			if (!con.pos_x){
				pos=getAnchorPosition("menu_l2_"+currentMenu+"_con");
				var last=document.getElementById("menu_l2_"+currentMenu+"_last");
				if (last){
					if (!ele2.pos_x) {
						var pos1=getAnchorPosition("menu_l2_"+currentMenu+"_2");
						ele2.pos_x=pos1.x;
					}
					con.pos_x=(parseInt(ele2.pos_x)+18)-parseInt(show_pop.style.width);
				} else {
					con.pos_x=pos.x;
				}
				con.pos_y=pos.y;
				con.pos_x1=con.pos_x+parseInt(show_pop.style.width)+2;
				con.pos_y1=con.pos_y+parseInt(show_pop.style.height)+40;
			}
			//show_pop.style.le
			show_pop.style.left=con.pos_x+2;
			show_pop.style.top=con.pos_y+22;
			show_pop.style.display="";
		}
	}
	function hide_popup(check_flag){
		show_pop=document.getElementById("pop_"+currentPath);
		if (!check_flag && show_pop) return;
		
		if (show_pop){
			document.onmousemove='';
			if (!IE) document.releaseEvents(Event.MOUSEMOVE);
			show_pop.style.display="none";
		}
		if(typeof(currentMenu)!="undefined"){
			var ele1=document.getElementById("menu_l2_"+currentMenu+"_1");
			var ele2=document.getElementById("menu_l2_"+currentMenu+"_2");
			var ele3=document.getElementById("menu_l2_"+currentMenu+"_3");
			var anc=document.getElementById("menu_l2_"+currentMenu+"_a");
			ele1.className=ele1.prev_class;
			ele2.className=ele2.prev_class;
			ele3.className=ele3.prev_class;
			ele1.innerHTML=ele1.prev_text;
		}
		anc.className=anc.prev_class;
		currentMenu=0;
		currentPath="";
		return false;
	}
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}
// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}

	function toggle_left_panel(panelid){
		var element=document.getElementById("panel_"+panelid);
		var img=document.getElementById("img_"+panelid);
		if (element.style.display=="none"){
			element.style.display="";
			img.src="images/template/ico_arrow_up.gif";
		} else {
			element.style.display="none";
			img.src="images/template/ico_arrow_down.gif";
		}
	}	
	function toggle_panel(title,funname,hide_prev,expand){				
		var panel=document.getElementById("panel_"+title);
		if(panel){
			if (panel.style.display=="none"){
				panel.style.display="";
				if (title=='Description' && !panel.editor){
					editor_init();
					panel.editor=true;
				}
			} else panel.style.display="none";
		}
		if(hide_prev==true)
		{
			if(prev_focus_id!="" && prev_focus_id!=title)
			{
				if(document.getElementById("img_"+prev_focus_id))
				{
					//var img=document.getElementById("img_"+prev_focus_id);
					var panel=document.getElementById("panel_"+prev_focus_id);
					panel.style.display="none";
					//img.src="images/template/panel_down.gif";
				}
			}
			prev_focus_id=title;
		}
		if(typeof(display_category) != "undefined"){
			panel_expand="panel_" + title;
			disp(panel);
		}
		if(parseInt(expand)>0)
			panel_expand_id = expand;
		//if(funname==true){	
		if(title=='Attribute_Inventory_control'){
			doaction();
		}
	}
	function toggle_panel1(title,funname,hide_prev,expand){				
		var img=document.getElementById("img_"+title);
		var panel=document.getElementById("panel_"+title);
		if (panel.style.display=="none"){
			img.src="images/template/panel_up.gif";
			panel.style.display="";
		} else {
			panel.style.display="none";
			img.src="images/template/panel_down.gif";
		}
		if(hide_prev==true)
		{
			if(prev_focus_id!="" && prev_focus_id!=title)
			{
				if(document.getElementById("img_"+prev_focus_id))
				{
					var img=document.getElementById("img_"+prev_focus_id);
					var panel=document.getElementById("panel_"+prev_focus_id);
					panel.style.display="none";
					img.src="images/template/panel_down.gif";
				}
			}
			prev_focus_id=title;
		}
		if(typeof(display_category) != "undefined"){
			panel_expand="panel_" + title;
			disp(panel);
		}
		if(parseInt(expand)>0)
			panel_expand_id = expand;
			
		if(title=='Attribute_Inventory_control'){
			doaction();
		}
		var jump_select=""; 
		if(document.form_jump && document.form_jump.category)
		{
		jump_select=document.form_jump.category;
		jump_select.value=title+'#'+expand;
		}
	}
	// For category panel
	var prev_category='';
	var open_level=0;
	var open_ids=Array();
	function toggle_category_panel(category_id,level,opn){ 
		var res_display=document.getElementById("res_display");		
		if(res_display && res_display.style.display=="") res_display.style.display="none";
		var img=document.getElementById("panel_"+category_id+"_img");
		var panel=document.getElementById("panel_"+category_id+"_content");
		
		show=false;		
		if (panel && panel.style.display=="none"){
			show_cat_panel(category_id);
			show=true;
		} else {
			//if (opn!=true && open_ids[level] && open_ids[level]==category_id && level==0) return;
			hide_cat_panel(category_id);
			
		}
		if (show){
			if (prev_category!=""){
				if (level<=open_level){
					hide_cat_panel(open_ids[level]);
					open_ids=open_ids.slice(0,level);
				}
			}
			open_level=level;
			prev_category=category_id;
			open_ids[level]=category_id;
			do_page_fetch("fetch_sub_list","",category_id,1,level+1);
		} else {
			open_ids=open_ids.slice(0,level);
			open_level=level-1;
		}		
	}
	function hide_cat_panel(category_id){
		var img=document.getElementById("panel_"+category_id+"_img");
		var panel=document.getElementById("panel_"+category_id+"_content");
		if(panel) {
			panel.style.display="none";
			panel.innerHTML="";	
		}
		if(img) img.src="images/template/panel_down.gif";
	}
	function show_cat_panel(category_id){
		var img=document.getElementById("panel_"+category_id+"_img");
		var panel=document.getElementById("panel_"+category_id+"_content");
		if (panel) panel.style.display="";
		if (img) img.src="images/template/panel_up.gif";
	}

	function toggle_focus(element,mode){
		if (mode==2){
			element.className="inputSelect";
		//For IE only
		if(element.type == "text" || element.type == "password")var intID=setInterval(function(){element.focus();clearInterval(intID);},10); //For IE only
		} else {
			element.className="inputNormal";
		}
	}
	var current_cmenu="";
	// Common popup menu
	function show_cpopup(menu_id,adjust_x,adjust_y){
		show_pop=document.getElementById("pop_common_"+menu_id);
		var con=document.getElementById("pop_common_"+menu_id+"_con");
		if (!con.pos_x){
			pos=getAnchorPosition("pop_common_"+menu_id+"_con");
			con.pos_x=pos.x;
			con.pos_y=pos.y;
			con.pos_x1=con.pos_x+parseInt(show_pop.style.width);
			con.pos_y1=con.pos_y+parseInt(show_pop.style.height)+20;
		}

		show_pop.style.left=con.pos_x+adjust_x;
		show_pop.style.top=con.pos_y+adjust_y;
		show_pop.style.display="";
		current_cmenu=menu_id;
		if (!IE) document.captureEvents(Event.MOUSEMOVE);
	    document.onmousemove=check_cpopup;
	}
	function check_cpopup(e){
		if(currentMenu=="") return;
		
		var con=document.getElementById("pop_common_"+current_cmenu+"_con");
		if (IE) { // grab the x-y pos.s if browser is IE
			tempX = event.clientX + document.body.scrollLeft;
			tempY = event.clientY + document.body.scrollTop;
		}
		else {  // grab the x-y pos.s if browser is NS
			tempX = e.pageX;
			tempY = e.pageY;
		}
		//document.getElementById("test_element").innerHTML=tempY<=con.pos_y1;
		if (!(tempX>=con.pos_x && tempX<=con.pos_x1 && tempY>=con.pos_y && tempY<=con.pos_y1)){
			hide_cpopup(true);
		}
	}
	function hide_cpopup(check_flag){ 
		show_pop=document.getElementById("pop_common_"+current_cmenu);
		if (!check_flag && show_pop) return;
		
		if (show_pop){
			document.onmousemove='';
			if (!IE) document.releaseEvents(Event.MOUSEMOVE);
			show_pop.style.display="none";
		}
		current_cmenu="";
	}
	function validate_search(){
		var phrase  = document.search_links.search_link.value;
		if(phrase=='') return false;
		else 
		  document.search_links.submit();
		
	}
</script>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td valign="top" width="120" nowrap="nowrap">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
		</table>
		</td>		
		
		<td id="formtable" valign="top">
		<table border="0" style="vertical-align:top;" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td valign="top">
				<table border="0" width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td valign="top">
						<table border="0" width="100%" cellpadding="0" cellspacing="0"  class="cell_bg_navig">
						<tr height="25">
								<td id="headerNavigation" nowrap="nowrap">&nbsp;&nbsp;
									<img src="images/template/ico_home.gif"/>
									<?php echo $breadcrumb->trail('&nbsp;&nbsp;' .tep_image(DIR_WS_IMAGES . 'template/ico_navig.gif') . '&nbsp;&nbsp;'); ?>
								</td>
								<td align="right" nowrap="nowrap">
								<table border="0" cellpadding="0" cellspacing="0" id="navig_row">
									<tr>	<?php 
																		 
									 //echo tep_draw_form('add_links', FILENAME_QUICK_LINKS, '' ,'post');
									 $hlink='<div id="quick_action_delete" style="display:none"><a href="javascript:add_links.submit();"> Delete from Quick Links </a></div><div id="quick_action_insert" style="display:none"><a href="javascript:add_links.submit();"> Add to Quick Links </a></div>';									 
													if( ($HTTP_GET_VARS['top']) && ($HTTP_GET_VARS['top'] =='1') && (basename($PHP_SELF)!=FILENAME_QUICK_LINKS) ) { 
													if(tep_session_is_registered('filename')) tep_session_unregister('filename') ;
													if(tep_session_is_registered('params')) tep_session_unregister('params');
													$filename=basename($PHP_SELF);													
													$params=tep_get_all_get_params();
													if(($params!='') && (substr($params,-1)=='&')){  
													 	$params=substr($params,0,-1);
													}
													tep_session_register('filename');
													tep_session_register('params');
													$links_select_query=tep_db_query('select * from '. TABLE_QUICK_LINKS ." where filename='".$filename. "' and params='".$params."' and login_group_id='". $login_groups_id."'");
												 
												   // echo 'select * from '. TABLE_QUICK_LINKS ." where filename='".$filename. "' and params='".$params."' and login_group_id='". $login_groups_id."'";
												?>
      											<?php  echo tep_draw_form('add_links', FILENAME_QUICK_LINKS, '' ,'post');?>
												<?php 
												   if($_SESSION){
												   tep_session_register('actions_value');  
												   $_SESSION['actions_value']='insert';
												   tep_session_register('delete_value');
												   $_SESSION['delete_value']='delete';	
												   }else{
												   $HTTP_POST_VARS['actions_value']='insert';
												   $HTTP_POST_VARS['delete_value']='delete';
												   }
												?>
										<!--		 <input type="hidden" name="quick" value="insert" id="quicks"/>		-->
										<!--		 <input type="hidden" name="quick1" value="delete" />	-->
												<?php
													if(tep_db_num_rows($links_select_query)>0){
													   $fetch_array = tep_db_fetch_array($links_select_query);
											  ?>
														<input type="hidden" value="delete" name="quick_del" />
									   					<input type="hidden" name="filename" id="filename" value="<?php echo tep_output_string($fetch_array['filename']); ?>" />
									  					<input type="hidden" id="params" name="params" value="<?php echo tep_output_string($fetch_array['params']); ?>" />
									  					<input type="hidden" id="links_id" name="links_id" value="<?php echo tep_output_string($fetch_array['links_id']); ?>" />
														<input type="hidden" value="1" name="top" id="top" />
												<?php		$hlink='<a href="javascript:add_links.submit();" id="quick_action_delete"> Delete from Quick Links </a>';
															echo '<input type="hidden" name="quick1" value="delete" id="quick_del"/>';
													  }else{
														    $hlink='<a href="javascript:add_links.submit();" id="quick_action_insert"> Add to Quick Links </a>';	
															echo '<input type="hidden" name="quick" value="insert" id="quick_ins"/>';
													       }
														    ?>	 
													</form>
										  <?php } ?>
									

										<td width="100" nowrap="nowrap" align="center">
											User: <b><?php echo $login_first_name;?></b>
										</td>
										<td width="120" nowrap="nowrap"><?php echo '<a href="' . tep_href_link(FILENAME_ADMIN_ACCOUNT) . '">Account Settings</a>';?></td>
										<td width="60" nowrap="nowrap"><?php echo '<a href="' . tep_href_link(FILENAME_LOGOFF) . '">Signout</a>';?></td>
										<td width="60" nowrap="nowrap"><?php echo '<a target="_blank" href="http://www.openfreeway.org/documentation/">Help</a>';?></td>
										<td width="160" nowrap="nowrap"><?php echo $hlink;?></td>
										<td width="10"></td>
									</tr>
								</table>
								</td>
							</tr>
						</table>
						</td>
					</tr>
					<tr>
						<td valign="top" class="cell_bg_navig_l21">
						<table border="0" width="100%" cellpadding="0" cellspacing="0" class="cell_bg_navig_l2"  height="34">
							<tr>
								<td class="page_menu_title"><?php echo HEADING_TITLE;?>&nbsp;</td>
								<?php $return=""; if(basename($PHP_SELF)=='customers_mainpage.php') $return="return=csl";?>
								<form name="search_links" action="<?php echo tep_href_link(FILENAME_SEARCH_LINKS,$return);?>" method="post" onsubmit="javascript: return validate_search();" >
								<td width="20"><img src="images/template/input_left.gif"/></td>
								<td width="120">
								<input type="text" name="search_link" id="search_link" class="roundText" value="<?php echo tep_output_string($HTTP_POST_VARS['search_link']); ?>" /></td>
								<td width="20"><a><img src="images/template/input_right.gif" onclick="javascript:validate_search();"/></a></td>
								</form>
								<td width="50">&nbsp;</td>
							</tr>
						</table>
						</td>
					</tr>
					<tr>
						<td valign="top">
						<table border="0" width="100%" cellpadding="2" cellspacing="0" id="menu_l2" class="cell_bg_navig_l3" height="60">
							<?php
								$level2_menus=array();
								$top_menu=&$menu_arr["2"];
								reset($top_menu);
							//	print_r($top_menu);
								$icnt=0;
								$prev_key='';
								while(list($key,$value)=each($top_menu)){
									if ($value["show"] && $value["file"]!=''){
										$level2_menus[]=$key;
										if ($value["params"]!='') $value["params"]=tep_get_expanded_params($value["params"]);

										$value["params"].="top=1&mPath=" . $value['path'];
										$temp_path=$GLOBALS["l1"] . "_" . $key;
										
										if ($icnt==0 || $icnt%4==0) {
											if ($icnt>0) echo '<td id="menu_l2_' . $prev_key .'_last">&nbsp;</td>';
											echo '<tr>';
										}
										$temp_class1="";
										if ($value["select"]){
											$temp_class="menu_l2_select";
											$temp_class1="menu_l2_hover_nom";
										} else {
											$temp_class="menu_l2_normal";
										}
										echo  '<td style="width:220px;" valign="top" id="menu_l2_' . $key .'_con"><table border="0" cellpadding="0" cellspacing="0" height="22"><tr><td width="20" id="menu_l2_' . $key . '_1" class="' . $temp_class . '_left" style="text-align:center">' . (isset($navig_list[$temp_path])?'+':'&nbsp;') .'</td><td id="menu_l2_' . $key . '_3" class="' . $temp_class1 . '">' .
												'<span id="menu_l2_' . $key . '_a" class="' .($value["select"]?'menu_l2_select_hover':'menu_l2_select_normal') . '" onMouseOver="javascript:show_menu(\'' . $temp_path .'\')" onMouseOut="javascript:hide_popup()" onclick="javascript:location.href=\'' . tep_href_link($value["file"],$value["params"]) . '\';">' . $value["text"] . '</a></td><td width="20" id="menu_l2_' . $key . '_2" class="' . $temp_class . '_right">&nbsp;</td>' . 
												'</tr></table></td>';
										$prev_key=$key;
										$icnt++;
												
									}
									
								} //while
								echo '<td>&nbsp;</td>';
							?>
						</table>
						<?php
							for ($icnt=0,$n=count($level2_menus);$icnt<$n;$icnt++){
								$menu=$level2_menus[$icnt];
								$temp_path=$GLOBALS["l1"] . "_" . $menu;
								if (isset($navig_list[$temp_path])){
									$sub_list=&$navig_list[$temp_path];
									$n1=count($sub_list);
									$temp_height=ceil($n1/3)*20+10;
									$temp_width=320;
									$temp_count=2;
									if ($n1>=6) {
										$temp_width=450;
										$temp_count=3;
									}
									echo '<div style="width:' . $temp_width . 'px;height:' . $temp_height . 'px;position:absolute;display:none;padding:10px;z-index:999" id="pop_' . $temp_path . '" class="menu_l3">' .
											'<table border="0" cellpadding="2" cellspacing="0" style="z-index:9999">';
									for ($jcnt=0;$jcnt<$n1;$jcnt++){
										$value=$menu_arr["3"][$sub_list[$jcnt]];
										
										if (trim($value["params"])!='') {
											$value["params"]=tep_get_expanded_params($value["params"]);
										}
										$value["params"].="top=1&mPath=" . $value['path'];
										if ($jcnt==0 || $jcnt%$temp_count==0) echo '<tr>';
										//if(!$value['file']) $value['file']=FILENAME_SHOP_ADMIN_MEMBERS;
										
										$show = true;
										if($value['file']=='events_instructor_payments.php'){
											if(strtolower($login_groups_type)=='instructor')$value['file'] = 'events_payments.php';
											if(strtolower($login_groups_type) != 'top administrator' && strtolower($login_groups_type) != 'instructor')$show = false;
										}
										if($show)echo  '<td style="width:200px;" valign="top"><a ' .($value["select"]?'class="menu_l3_select"':'') . ' href="' . tep_href_link($value["file"],$value["params"]) . '">' . $value["text"] . '</a></td>';
									}
									echo '</table></div>';
								}
							}
						?>
						<iframe border="0" style="position:absolute;display:none;padding:10px;z-index:999" id="menu_adjust"></iframe>
						</td>
					</tr>
				</table>
				</td>
			</tr>
 			<tr>
				<td id="holetable" valign="top" height="600">
				<?php show_alert_message();?>
		
		<?php function show_alert_message($mode=0)
			{
			//tep_session_unregister("show_alert_message"); 
			//$mode==1 when called from upgrade page;
			 if(!tep_session_is_registered("show_alert_message") || $mode==1){
					$rates = load_xml_file("https://www.openfreeway.org/fileadmin/freeway/freeway.xml");
					//$rates = load_xml_file("freeway.xml");
					$start_pos=strpos($rates,"<Message>");
					$end_pos=strrpos($rates,"</Message>");

					$alert_title="";
					$alert_content="";
					$show_check_box=false;
					$general_create_date='';
					$general_update_date='';
					if($start_pos>=0 && $end_pos>0) //success result
					{
						if($mode==0)
							require(DIR_WS_CLASSES . 'XPath.php');
							$xPath_header =&new XPath(FALSE, $xmlOptions);
							$xPath_header->importFromString(xmlentities_r($rates));
							$items=$xPath_header->match('Freeway_Text[1]/Message_List[1]/Message');
							$item_count=count($items);
							for($i=0; $i<$item_count; $i++){
								$start_date= $xPath_header->getData($items[$i]."/Display_Start");
								$end_date=$xPath_header->getData($items[$i]."/Display_End");
								$current_date=getServerDate(false);
								$show_message=false;
								if($start_date=="") 
									$start_date=$current_date;
								else
								{
									 list($dt_day, $dt_month, $dt_year) = explode('/', $start_date);
									 $start_timestamp = mktime(23, 59, 59, $dt_month, $dt_day , $dt_year);
									 $start_date = date('Y-m-d', $start_timestamp);
								}
								if($end_date=="") 
									$end_date=$current_date;
								else
								{
									 list($dt_day, $dt_month, $dt_year) = explode('/', $end_date);
									 $end_timestamp = mktime(23, 59, 59, $dt_month, $dt_day , $dt_year);
									 $end_date = date('Y-m-d', $end_timestamp);
								}
								if($start_date<=$current_date && $end_date>=$current_date)
								{
									$msg_type = $xPath_header->getData($items[$i]."/Message_Type");
									switch($msg_type)
									{
										case 'General':
											$general_create_date=$xPath_header->getData($items[$i]."/Message_Createdate");
											if(trim(GENERAL_MESSAGE_CREATE_DATE)!="" )
											{
											 list($dt_day, $dt_month, $dt_year) = explode('/', GENERAL_MESSAGE_CREATE_DATE);
											 $last_create_date = mktime(23, 59, 59, $dt_month, $dt_day , $dt_year);
											 $last_create_date = date('Y-m-d', $last_create_date);
											 
											 list($dt_day, $dt_month, $dt_year) = explode('/', $general_create_date);
											 $current_create_date = mktime(23, 59, 59, $dt_month, $dt_day , $dt_year);
											 $current_create_date = date('Y-m-d', $current_create_date);
											 if($last_create_date<$current_create_date)		//new general messages
											 	$show_message=true;	
											}
											else
												$show_message=true;
											if($show_message)
											{
											 $show_check_box=true;
											 if($alert_title=="")
												$alert_title="General";
											}
											if($general_update_date=='')
												$general_update_date=$general_create_date;
											if($general_create_date>general_update_date)
												$general_update_date=$general_create_date;
											break;
										case 'Alert':
											$alert_title="Alert";
											$show_message=true;
											break;
										default:
										//	if(trim(ALERT_MESSAGE_HIDE_VERSION)!='')
										//	{
												$aversion=ALERT_MESSAGE_HIDE_VERSION;
										//	}
										//	else  //get the available version
										//	{
												$available_version=current_version();
												if($available_version!='')
												{
													$temp=split(" ",$available_version);
													$available_version=$temp[1];
												}
										//	}
											$aversion_temp=array();
											$current_version=$xPath_header->getData($items[$i]."/Current_Version");
											$cur_version_temp=split("\.",$current_version);
											$site_version_temp=split("\.",$available_version);
											$aversion_temp=split("\.",$aversion);
											$check_version = count($site_version_temp);
											$version_updation = false;
											if(count($site_version_temp)<count($cur_version_temp))
												$check_version = sizeof($cur_version_temp);
											if(UPGRADE_NOTICE_TYPE=="n") //new user check for major releases
												$check_version=$check_version-1;
											else 	//developer   check for minor release
												$check_version=$check_version;
											for($iv=0;$iv<$check_version;$iv++){
												if(!$site_version_temp[$iv])$site_version_temp[$iv]=0;
												if(!$cur_version_temp[$iv])$cur_version_temp[$iv]=0;
												if(!$aversion_temp[$iv])$aversion_temp[$iv]=0;
												if($site_version_temp[$iv]<$cur_version_temp[$iv] && ($aversion_temp[$iv] < $cur_version_temp[$iv])){
													$version_updation = true;
													break;
												}else if($site_version_temp[$iv]>$cur_version_temp[$iv]){
													$version_updation = false;
													break;
												}
											}
											$show_message=$version_updation;
											if($show_message) 
											{
												if($alert_title!="Alert")
													$alert_title=$msg_type;
												$show_check_box=true;
											}
											break;
									}
									if($show_message)
									{
										$msg_title=$xPath_header->getData($items[$i]."/Message_Title");
										if($msg_title=="" && $item_count>1) $msg_title=$msg_type;
										$alert_content.="<div class=info_content_td style=padding-bottom:10px;><b>" .$msg_title . "</b></div>";
										$msg_content=$xPath_header->getData($items[$i]."/Message_Body");
										$alert_content.= "<div class=main>" . xmlentities($msg_content) . "</div><br>";
										$button_text=$xPath_header->getData($items[$i]."/Button_Text");
										$button_link=$xPath_header->getData($items[$i]."/Button_Hyperlink");
										if($button_text!="" && $button_link!="")
											$alert_content.=create_text_button($button_text,$button_link) . "<br>";
									}
								} //date check end
							}// for end
						}
					if($mode==1)
						return($alert_content);
				?>
					<div id='alert_messages' style='position:absolute;width:500;height:330;z-index:999;border:3px solid;border-color:#425796;padding:0px;<?php if(trim($alert_content)==""){echo 'display:none;';}?>' class="cell_bg_navig_l3">
					<table width="100%" cellpadding="0" cellspacing="0">
						<tr>
							<td align=right><a href='javascript:close_alert_messages(1)'><img src='images/layout/img_close.gif' alt='close' title='close' border='0'></a></td>
						</tr>
						<tr class="cell_bg_navig_l21" valign="top"><tD>
							<table border="0" width="100%" cellpadding="0" cellspacing="0" class="cell_bg_navig_l2"  height="34">
							<tr>
								<td >
								<?php
									switch(strtolower($alert_title))
									{
										case 'general':
											$img_name="general.gif";
											break;
										case 'developer':
											$img_name="developer.gif";
											break;
										case 'major release':
											$img_name="major_rel.gif";
											break;
										default:
											$img_name="security.gif";
											break;
									}
								?>
								<table>
									<tr>
									<td><?php echo tep_image('images/layout/' . $img_name,'',30,30);?></td>
									<td class="page_menu_title"><?php echo $alert_title;?>&nbsp;</td>
									</tr>
								</table></td>
							</tr>
							</table>
						</td></tr>
						<Tr><tD align="center">
							<table cellpadding="10"><tr><td align="center">
							<?php 
								echo '<table border="0" cellpadding="0" cellspacing="0" width="100%">
								<tr height="7">
									<td class="contentTopLeft"><img src="images/pixel_trans.gif" width="6"></td>
									<td class="contentTopMiddle"><img src="images/pixel_trans.gif" width="6"></td>
									<td class="contentTopRight"><img src="images/pixel_trans.gif" width="6"></td>
								</tr>
								<tr>
									<td class="contentMiddleLeft">&nbsp;</td>
									<td bgcolor="#FFFFFF" valign="top">
									<div style="height:200px;width:450px;overflow:auto" id="div_license" >';
									echo $alert_content;
								echo '	</div>
									</td>
									<td class="contentMiddleRight">&nbsp;</td>
								</tr>
								<tr height="7">
									<td class="contentBottomLeft"><img src="images/pixel_trans.gif" width="6"></td>
									<td class="contentBottomMiddle"><img src="images/pixel_trans.gif" width="6"></td>
									<td class="contentBottomRight"><img src="images/pixel_trans.gif" width="6"></td>
								</tr>
								</table>';
								?>
							</td></tr></table>
						</tD></Tr>
						<tr><td>
							<table width="100%" align="center">
								<tr>
									<?php 
									//if($img_name!="security.jpg"){
									if($show_check_box) {?>
									<td><table><tr><tD><input type="checkbox" name="chk_show_message" id="chk_show_message"></td><td class="display_text" valign="middle" nowrap>Don't show this message again.</td></tr></table></td>
									<?php }
									
									//}?>
									<td width="75%" align="right">
										<?php echo create_text_button('Upgrade','javascript:close_alert_messages(2)');?>
									</td>
									<td width="20%" align="right">
										<?php echo create_text_button('Cancel','javascript:close_alert_messages(1)');?>
									</td>
									<td width="5%">&nbsp;</td>
								</tr>
							</table>
						</td></tr>
						<tr><td height="5"></td></tr>
					</table>
					</div>
					<Script>
						div_tag=document.getElementById('alert_messages');
						hole_table=document.getElementById('holetable');
						div_height=div_tag.style.height;
						div_height=div_height.replace('px','');
						div_width=div_tag.style.width;
						div_width=div_width.replace('px','');
						div_tag.style.top=screen.availHeight/2 - div_height/2 ; //hole_table.style.top+hole_table.height/3;
						div_tag.style.left=screen.availWidth/2 - div_width/2 ; //hole_table.style.left+300;
						if(document.getElementById('chk_show_message'))
							document.getElementById('chk_show_message').checked=false;
						function close_alert_messages(mode)
						{
							div_tag=document.getElementById('alert_messages');
							div_tag.style.display="none";
							if(document.getElementById('chk_show_message') && document.getElementById('chk_show_message').checked)
							{
								window.open("<?php echo $PHP_SELF . '?alert_action=hide_alert&general=' . $general_update_date . '&version=' . $current_version;?>&mode=" + mode,'','height=10,width=10,left=8000,top=8000');
							}
							else if(mode==2){
								location.href="<?php echo tep_href_link(FILENAME_VERSION_UPGRADE);?>";
							}
						}
					</Script>
				<?php tep_session_register("show_alert_message");
					$show_alert_message=true;
				 }
			}
				
	function load_xml_file($filename){
		$xml=@file_get_contents($filename);
		$xml=xmlentities1($xml);
		return $xml;
	}
	function xmlentities ( $string ){
		return str_replace ( array ( '&', '"', '<', '>' ), array ( '&amp;amp;' , '&amp;quot;',  '&amp;lt;' , '&amp;gt;' ), $string );
	}
	function xmlentities_r ( $string ){
		return str_replace ( array ( '&amp;amp;' , '&amp;quot;',  '&amp;lt;' , '&amp;gt;' ), array ( '&amp;' , '&quot;', '&lt;' , '&gt;' ),$string );
	}
	function xmlentities1( $string ){
		return str_replace ( array ( '&amp;', '&quot;', '&lt;', '&gt;' ), array ( '&amp;amp;' , '&amp;quot;', '&amp;lt;' , '&amp;gt;' ), $string );
	}
	function create_text_button($text,$link,$blank_target=true)
	{
		if(strpos($link,'javascript:')===false && $blank_target)
			$target='onclick=javascript:window.open("'. $link. '")';
		else
			$target='onclick="'. $link. '"';
		$width=strlen($text) * 10 + 30;
		$button='<Table cellpadding="0" cellspacing="0" width=' . $width . 'px ' . $target. ' >
				<tr>
					<tD class="button_left" height="25"></tD>
					<td class="button_middle" height="25" style="cursor:pointer;" nowrap >&nbsp;&nbsp;&nbsp;' . $text . '&nbsp;&nbsp;&nbsp;</td>
					<td class="button_right" height="25" align="left"></td>
				</tr>
			   </Table>';
		return($button);
	}
	?>
	
