﻿
function Visual(){
}


// For shoppingcart.js
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/e02.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";

//for checkout.js
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='<div id="linklistcategory"><ul>';
  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+='<li><a href="JavaScript:Novigation.goToCategory('+c.getId()+')">'+Visual.formatStr(c.getName())+'</a></li>';
	  }
   }
	str+='</ul></div>';
   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=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){
	 alert("Error:"+errmes[errors]);
  }
}

//-----------------------------------------------------------
// 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);
 }
//--------------------------------------------------

Visual.showCartContentMess = function(){
	var count=Product.countInCartAll();
	if (count>0)
	  str=count +" products in cart";
	else
	  str="Cart is empty";

	var el=document.getElementById('cart_mess_id');
	if (el == null || typeof(el.innerHTML) == typeof(undefined)){
		document.write("<div id='cart_mess_id'>"+str+'</div>');
	}else{
		el.innerHTML=str;
	}
}

