<?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
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
  require('includes/application_top.php');
  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  $command=isset($HTTP_GET_VARS["command"])?$HTTP_GET_VARS["command"]:'';
  $customer_group_id=isset($HTTP_GET_VARS["cID"])?(int)$HTTP_GET_VARS["cID"]:'';
  $page = (isset($HTTP_GET_VARS['page']) ? (int)$HTTP_GET_VARS['page'] :1);
  ?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<style>
.link_class{
	font-family: Verdana, Arial, sans-serif; 
	font-size: 12px;
	color: #245EDC;
	text-decoration:underline;		
}
</style>
<script language="javascript" src="includes/general.js"></script>
<script language="javascript" src="includes/http.js"></script>
<Script>
	var prev_icnt=0;
	var detail=new Array;
	function show_detail(icnt)
	{
		if(prev_icnt>0)
			hide_detail(prev_icnt);
		if(document.getElementById("list" + icnt))
		{
			document.getElementById("list" + icnt).style.display="none";
			document.getElementById("list" + icnt+ "_detail").style.display="";
		}
		prev_icnt=icnt;
	}
	function hide_detail(icnt)
	{
		if(document.getElementById("list" + icnt))
		{
			document.getElementById("list" + icnt).style.display="";
			document.getElementById("list" + icnt+ "_detail").style.display="none";
		}
	}
	function load_country()
	{
		if(detail)
		{
			loaded_country=",";
			add_box=document.getElementById('selcountry');
			for(k=0;k<detail.length;k++)
			{
				cou=detail[k]["country"];
				temp="," + cou + ",";
				if(loaded_country.indexOf(temp)<0)
				{
					var opt=new Option(cou,cou);
					add_box.options[add_box.length]=opt;
					loaded_country+=cou +",";
				}
			}
		}
	}
	function search_prd()
	{
		if(prev_icnt>0)
			hide_detail(prev_icnt);
		country=document.getElementById('selcountry').value;	
		service=document.getElementById('selservice').value;
		cname=document.getElementById('cmp_name').value;
		for(k=0;k<detail.length;k++)
		{
			show=true;
			if(country!="")
			{
				if(country==detail[k]["country"])
					show=true;
				else
					show=false
			}
			if(service>0)
			{
				switch(service)
				{
					case '1':
						if(detail[k]["consultant"]!="Y")
							show=false;
						break;
					case '2':
						if(detail[k]["developer"]!="Y")
							show=false;
						break;
					case '3':
						if(detail[k]["hosting"]!="Y")
							show=false;
						break;
				}
			}
			if(cname!="")
			{
				val=detail[k]["company"]
				val=val.toLowerCase();
				cname=cname.toLowerCase();
				if(val.indexOf(cname)<0)
					show=false;
			}
			icnt=k+1;	
			if(show)
				document.getElementById("list" + icnt).style.display="";
			else
				document.getElementById("list" + icnt).style.display="none";
		}
	}
</Script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="SetFocus();">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="5" cellpadding="5">
  <tr> 
