﻿
function Visual(){
}

Visual.right="right";
Visual.left="left";

Visual.strPostiveNumbers='Only positive numbers are valid';
Visual.outOfStock='Sorry,Out of stock';
Visual.unexpectedError="Sorry, unexpected error, try to refresh the page";
Visual.strAddToCart="  Add to Cart  ";
Visual.strMore="  More  ";
Visual.strNoProd="No product Found";
Visual.strCatHome="Home";
Visual.strSign=">";

Visual.strProdMes=new Array("Product added to the Shopping Cart. Proceed to check out?");
Visual.trans = new Array(0);
Visual.trans['shoppingcart']=new Array(0);
Visual.trans['shoppingcart']['strHeader']=new Array("Remove","Product(s)","Qnt","Price("+Project.msign+")");
Visual.trans['shoppingcart'][0]="No Products in Cart";
Visual.trans['shoppingcart'][1]="Total:";
Visual.trans['shoppingcart'][2]="Shipping method&nbsp;";
Visual.trans['shoppingcart'][3]="SubTotal:";

Visual.mustBeNumber="Some of values must be numbers";
Visual.catSign='<img src="images/catsign.gif">';

Visual.trans['payment'] = new Array(0);
Visual.trans['payment']['types'] = new Array("Credit card","Cash on delivary",
	"By Phone","Check","Money order","E-currency","PAYPAL","Bank wire", "Free", "Quote", "Google","Escrow");


var errmes=new Array('Please verify all fields','Please check the details...',
					 'Wrong password','Error try again','Saved',
					 'Cant find this email','Sent','Removed',
					 'This e-mail already exist','Please check the payment details');

var fdescr=new Array(0);
fdescr['email']="Email address";
fdescr['name']="First Name";
fdescr['family']="Last Name";
fdescr['addr']="Address";
fdescr['city']="City";
fdescr['stateID']="State";
fdescr['zip']="Zip";
fdescr['countryID']="Country";
fdescr['phone']="Phone";
fdescr['passwd']="Password";

var strEFileds = "Some values are missing:";
Visual.TaxesStr="All taxes";
Visual.ShippStr="Shipping";
Visual.strQuote="Quote";
Visual.strCheckout="Checkout";
Visual.strContinueShopping="Continue Shopping";
Visual.strRemoveSelected="Remove Selected";
Visual.strBInfo="Billing Info:";
Visual.strSInfo="Shipping Info:";
Visual.strSameAsB=" same as billing";
Visual.strPayMethod="Payment method:";
Visual.strContCheckout="Continue Checkout";
Visual.strSendOrder="Send Order";
//----------------------------------------
Visual.showProductsBrend= function(prid){
  var str='';
  var brend=null;
  var pcArr=Category.getPCList();
  if (pcArr[prid]){
	  for (var i=0;i<pcArr[prid].length;i++){
		  var c = Category.getCategoryByID(pcArr[prid][i]);	
		  if (c!=null && c.getStatus()=="1"){
			brend=c;
			break;
		  }
	  }
  }
  if (brend!=null) {
	//alert(brend); 
	str+='<a href="JavaScript:Novigation.goToCategory('+c.getId()+')">';
	if (brend.getPicture()!=null && brend.getPicture()!=""){
		str+='<img border="0" width=100 hight=100 src="'+Project.smallPictureDir+"../"+brend.getPicture()+'">';
	}else{
		str+=Visual.formatStr(brend.getName());
	}
	str+='</a>';
  }
  return str;
}

//--------- Return formatted string ---------
Visual.formatStr = function(str){
  return MultiLang.get(str);
}

//----------------------------------------------------
// Show current Categories, by ststus and from_catid
Visual.showCategories = function(status,from_catid){
  var idc;
  if (!from_catid) {
	 idc=Category.current();
  }else{
	 idc=from_catid;
  }

  if (idc<-1)idc=-1;

  var str="";
  var brothers = Category.getChildren( idc );
  if (brothers.size()<=0)
	{
	   var bcat = Category.getCategoryByID(idc);
	   if (bcat!=null)
		   brothers = Category.getChildren( bcat.getParent() );
	}

  for (var j=0;j<brothers.size();j++)
   {
	  var c = brothers.get(j);
	  if (status==c.getStatus())
	  {
		  str+='<a class="CategoryMenu" '+
		 ' href="JavaScript:Novigation.goToCategory('+c.getId()+')">'
		  +Visual.formatStr(c.getName())+"</a><BR>";
	  }
   }
   document.write(str);
   brothers=null;
}

