   but=new Array;
   
   but['american'] = new Image();
   but['american'].src = '/images/cards/american.gif';
   but['discover'] = new Image();
   but['discover'].src = '/images/cards/cv_card_ax.gif';
   but['master'] = new Image();
   but['master'].src = '/images/cards/cv_card_ax.gif';
   but['visa'] = new Image();
   but['visa'].src =  '/images/cards/cv_card_ax.gif';

   but['pointer'] = new Image();
   but['pointer'].src = '/images/cardpointer.gif';
   
   
   CardText = new Array;   
   CardText['american']='CID';
   CardText['discover']='Cardmember ID';
   CardText['master']='CVC2';
   CardText['visa']='CVV2';
   



function open_window(link,w,h) //opens new window
	{
		var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'newWin',win);
		newWin.focus();
	}

	function open_printable_version(link) //opens new window
	{
		var win = "menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'perintableWin',win);
		newWin.focus();
	}

	function confirmDelete(id, ask, url) //confirm order delete
	{
		temp = window.confirm(ask);
		if (temp) //delete
		{
			window.location=url+id;
		}
	}

	

	function confirmUnsubscribe() //unsubscription confirmation
	{
		temp = window.confirm('{/literal}{$smarty.const.QUESTION_UNSUBSCRIBE}{literal}');
		if (temp) //delete
		{
			window.location="index.php?killuser=yes";
		}
	}

	function validate() // newsletter subscription form validation
	{
		if (document.subscription_form.email.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_EMAIL}{literal}");
			return false;
		}
		if (document.subscription_form.email.value == 'Email')
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_EMAIL}{literal}");
			return false;
		}
		return true;
	}
	function validate_disc() // review form verification
	{
		if (document.formD.nick.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_NICKNAME}{literal}");
			return false;
		}

		if (document.formD.topic.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_MESSAGE_SUBJECT}{literal}");
			return false;
		}

		return true;
	}
	function validate_search()
	{

		if (document.Sform.price1.value!="" && ((document.Sform.price1.value < 0) || isNaN(document.Sform.price1.value)))
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_PRICE}{literal}");
			return false;
		}
		if (document.Sform.price2.value!="" && ((document.Sform.price2.value < 0) || isNaN(document.Sform.price2.value)))
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_PRICE}{literal}");
			return false;
		}

		return true;
	}

	
	function validate_cart()
	{

		if (document.Sform.price1.value!="" && ((document.Sform.price1.value < 0) || isNaN(document.Sform.price1.value)))
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_PRICE}{literal}");
			return false;
		}
		if (document.Sform.price2.value!="" && ((document.Sform.price2.value < 0) || isNaN(document.Sform.price2.value)))
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_PRICE}{literal}");
			return false;
		}

		return true;
	}
	
	
function isValueEmpty(value){ var re = /^\s+$/; if(value.length==0 || re.test(value)) return true; return false; }
/*
function CheckQuestionForm()
{
    var val_array = new Array("Name","Title","Organization","Address","City",
                              "State","Zip","Country","Phone","Email");
    var id_array = new Array("idName","idTitle","idOrganization","idAddress1","idCity",
                              "idState","idZip","idCountry","idPhone","idEmail");
    for(i=0;i<10;i++)
    {
        if(isValueEmpty(document.getElementById(id_array[i]).value))
        {
            alert("Please enter your "+val_array[i]);
            return false;
        }
    }

    if(isValueEmpty(document.getElementById('idComments').value))
    {
        alert("Please enter comments.");
        return false;
    }
    return true;
}	
*/

function CheckQuestionForm()
{
	var val_array = new Array("Name");
    var id_array = new Array("idName");
    for(i=0;i<1;i++)
    {
        if(isValueEmpty(document.getElementById(id_array[i]).value))
        {
            alert("Please enter your "+val_array[i]);
            return false;
        }
    }
	
	var val_array1 = new Array("Comments");
    var id_array1 = new Array("idComments");
    for(i=0;i<1;i++)
    {
        if(isValueEmpty(document.getElementById(id_array1[i]).value))
        {
            alert("Please enter your "+val_array1[i]);
            return false;
        }
    }

 var re = /^\w+([\.-]?\w+)*@(((([a-z0-9]{2,})|([a-z0-9][-][a-z0-9]+))[\.][a-z0-9])|([a-z0-9]+[-]?))+[a-z0-9]+\.([a-z]{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/i;
//var re = /^\w+([\.-]?\w+)*@[a-z0-9]+([\.-]?[a-z0-9]+)+\.([a-z]{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/i;    

  if(re.test(document.getElementById('idEmail').value))
  {
	if(confirm("Your data \n\tName:"+document.getElementById("idName").value+"\n\tMail:"+document.getElementById("idEmail").value+"\n\tComment:"+document.getElementById("idComments").value))
	{
		return true;
	}
	else 
	{
		return false;
	}

  }
  else {
    alert("Email is incorrect! Please enter correct Email.");
    document.getElementById('idEmail').focus();
    return false;
  }
}
	

function _formatPrice( _price )
{

		_pointIndex = -1;
		for( i=0; i< _price.length; i++ )
			if ( _price.charAt(i) == '.' )
			{
				_pointIndex = i;
				break;
			}

		if (  _pointIndex == -1 )
			_price = _price + ".00";
		else if (  _price.length-1 - _pointIndex == 1  )
			_price = _price + "0";

		_res = "";

		i=0;
		for( i=_price.length-1; i >= 0; i-- )
		{
			if ( _price.charAt(i) == '.' )
				break;
			else
				_res = _price.charAt(i) + _res;
		}

		_res = "." + _res;

		i--;
		_digitCounter = 0;
		for( ; i>=0; i-- )
		{
			_digitCounter ++;
			_res = _price.charAt(i) + _res;
			if ( _digitCounter == 3 && i != 0 )
			{
				_res = "," + _res;
				_digitCounter = 0;
			}

		}

		return _res;

}

function _categoryChangedHandler()
{
  if (document.AdvancedSearchInCategory.categorySelect.value != 0)
   window.location = 'index.php?categoryID=' + 
   document.AdvancedSearchInCategory.categorySelect.value + '&search_with_change_category_ability=yes';
}


		function show_card_image(cardtype) {		 
		  object_p = document;
		  object_p.images['cardpic'].src = but[cardtype].src;
		  //object_p.images['cardpointer'].src = but['pointer'].src;
		  
		  object_p.getElementById('card_cvv').innerHTML = "<font color=red>*</font>" + CardText[cardtype] + ":";
          if (object_p.getElementById('cvv_field').style.display == 'none') {
				object_p.getElementById('cvv_field').style.display = 'block';
		  } 
		}
		
		function check_card_type() {		 
          if (document.MainForm.cardtype.value=='') {
				alert('Please select card type.');
				return false;
		  } return true;
		}		

function doZebra( table_id )
{

     var table = document.getElementById( table_id );

     f = 0;

     for( var i=0; i < table.rows.length; i++ )
     {
         table.rows[i].className = ( f ? 'bg1' : 'bg2' );

         f = ( f ? 0 : 1 );
     }

}


		