<!-- body_text //-->   
	 <td valign="top" class="openContent">
	  <table border="0" cellspacing="5" cellpadding="0" width=100%>
	   <tr>
		<td>
				   <?php
					$rates = load_xml_file("https://www.openfreeway.org/fileadmin/freeway/freeway.xml");
					//$rates = load_xml_file("freeway.xml");
					 require(DIR_WS_CLASSES . 'XPath.php');
					$xPath =&new XPath(FALSE, $xmlOptions);
					$xPath->importFromString(xmlentities_r($rates));
					$top_items=$xPath->match('Freeway_Text[1]/Version_Upgrade[1]');
					$avail_version=$xPath->getData($top_items[0]."/Current_Version");
					$items=$xPath->match('Freeway_Text[1]/Version_Upgrade[1]/Update'); 
					$item_count=count($items);
					for($i=0; $i<$item_count; $i++)
						$upgrade_text= $xPath->getData($items[$i]."/Update_Text");
					$button_name=$xPath->getData($items[0]."/Button_Upgrade_Text");
					$button_link=$xPath->getData($items[0]."/Button_Upgrade_Hyperlink");
					$cur_version=current_version();
					$upgrade_text=str_replace('&lt;current version number&gt;','<b>' . $cur_version . '</b>',$upgrade_text);
					//echo $upgrade_text;
				   ?>
				   <table width="100%" cellpadding="3">
				<tr>
					<td width="50%" class="main" valign="top">
						<Table width="100%"  cellpadding="0" cellspacing="5">
							<tr>
								<Td>
									<table cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFFFFF">
										<Tr>
										<td width="10%"><?php echo tep_image('images/layout/top_left1.gif');?></td>
										<td  ></td>
										<td width="10%"><?php echo tep_image('images/layout/top_right1.gif');?></td>
										</Tr>
										<tr>
											<td colspan="3" valign="top">
												<table width="100%" cellpadding="3">
													<tr><td class="main" width="5%">
														<?php echo tep_image('images/layout/general_white.gif','',20,20);?></td>
														<td class="main">
															<table cellpadding="0" cellspacing="2" border="0" width="100%">
																<tr>
																	<td class="main">
																		<b><?php 
																		$temp=str_replace('Freeway &nbsp;','',$cur_version);
																		$curversion=ltrim($temp); 
																		//$aversion=ALERT_MESSAGE_HIDE_VERSION;
																		//$aversion_temp=split("\.",$aversion);
																		$avail_version_temp=split("\.",$avail_version);
																		$curversion_temp=split("\.",$curversion);
																		$check_version = sizeof($curversion_temp);
																		$version_updation = false;
																		if(sizeof($curversion_temp)<sizeof($avail_version_temp))
																			$check_version = sizeof($avail_version_temp);
																		for($iv=0;$iv<$check_version;$iv++){
																			if(!$curversion_temp[$iv])$curversion_temp[$iv]=0;
																			if(!$avail_version_temp[$iv])$avail_version_temp[$iv]=0;
																			if($curversion_temp[$iv]<$avail_version_temp[$iv]){
																				$version_updation = true;
																				break;
																			}
																		}
																		
																		 if($version_updation) {
																			echo TEXT_VERSION_OUT_DATE;
																			echo '<td><td align="right"><a class="main_update" href="' . $button_link . '"><font color="#FFFFFF"><b>' . $button_name . '</b></font></a>' . '</td>';
																		 } else {
																			echo TEXT_CURRENT_IN_DATE;
																		}
																		 ?></b></td>
																</tr>
															</table>
														</td>				 
													</tr>
													<tr><td ></td>
														<td class="smalltext"><?php echo sprintf(TEXT_CURRENT_VERSION,$cur_version); ?></td>
													</tr>
													<tr><td ></td>
														<td class="smalltext"><?php if($version_updation) echo sprintf(TEXT_AVAILABLE_VERSION,$avail_version); ?></td>
													</tr>
												</table>
											</td>
										</tr>
										<Tr>
										<td width="10%"><?php echo tep_image('images/layout/bottom_left1.gif');?></td>
										<td ></td>
										<td width="10%"><?php echo tep_image('images/layout/bottom_right1.gif');?></td>
										</Tr>
										
									</table>
								</Td>
							</tr>
							<tr><td class="smallText"><?php //echo TEXT_ALERT_MESSAGE;?>
							<?php echo show_alert_message('1');?>
							</td></tr>
							<tr><td height="10"></td></tr>
							<tr><td class="main"><b><?php echo HEADING_AVAILABLE_VERSION . '&nbsp;' . tep_image('images/layout/round.gif') . '&nbsp;' . 'Freeway ' . $avail_version;?></b></td></tr>
							<tr><td>
							 <?php $img_path="images/layout/";
							 $upgrade_text=str_replace('<img_path>',$img_path,$upgrade_text);
							 echo $upgrade_text;?>
							</td></tr>
							<tr><td height="10"></td></tr>
								<tr><td class="main" nowrap="nowrap"><a class="main_update" href="<?php echo $button_link ; ?>"><font color="#FFFFFF"><b><?php echo $button_name ;?></b></font></a></td></tr>
						</Table>
		  	 	</td>
			 	<td width="50%" bgcolor="#ffffff" valign="top">
					<?php $provider=$xPath->match('Freeway_Text[1]/Version_Upgrade[1]/Service_Provider');
					$i=0;
					?>
					<table width="98%" align="center" cellpadding="5">
					<tr><td class="main"><b><?php echo $xPath->getData($provider[$i]."/Provider_Title");?></b></td></tr>
					<tr><td class="main"><?php echo $xPath->getData($provider[$i]."/Provider_Text");?></td></tr>
					<tr><td class="main">
						<Table width=100% cellpadding="5" cellspacing="0" id="navig_row">
							<tr>
								<td class="cell_bg_navig_l3" nowrap style="height:35px">
									<select name="selcountry" id="selcountry"><option value=""><?php echo TEXT_ALL_COUNTRIES;?></option></select>
									<select name="selservice" id="selservice">
										<option value="0"><?php echo TEXT_ALL_SERVICES;?></option>
										<option value="1"><?php echo TEXT_CONSULTANT;?></option>
										<option value="2"><?php echo TEXT_DEVELOPER;?></option>
										<option value="3"><?php echo TEXT_HOSTING;?></option>
									</select>
									<?php echo tep_draw_input_field("cmp_name") . '&nbsp;';
									echo '<a href="javascript:search_prd();" class=menu_l3_select>' . TEXT_SEARCH .'</a>';?>
								</td></tr>
							<tr>
							<td class="cell_bg_navig">
								<Table width="100%" cellpadding="2" cellspacing="0">
									<tr>
										<td width="50%" align="left"><b><?php echo TEXT_COMPANY;?></b></td>
										<td width="45%" align="left"><b><?php echo TEXT_COUNTRY;?></b></td>