//----------------------------------------------------
// Show all Categories, by ststus and from_catid,in select
Visual.showCategoriesInSelect = function (status,from_catid,isAll){
 var cats=Category.getAllChildren(from_catid);
 var str="";
 if (isAll) str+='<option value="-2">All</option>';

  for (var j=0;j<cats.size();j++){
	  var c = cats.get(j);
	  if (status==c.getStatus())
	  {
		  str+='<option value="'+c.getId()+'"';
		  if (Category.current()==c.getId()) str+=" selected";
		  str+=">";
		  str+=Visual.formatStr(c.getName())+"</option>";
	  }

  }

  document.write(str);
  cats=null;
}
//-----------------------------------------------------------
// Return String representing form Category to To catgegory
// with HREF values
Visual.showUrlCatPath =  function (fromId,toId)
 {
    var str="";
    var arr=Category.getPath(fromId,toId);

	for (var i=0;i<arr.length;i++){	
       str+='<a class="CategoryPath" href="JavaScript:Novigation.goToCategory('+arr[i].getId()+')">';
  	   str+=Visual.formatStr(arr[i].getName());
	   str+='</a>';
	   if (i!=arr.length-1)
		   str+=Visual.catSign;
	 }

	 if (str!="") {
	  str=Visual.catSign+str;
	 }

	str='<a class="CategoryPath" href="JavaScript:Novigation.goToCategory(-2)">'+
		  Visual.strCatHome+'</a>'+str;
	return str;
 }



Visual.addMSign=function(input){
  return input+Visual.priceStr;
}

//-------------------------------------------------------
// Return String with PRODUCT html view
//-------------------------------------------------------
Visual.showProductInCart = function (pr,addVal){	
  var tStr="";
  var str="";
  if (addVal) str="&nbsp;("+addVal+")";
  tStr+='<TD align="left" CLASS="cartentry01"> ';
  if (pr.getCode()!="") tStr+="("+pr.getCode()+") ";
  tStr+=Visual.formatStr(pr.getName())+" "+str;
  tStr+='</TD>';
  return tStr;
}

Visual.showProductInCartMail = function (pr,addVal){	
  var tStr="";
  var str="";
  if (addVal) str="&nbsp;("+addVal+")";
  tStr+='<TD>';
  tStr+=Visual.formatStr(pr.getName());
  tStr+=str;
  tStr+='</TD>';
  return tStr;
}


Visual.showError=function(){
 if (errors.indexOf("##")!=0){
	 document.write('<FONT COLOR="#FF0000">');
	 document.write(errmes[errors]);
	 document.write('</FONT><br><br>');
  }
}

//-----------------------------------------------------------
// Return String representing form Category to To catgegory
// with HREF values, to current product if exist
Visual.showPathToCurrentProduct =  function (fromId,toId){
	var fstr="";
	if((Product.getList()).size()==1){ // showing only one product 
		var pr=(Product.getList()).get(0);
	    var catids=getProductCategories(pr.getId(),true);
		fstr=Visual.showUrlCatPath(fromId,catids[0])+Visual.catSign+Visual.formatStr(pr.getName());
	 }else
		 fstr=Visual.showUrlCatPath(fromId,toId);
	document.write(fstr);
 }

//----------------------------------------------------
// Show current Categories, by ststus and from_catid
Visual.showVisualCategories = function(status,from_catid){
  var idc;
  if (!from_catid){
	 idc=Category.current();
  }else{
	 idc=from_catid;
  }
  if (idc<-1)idc=-1;
  var str="";
  var brothers = Category.getChildren( idc );
  if (brothers.size()<=0){
	   return -1;
  }
  var inrow=3;
  w=100/3;
  str+='<table width="100%">';
  var isOpen=false;
  var count=0;
  for (var j=0;j<brothers.size();j++){
	  var c = brothers.get(j);
	  if (status==c.getStatus()){
		  if (count % inrow ==0){
			  if (isOpen) str+="</tr>";
			  str+="<tr>";
		  	  isOpen=true;
	  	  }
		  count++;
		  str+='<td align="center" valign="top" width="'+w+'%">';
		  str+='<a class="CategoryMenu_body" href="JavaScript:Novigation.goToCategory('+c.getId()+')">'+Visual.formatStr(c.getName())+"</a>";
		  
		  if (c.getPicture()!=""){
		   str+="<br>";
		   str+='<a href="JavaScript:Novigation.goToCategory('+c.getId()+')">';
		   var pict=c.getPicture();
		   if ((c.getPicture()).indexOf('http')!=0){
			pict=Project.smallPictureDir+"../"+pict;
		   }
		   str+='<img border="0" src="'+pict+'"></a>';
		  }
		  str+="</td>";
	  }
   }
  if (count % inrow!=0){
	  str+='<td colspan="'+((count % inrow)+1)+'"></td>';
  }
  if (isOpen) str+="</tr>";
  str+="</table>";
  return str;
}

