﻿function SearchHasFocus() {
    var t = document.getElementById('ctl00_txtSearch_I');
    if (t != null) {
        t.value = "";
    }
}

//functions related to checkout controls//
function OnClearCart(s, e) {
  var item = s.GetValue();
  CallbackShipMeth.PerformCallback('ClearCart|0|0');
}

function OnUpdateCart(s, e) {
  var item = s.GetValue();
  CallbackShipMeth.PerformCallback('UpdateCart|0|0');
}

//functions for use in CustomerPortal //
function OnResetClick( s, e ) {
	ebMemReview.SetText( "" );
}
      
function OnSubmitClick( s, e ) {				
  var args = [s.cpRowIndex, s.GetSelectedItem().value].join("|");
	cbPopups.PerformCallback( s, e );
}

function OnLogin(s, e) {
	var args = [" ", " "].join("|");
  cbPopups.PerformCallback('Login|' + args);
}
			
function IssuedCreditAmount( s, e ) {				
	var t = s.GetValue();
	if( IsValidAmount( t ) ) {				
		cbWrapper.PerformCallback( 'ebCreditIssued|' + t );
	} else {
		s.SetValue( "Enter Valid Amount" );
		return;
	}
}
			
function IsValidAmount( sEntry ) {
	var valid = true;				
	var cValid = "0123456789.";
	var current;
					
	for( i = 0; i < sEntry.length && valid; i++ ) {
		current = sEntry.charAt( i );
		if( cValid.indexOf( current ) == -1 ) {
			valid = false;
		}
	}
	
	return valid;
}

//functions for checkout//
function SetInitialShipToIndex(s, e) {
  var args = [s.cpRowIndex, s.cpSelectedLocationID].join("|");
  CallbackShipMeth.PerformCallback('SelectedShipTo|' + args);
}
function OnSelectedShipToIndexChanged(s, e) {
	var args = [s.cpRowIndex, s.GetSelectedItem().value].join("|");
  CallbackShipMeth.PerformCallback('SelectedShipTo|' + args);
}
//      'txtQuantity|' + '{0}|' + s.GetValue().toString()); }}", e.KeyValue
function OnShipMethChanged(s, e) {
  var item = s.GetSelectedItem();
  CallbackShipMeth.PerformCallback('ShipMeth|0|' + item.value);
}
function OnStudioCardChanged(s, e) {
  var item = s.GetValue();
  var args = ["SC", item].join(" ");
  CallbackShipMeth.PerformCallback('StudioCard|0|' + s.GetValue());
}
function OnPromoChanged(s, e) {
  var item = s.GetValue();
  var args = ["PR", item].join(" ");
  CallbackShipMeth.PerformCallback('Promo|0|' + s.GetValue());
}
function OnRushChanged(s, e) {
  var item = s.GetChecked();
  CallbackShipMeth.PerformCallback('Rush|0|' + s.GetChecked());
}
function OnCreditCardChanged(s, e) {
  var item = s.GetValue();
  CallbackShipMeth.PerformCallback('CreditCard|0|' + s.GetValue());
}
function OnWholesaleChanged(s, e) {
  var item = s.GetValue();
  CallbackShipMeth.PerformCallback('Wholesale|0|' + s.GetValue());
}        
function OnClearCart(s, e) {
  var item = s.GetValue();
  CallbackShipMeth.PerformCallback('ClearCart|0|0');
}
function OnUpdateCart(s, e) {
  var item = s.GetValue();
  CallbackShipMeth.PerformCallback('UpdateCart|0|0');
}
function OnCommitEditClick(s, e) {
  ASPxCallbackValidator.PerformCallback();
}        