<!--										<td width="20%"><b><?php //echo TEXT_SITEMADE;?></b></td>
-->										<td width="5%"><b><?php echo TEXT_DETAILS;?></b></td>
									</tr>
                                 </Table>
							</table></td></tr>
									<?php //$list=$xPath->getData($provider[$i]."/Provider_Description[0]");
									$list=$xPath->match('Freeway_Text[1]/Version_Upgrade[1]/Service_Provider/Provider_Description'); 
									?>
									<tr><td  width="100%" bgcolor="#ffffff">
									<div id="provider_list" style="width:100%;height:450px;overflow:auto">
									<?php for($icnt=0;$icnt<count($list);$icnt++){
										$rtext="";
										$cmp_name=$xPath->getData($list[$icnt]."/Company_Name");
										$country=$xPath->getData($list[$icnt]."/Country");
										$consultant=$xPath->getData($list[$icnt]."/Services_Consultant");
										$developer=$xPath->getData($list[$icnt]."/Services_Developer");
										$hosting=$xPath->getData($list[$icnt]."/Services_Hosting");
										$cname=$xPath->getData($list[$icnt]."/Contact_Name");
										$email=$xPath->getData($list[$icnt]."/Contact_Email");
										$web=$xPath->getData($list[$icnt]."/Contact_Website");
										$desc=$xPath->getData($list[$icnt]."/Description");
										$refer=$xPath->match('Freeway_Text[1]/Version_Upgrade[1]/Service_Provider/Provider_Description[' .($icnt+1) . ']/References');
										if($refer)
										{
										$rtitle=$xPath->getData($refer[0]."/Title");
										$rtext=$xPath->getData($refer[0]."/Teaser_Text");
										$rlink=$xPath->getData($refer[0]."/Teaser_Link");
										$rurl=$xPath->getData($refer[0]."/Reference_URL");
										$rurl_temp=str_replace("http://","",$rurl);
										$replace_txt="<a href='" . $rlink. "' target=_blank><font class='link_class'>" . $rurl_temp . "</font></a>";
										$rtext=str_replace($rurl_temp,$replace_txt,$rtext);
										}
										echo "<script>";
										echo "detail[" . $icnt ."]=new Array(14);";
										echo "detail[" . $icnt ."]['id']='" . ($icnt+1) . "';";
										echo "detail[" . $icnt ."]['company']='" . $cmp_name . "';";
										echo "detail[" . $icnt ."]['country']='" . $country . "';";
										echo "detail[" . $icnt ."]['consultant']='" . $consultant . "';";
										echo "detail[" . $icnt ."]['hosting']='" . $hosting . "';";
										echo "detail[" . $icnt ."]['developer']='" . $developer . "';";
										/*echo "detail[" . $icnt ."]['cname']='" . $cname . "';";
										echo "detail[" . $icnt ."]['email_add']='" . $email . "';";
										echo "detail[" . $icnt ."]['web_site']='" . $web . "';";
										$desc1=str_replace("'","\'",$desc);
										$desc1=ereg_replace(chr(13),"",$desc1);
										echo "detail[" . $icnt ."]['desc']='" . desc1 . "';";
										echo "detail[" . $icnt ."]['rtitle']='" . $rtitle . "';";
										echo "detail[" . $icnt ."]['rtext']='" .  str_replace("'","\'",$rtext) . "';";
										echo "detail[" . $icnt ."]['rlink']='" . $rlink . "';";
										echo "detail[" . $icnt ."]['rurl']='" . $rurl . "';";*/
									echo "</script>";
										?>
										<div id="list<?php echo ($icnt+1);?>">
											<table width="100%" cellpadding="3" style="cursor:pointer;" cellspacing="0">
												<tr onClick="javascript:show_detail(<?php echo ($icnt+1);?>);" class="openContent" onMouseOver="javascript:rowOverEffect(this)" onMouseOut="javascript:rowOutEffect(this)" >
													<td width="45%" class="main" style="color:#314C9B;" align="left"><b><?php echo $cmp_name;?></b></td>
													<td width="45%" class="main" align="left"><?php echo $country;?></td>
<!--													<tD width="20%" class="main">
-->														<?php 
/*															$str="";$str_det="";
													if ($consultant=="Y"){
														$str_det=TEXT_CONSULTANT . ",";
														$str="C,";}
														if ($developer=="Y"){
														$str_det.=TEXT_DEVELOPER . ",";
														$str.="D,";}
														if ($hosting=="Y"){
														$str_det.=TEXT_HOSTING . ",";
														$str.="H,";}
														if($str!=""){ 
															$str=substr($str,0,-1);
															$str_det=substr($str_det,0,-1);
														}
														else{
															$str=" - ";
															$str_det="--" . TEXT_NONE ."--";
														}
														echo $str;
*/													?>
<!--													</tD>
-->													<td width="5%"><a href="javascript:show_detail(<?php echo ($icnt+1);?>);"><?php echo tep_image("images/icons/view_detail.gif");?></a></td>
												</tr>
											</table>
											</div>
											<div id="list<?php echo ($icnt+1);?>_detail" style="display:none;">
											<table width="100%" cellpadding="0" cellspacing="0">
												<tr class="openContent" onClick="javascript:hide_detail(<?php echo ($icnt+1);?>);" style="cursor:pointer;">
													<td width="45%" class="main" style="color:#314C9B;"><b><?php echo $cmp_name;?></b></td>
													<td width="45%" class="main"><?php echo $country;?></td>
													<td width="5%">&nbsp;</td>
												</tr>
												<tr><td colspan="3">
													<table width="85%" cellpadding="3" border="0" align="center">
														<tr><td class="main" colspan="3"><b><?php echo TEXT_DESCRIPTION;?></b></td></tr>
														<tr><td class="main" colspan="3"><?php echo $desc;?></td></tr>
														<tr><td class="main" colspan="3"><b><?php echo TEXT_REFERENCES;?></b></td></tr>
														<?php if($rtext!=''){?>
														<tr><td class="main" colspan="3"><i><?php echo $rtitle;?></i></td></tr>
														<tr><td class="main" colspan="3"><?php echo $rtext;?></td></tr>
														<?php }else{?>
														<tr><td class="main" colspan="3" align="center"><?php echo TEXT_NO_REFERENCES;?></td></tr>
														<?php }?>
														<tr><td class="main" colspan="3"><b><?php echo TEXT_SITEMADE;?></b></td></tr>
														<tr><td class="main" colspan="3"><?php echo $str_det;?></td></tr>
														<tr><td class="main"><b><?php echo TEXT_CONTACT;?></b></td>
														<td class="main"><b><?php echo TEXT_MAIL;?></b></td>
														<td class="main"><b><?php echo TEXT_WEB;?></b></td>
														</tr>
														<tr><td class="main" nowrap><?php echo $cname;?></td>
														<td class="info_content"><a  href="mailto:<?php echo $email;?>"><font class="link_class"><?php echo $email;?></font></a></td>
														<td class="info_content"><a  href="<?php echo $web;?>" target="_blank"><font class="link_class"><?php echo $web;?></font></a></td>
														</tr>
													</table>
												</td></tr>
											</table>	
											</div>
									<?php }
									?>
									<script>
										load_country();
									</script>
									</div>
									</td></tr>
					</table>
				</td>
			 </tr>
			</table>
        </td></tr></table>
        </td>      
<!-- body_text_eof //-->
<!-- body_eof //-->
	</tr>			
  </table>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
