<?php
/**
 *\licence GPL 2005-2010  The osCSS developers - osCSS Open Source E-commerce
 *\portion code Copyright (c) 2002 osCommerce
 *\package osCSS-2 <www http://www.oscss.org>
 *\version 2.1.0
 *\date  28/11/10, 08:18
 *\author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
 *\encode UTF-8
 *\brief lib function template
*/
$customer_status = (tep_session_is_registered('customer_id') ? 'client' : 'guest');
$template=$page->the_template();



/**
  Alias Widget_menu pour menu account
*/
function Widget_account_info(){
  $t='<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . PAGE_ACCOUNT . '</a>'."\n";
  $s=Widget_menu(3,false,true);
  global $page,$language;
 return array('title'=>tep_output_string_protected($t,false,true),'content'=>$s['content']);
}

function Widget_search_suggest(){
  global $page;
  $s='';
  $s.='<script type="text/javascript"><!--//'."\n";
  $s.='function searchSuggest() {'."\n";
    $s.='keySend = document.getElementById(\'quick_find\').keywords.value;'."\n";
    $s.='divOutput = document.getElementById(\'search_suggest\');'."\n";
    $s.='divOutput.innerHTML = \'\';'."\n";
    $s.='divOutput.style.visibility="hidden";'."\n";
    $s.='if ( keySend.length > 1 ) {'."\n";
	$s.='if ( text = file(\''.tep_href_link('ajax_exe.php', 'action=search_suggest').'&'.'search=\'+escape(keySend)) ) {'."\n";
	    $s.='divOutput.style.visibility="visible";'."\n";
	    $s.='searchResult = text.split("\n");'."\n";
	    $s.='suggest = \'<ul>\';'."\n";
	    $s.='suggest += \'<li class="smenufull_arhaut"></li>\';'."\n";

	    $s.='for(i=0; i < searchResult.length-1; i++) {'."\n";
	      $s.=' suggest += \'<li onmouseover="javascript:suggestOver(this);" onmouseout="javascript:suggestOut(this);" \';'."\n";
	      $s.=' suggest += \'onclick="javascript:setSearch(this.innerHTML);" class="suggest_link">\' + searchResult[i] + \'</li>\';'."\n";
	    $s.='}'."\n";
	  $s.=' suggest += \'<li class="smenufull_arbas"></li>\';'."\n";
	    $s.='suggest += \'</ul>\';'."\n";
	    $s.='divOutput.innerHTML = suggest;'."\n";
      $s.=' }'."\n";
    $s.='}'."\n";
  $s.='}'."\n";

  //Mouse over function
  $s.='function suggestOver(div_value) {'."\n";
    $s.='div_value.className = \'suggest_link_over\';'."\n";
  $s.='}'."\n";
  //Mouse out function
  $s.='function suggestOut(div_value) {'."\n";
    $s.='div_value.className = \'suggest_link\';'."\n";
  $s.='}'."\n";
  //Click function
  $s.='function setSearch(selectedValue) {'."\n";
    $s.='document.getElementById(\'quick_find\').keywords.value = selectedValue;'."\n";
    $s.='document.getElementById(\'search_suggest\').innerHTML = \'\';'."\n";
    $s.='document.getElementById(\'search_suggest\').style.visibility="hidden";'."\n";
  $s.='}'."\n";
  $s.='//--></script>'."\n";

  $page->javascript->add_script_src(array('file'=>'search_suggest','script'=>tep_output_string_protected($s,false,true)) );

 return array('title'=>__('widget box heading search suggest'),'content'=>tep_output_string_protected(tep_get_include_contents('box.search_suggest'),false,true));
}

function Widget_login_box(){
  global $page;
  $s='';
  if (tep_session_is_registered('customer_first_name') && tep_session_is_registered('customer_id')) {
    $s.='<div class="back_login" ><p>Bienvenue '.'</p><br />'."\n";
      $s.='<p class="createAccount"><a  href="'. tep_href_link(FILENAME_LOGOFF) .'">'. BOX_LOGIN_LINK5 .'</a></p>'."\n";
    $s.='</div>'."\n";
  } else {
    if (_cst_bool('LOGIN_SET_SNAPSHOT')) {
      $navigation = $page->return_object('navigation_history');
      $navigation->set_snapshot();
    }

    $s.=tep_draw_form('login_form_box', tep_href_link(FILENAME_LOGIN, 'action=process', 'SSL'));
    $s.='<fieldset class="back_login">'."\n";
      $s.='<p class="inputLog">'."\n";
	$s.=tep_draw_input_field('email_address','login_email',__('widget box input email'), 'onclick="this.value=\'\'"');
      $s.='</p>'."\n";
      $s.='<p class="inputLog">'."\n";
	$s.=tep_draw_password_field('password','login_password','0123','onclick="this.value=\'\'"')."\n";
      $s.='</p>'."\n";
      $s.='<p class="formBt">'."\n";
	$s.='<input type="submit" class="submitBt" value="'.IMAGE_BUTTON_LOGIN.'"  />'."\n";
      $s.='</p>'."\n";
    $s.='</fieldset>'."\n";
    $s.='<p class="createAccount">'."\n";
      $s.='<a href="'.tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL').'">'.__('widget box creat account').'</a>'."\n";
    $s.='</p>'."\n";
    $s.='</form>'."\n";
  }
 return array('title'=>'','content'=>tep_output_string_protected($s,false,true));
}

/** TAGS */
function Widget_Tags(){
  if(isset($_GET['products_id']) || isset($_GET['content']) || isset($_GET['cPath'])){
    // include cloud generator
    include_once(DIR_WS_FUNCTIONS.'generate.php');
    $s= generateCloud(array('products'=>@$_GET['products_id'],'cPath'=>@$_GET['cPath'],'content'=>@$_GET['content']));
    return array('title'=>__('widget box heading tag'),'content'=>tep_output_string_protected($s,false,true));
  }
  return array('title'=>'','content'=>'');
}


?>