PageRenderTime 71ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/design/theme/base-responsive-v2/ec-store-js.js

https://github.com/EmranAhmed/wp-easycart
JavaScript | 3178 lines | 2306 code | 585 blank | 287 comment | 755 complexity | 45ac621478fa42803509cf497dec41e3 MD5 | raw file
  1. function ec_product_show_quick_view_link( modelnum ){
  2. jQuery('#ec_product_quick_view_' + modelnum).fadeIn(100);
  3. }
  4. function ec_product_hide_quick_view_link( modelnum ){
  5. jQuery('#ec_product_quick_view_' + modelnum).fadeOut(100);
  6. }
  7. function ec_product_show_quick_view( modelnum ){
  8. jQuery('#ec_product_quick_view_box_' + modelnum).fadeIn(100);
  9. }
  10. function ec_product_hide_quick_view( modelnum ){
  11. jQuery('#ec_product_quick_view_box_' + modelnum).fadeOut(100);
  12. }
  13. function ec_thumb_quick_view_click( modelnum, level, imgnum ){
  14. if( document.getElementById( 'ec_image_quick_view_' + modelnum + "_" + 1 + "_" + level ) ){
  15. jQuery('#ec_image_quick_view_' + modelnum + "_" + 1 + "_" + level ).hide();
  16. }
  17. if( document.getElementById( 'ec_image_quick_view_' + modelnum + "_" + 2 + "_" + level ) )
  18. jQuery('#ec_image_quick_view_' + modelnum + "_" + 2 + "_" + level ).hide();
  19. if( document.getElementById( 'ec_image_quick_view_' + modelnum + "_" + 3 + "_" + level ) )
  20. jQuery('#ec_image_quick_view_' + modelnum + "_" + 3 + "_" + level ).hide();
  21. if( document.getElementById( 'ec_image_quick_view_' + modelnum + "_" + 4 + "_" + level ) )
  22. jQuery('#ec_image_quick_view_' + modelnum + "_" + 4 + "_" + level ).hide();
  23. if( document.getElementById( 'ec_image_quick_view_' + modelnum + "_" + 5 + "_" + level ) )
  24. jQuery('#ec_image_quick_view_' + modelnum + "_" + 5 + "_" + level ).hide();
  25. jQuery('#ec_image_quick_view_' + modelnum + "_" + imgnum + "_" + level ).show();
  26. }
  27. function ec_image_quick_view_click( modelnum, level, imgnum ){
  28. return false;
  29. }
  30. function product_quantity_change( ){
  31. // Possibly do something on quantity change
  32. }
  33. function ec_swatch_quick_view_click( modelnum, level, imgnum ){
  34. if( level == 1 && document.getElementById( 'use_optionitem_images_' + modelnum ).value == 1 ){
  35. ec_image_quick_view_update( modelnum, level, imgnum );
  36. }
  37. if(document.getElementById( 'ec_swatch_quick_view_' + modelnum + "_" + level + "_" + imgnum ).className != "ec_product_swatch_out_of_stock"){
  38. var i=0;
  39. while( document.getElementById( 'ec_swatch_quick_view_' + modelnum + "_" + level + "_" + i ) ){
  40. if( document.getElementById( 'ec_swatch_quick_view_' + modelnum + "_" + level + "_" + i ).className != "ec_product_swatch_out_of_stock"){
  41. document.getElementById( 'ec_swatch_quick_view_' + modelnum + "_" + level + "_" + i ).className = "ec_product_swatch";
  42. }
  43. i++;
  44. }
  45. document.getElementById( 'ec_swatch_quick_view_' + modelnum + "_" + level + "_" + imgnum ).className = "ec_product_swatch_selected";
  46. }
  47. }
  48. function ec_image_quick_view_update( modelnum, level, imgnum ){
  49. if(this.document.getElementById( 'ec_swatch_' + modelnum + "_" + level + "_" + imgnum ).className != "ec_product_swatch_out_of_stock"){
  50. var i=0;
  51. while( this.document.getElementById( 'ec_swatch_' + modelnum + "_" + level + "_" + i ) ){
  52. if(this.document.getElementById( 'ec_image_quick_view_' + modelnum + "_" + 1 + "_" + i ))
  53. jQuery('#ec_image_quick_view_' + modelnum + "_" + 1 + "_" + i ).hide();
  54. if(this.document.getElementById( 'ec_image_quick_view_' + modelnum + "_" + 2 + "_" + i ))
  55. jQuery('#ec_image_quick_view_' + modelnum + "_" + 2 + "_" + i ).hide();
  56. if(this.document.getElementById( 'ec_image_quick_view_' + modelnum + "_" + 3 + "_" + i ))
  57. jQuery('#ec_image_quick_view_' + modelnum + "_" + 3 + "_" + i ).hide();
  58. if(this.document.getElementById( 'ec_image_quick_view_' + modelnum + "_" + 4 + "_" + i ))
  59. jQuery('#ec_image_quick_view_' + modelnum + "_" + 4 + "_" + i ).hide();
  60. if(this.document.getElementById( 'ec_image_quick_view_' + modelnum + "_" + 5 + "_" + i ))
  61. jQuery('#ec_image_quick_view_' + modelnum + "_" + 5 + "_" + i ).hide();
  62. if(this.document.getElementById( 'ec_thumb_quick_view_' + modelnum + "_" + 1 + "_" + i ))
  63. jQuery('#ec_thumb_quick_view_' + modelnum + "_" + 1 + "_" + i ).hide();
  64. if(this.document.getElementById( 'ec_thumb_quick_view_' + modelnum + "_" + 2 + "_" + i ))
  65. jQuery('#ec_thumb_quick_view_' + modelnum + "_" + 2 + "_" + i ).hide();
  66. if(this.document.getElementById( 'ec_thumb_quick_view_' + modelnum + "_" + 3 + "_" + i ))
  67. jQuery('#ec_thumb_quick_view_' + modelnum + "_" + 3 + "_" + i ).hide();
  68. if(this.document.getElementById( 'ec_thumb_quick_view_' + modelnum + "_" + 4 + "_" + i ))
  69. jQuery('#ec_thumb_quick_view_' + modelnum + "_" + 4 + "_" + i ).hide();
  70. if(this.document.getElementById( 'ec_thumb_quick_view_' + modelnum + "_" + 5 + "_" + i ))
  71. jQuery('#ec_thumb_quick_view_' + modelnum + "_" + 5 + "_" + i ).hide();
  72. i++;
  73. }
  74. jQuery('#ec_image_quick_view_' + modelnum + "_" + 1 + "_" + imgnum ).show();
  75. if( document.getElementById( 'ec_thumb_quick_view_' + modelnum + "_" + 1 + "_" + imgnum ) )
  76. jQuery('#ec_thumb_quick_view_' + modelnum + "_" + 1 + "_" + imgnum ).show();
  77. if( document.getElementById( 'ec_thumb_quick_view_' + modelnum + "_" + 2 + "_" + imgnum ) )
  78. jQuery('#ec_thumb_quick_view_' + modelnum + "_" + 2 + "_" + imgnum ).show();
  79. if( document.getElementById( 'ec_thumb_quick_view_' + modelnum + "_" + 3 + "_" + imgnum ) )
  80. jQuery('#ec_thumb_quick_view_' + modelnum + "_" + 3 + "_" + imgnum ).show();
  81. if( document.getElementById( 'ec_thumb_quick_view_' + modelnum + "_" + 4 + "_" + imgnum ) )
  82. jQuery('#ec_thumb_quick_view_' + modelnum + "_" + 4 + "_" + imgnum ).show();
  83. if( document.getElementById( 'ec_thumb_quick_view_' + modelnum + "_" + 5 + "_" + imgnum ) )
  84. jQuery('#ec_thumb_quick_view_' + modelnum + "_" + 5 + "_" + imgnum ).show();
  85. }
  86. }
  87. function ec_product_image_click( model, level, num ){
  88. return true;
  89. }
  90. function ec_image_click( model, level, num ){
  91. return true; // just go to the link
  92. }
  93. function ec_product_details_swap_image( modelnum, level, imgnum ){
  94. var i=1;
  95. while( document.getElementById( 'ec_image_quick_view_' + modelnum + '_' + i + '_' + level ) ){
  96. document.getElementById( 'ec_image_quick_view_' + modelnum + '_' + i + '_' + level ).className = 'ec_product_image_inactive';
  97. i++;
  98. }
  99. document.getElementById( 'ec_image_quick_view_' + modelnum + '_' + imgnum + '_' + level ).className = 'ec_product_image';
  100. }
  101. var content_width = 1000;
  102. jQuery( document ).ready( function( ){
  103. content_width = jQuery( "#ec_product_page" ).width( );
  104. resize_product_layout( );
  105. if( jQuery( '.ec_product_details_page' ).width( ) < 550 ){
  106. jQuery( '.ec_product_details_right_side' ).css( 'width', '100%' );
  107. jQuery( '.ec_product_details_right_side' ).css( 'float', 'left' );
  108. jQuery( '.ec_product_details_right_side' ).css( 'margin-left', '0px' );
  109. jQuery( '.ec_product_details_left_side' ).css( 'width', '100%' );
  110. }
  111. });
  112. jQuery( window ).resize( function( ){
  113. if( content_width != jQuery( "#ec_product_page" ).width( ) ){
  114. content_width = jQuery( "#ec_product_page" ).width( );
  115. resize_product_layout( );
  116. }
  117. });
  118. function resize_product_layout( ){
  119. if( document.getElementById( 'ec_product_details_mag_viewer' ) ){
  120. var position_top = jQuery( '.ec_product_details_left_side' ).offset().top;
  121. var margin_bottom = parseInt( jQuery( '.ec_product_details_top_bar' ).css( "margin-bottom" ) );
  122. jQuery( '#ec_product_details_mag_viewer' ).css( "top", position_top + margin_bottom + 2 );
  123. }
  124. var product_width = jQuery( "#ec_product_item1" ).width( );
  125. var num_products_per_row = Math.floor( content_width / product_width );
  126. var remaining_space = content_width - ( num_products_per_row * product_width );
  127. var margin_between_product = remaining_space / ( ( ( num_products_per_row - 1 ) * 2 ) );
  128. if( Number(margin_between_product) < 1 )
  129. margin_between_product = 0;
  130. var i = 0;
  131. while( document.getElementById( "ec_product_item" + (i+1) ) ){
  132. if( i%num_products_per_row == 0 ){ //This is left product
  133. document.getElementById( "ec_product_item" + (i+1) ).setAttribute("class", "ec_product left");
  134. }else if( i%num_products_per_row == num_products_per_row-1 ){ // This is the right product
  135. document.getElementById( "ec_product_item" + (i+1) ).setAttribute("class", "ec_product right");
  136. }else{ // This is a middle product
  137. document.getElementById( "ec_product_item" + (i+1) ).setAttribute("class", "ec_product middle");
  138. }
  139. i++;
  140. }
  141. // Change class for left products so margins are correct
  142. jQuery( ".ec_product.left" ).css( "margin-left", "0px" );
  143. jQuery( ".ec_product.left" ).css( "margin-right", margin_between_product + "px" );
  144. // Change class for middle products so margins are correct
  145. jQuery( ".ec_product.middle" ).css( "margin-left", margin_between_product + "px" );
  146. jQuery( ".ec_product.middle" ).css( "margin-right", margin_between_product + "px" );
  147. // Change class for right products so margins are correct
  148. jQuery( ".ec_product.right" ).css( "margin-left", "0px" );
  149. jQuery( ".ec_product.right" ).css( "margin-right", "0px" );
  150. }// Base Theme - Product Filter Bar Javascript Document// JavaScript Document// EC Product Page JavaScript Document
  151. function change_product_sort(menu_id, menu_name, submenu_id, submenu_name, subsubmenu_id, subsubmenu_name, manufacturer_id, pricepoint_id, currentpage_selected, perpage, URL, divider){
  152. var url_string = URL + divider + "filternum=" + document.getElementById('sortfield').value;
  153. if( subsubmenu_id != 0 ){
  154. url_string = url_string + "&subsubmenuid=" + subsubmenu_id;
  155. if( subsubmenu_name != 0 )
  156. url_string = url_string + "&subsubmenu=" + subsubmenu_name;
  157. }else if( submenu_id != 0 ){
  158. url_string = url_string + "&submenuid=" + submenu_id;
  159. if( submenu_name != 0 )
  160. url_string = url_string + "&submenu=" + submenu_name;
  161. }else if( menu_id != 0 ){
  162. url_string = url_string + "&menuid=" + menu_id;
  163. if( menu_name != 0 )
  164. url_string = url_string + "&menu=" + menu_name;
  165. }
  166. if( manufacturer_id > 0 )
  167. url_string = url_string + "&manufacturer=" + manufacturer_id;
  168. if( pricepoint_id > 0 )
  169. url_string = url_string + "&pricepoint=" + pricepoint_id;
  170. if( currentpage_selected )
  171. url_string = url_string + "&pagenum=" + currentpage_selected;
  172. if( perpage )
  173. url_string = url_string + "&perpage=" + perpage;
  174. window.location = url_string;
  175. }jQuery(document).ready(
  176. function() {
  177. // In case a theme over-rides images, we need to make sure all inactive images get hidden on load
  178. jQuery( ".ec_product_image_inactive" ).hide( );
  179. // Initialize the available quick view boxes
  180. jQuery(".ec_product_quick_view_box_holder").each( function( ){
  181. var temp_split = jQuery( this ).attr( "id" ).split( "ec_product_quick_view_box_" );
  182. ec_initialize_options_product( temp_split[1] );
  183. });
  184. if( document.getElementById( 'ec_product_details_magbox' ) ){
  185. if( document.getElementById( 'ec_product_details_description_tab' ) ){
  186. if( document.getElementById( 'ec_product_details_specifications' ) )
  187. jQuery( '#ec_product_details_specifications' ).hide( );
  188. if( document.getElementById( 'ec_product_details_customer_reviews' ) )
  189. jQuery( '#ec_product_details_customer_reviews' ).hide( );
  190. }
  191. jQuery('.ec_product_details_images img').hover(
  192. function (){
  193. if( jQuery(window).width() > 960 ){
  194. if( !jQuery.browser.msie ){
  195. //jQuery('#ec_product_details_magbox').fadeIn(100);
  196. }
  197. var hasTouch = ("ontouchstart" in window);
  198. if( !hasTouch ){
  199. jQuery('#ec_product_details_mag_viewer').fadeIn(100);
  200. jQuery("#ec_product_details_mag_viewer").html('<img src="' + this.src + '" class="ec_product_details_mag_viewer_image" style="width:800px; height:800px;" width="800" height="800">');
  201. }
  202. }
  203. },
  204. function (){
  205. if( !jQuery.browser.msie ){
  206. //jQuery('#ec_product_details_magbox').fadeOut(100);
  207. }
  208. jQuery('#ec_product_details_mag_viewer').fadeOut(100);
  209. }
  210. );
  211. var position_top = jQuery( '.ec_product_details_left_side' ).offset().top;
  212. var margin_bottom = parseInt( jQuery( '.ec_product_details_top_bar' ).css( "margin-bottom" ) );
  213. jQuery( '#ec_product_details_mag_viewer' ).css( "top", position_top + margin_bottom + 2 );
  214. jQuery(document).bind('mousemove', function( e ){
  215. jQuery('#ec_product_details_magbox').css({ 'left': e.pageX - jQuery(e.target).offset().left - 20, 'top': e.pageY - jQuery(e.target).offset().top + 225});
  216. // top left position, image should be 0,0
  217. // top right position, image should be at -550, 0
  218. // bottom left position, image should be at 0, -550
  219. // bottom right position, image should be at -550, -550
  220. var mag_box_size = 350;
  221. var small_img_width = 350;
  222. var small_img_height = 350;
  223. var large_img_width = 800;
  224. var large_img_height = 800;
  225. var move_width = large_img_width - mag_box_size;
  226. var move_height = large_img_height - mag_box_size;
  227. var left_pos = e.pageX - jQuery( e.target ).offset( ).left;
  228. var top_pos = e.pageY - jQuery( e.target).offset( ).top;
  229. // %accross * amount to move * negative move distance
  230. var left = ( left_pos / small_img_width ) * move_width * -1;
  231. var top = ( top_pos / small_img_height ) * move_height * -1;
  232. jQuery('#ec_product_details_mag_viewer img').css({ 'left': left, 'top': top});
  233. });
  234. }
  235. }
  236. );
  237. // tab listener
  238. function update_content_areas( item_num ){
  239. if( item_num == 1 ){
  240. jQuery( '#ec_product_details_description' ).show( );
  241. document.getElementById( 'ec_product_details_description_tab' ).className = "ec_product_details_tab_selected";
  242. }else{
  243. jQuery( '#ec_product_details_description' ).hide( );
  244. document.getElementById( 'ec_product_details_description_tab' ).className = "ec_product_details_tab";
  245. }
  246. if( document.getElementById( 'ec_product_details_specifications' ) ){
  247. if( item_num == 2 ){
  248. jQuery( '#ec_product_details_specifications' ).show( );
  249. document.getElementById( 'ec_product_details_specifications_tab' ).className = "ec_product_details_tab_selected";
  250. }else{
  251. jQuery( '#ec_product_details_specifications' ).hide( );
  252. document.getElementById( 'ec_product_details_specifications_tab' ).className = "ec_product_details_tab";
  253. }
  254. }
  255. if( document.getElementById( 'ec_product_details_customer_reviews' ) ){
  256. if( item_num == 3 ){
  257. jQuery( '#ec_product_details_customer_reviews' ).show( );
  258. document.getElementById( 'ec_product_details_customer_reviews_tab' ).className = "ec_product_details_tab_selected";
  259. }else{
  260. jQuery( '#ec_product_details_customer_reviews' ).hide( );
  261. document.getElementById( 'ec_product_details_customer_reviews_tab' ).className = "ec_product_details_tab";
  262. }
  263. }
  264. }
  265. // Set initial variables
  266. var model_number = "";
  267. var product_id = "";
  268. var current_rating = -1;
  269. var selected_option_quantity = 0;
  270. /////////////// OPTION FUNCTIONS ///////////////////////////////
  271. // Once the page has loaded we can initialize the commonly used variables.
  272. function ec_update_product_details_variables( ){
  273. model_number = document.getElementById( 'model_number' ).value;
  274. product_id = document.getElementById('product_id').value;
  275. }
  276. // Initialize the product details page for option sets
  277. function ec_initialize_options( ){
  278. ec_update_product_details_variables( );
  279. if( ec_uses_stock_quantities( model_number ) ){
  280. if( ec_is_swatch_set( 1 ) ) ec_set_swatches_by_stock_quantities( 1 );
  281. else if( ec_is_combo_box( 1 ) ) ec_set_combo_by_stock_quantities( 1 );
  282. if( ec_is_swatch_set( 1 ) && ec_is_swatch_set( 2 )) ec_set_swatches_by_stock_quantities( 2 );
  283. else if( ec_is_swatch_set( 1 ) && ec_is_combo_box( 2 )) ec_set_combo_by_stock_quantities( 2 );
  284. else if( ec_is_swatch_set( 2 ) ) ec_clear_swatch_set( 2 );
  285. else if( ec_is_combo_box( 2 ) ) ec_clear_combo_box( 2 );
  286. if( ec_is_swatch_set( 3 ) ) ec_clear_swatch_set( 3 );
  287. else if( ec_is_combo_box( 3 ) ) ec_clear_combo_box( 3 );
  288. if( ec_is_swatch_set( 4 ) ) ec_clear_swatch_set( 4 );
  289. else if( ec_is_combo_box( 4 ) ) ec_clear_combo_box( 4 );
  290. if( ec_is_swatch_set( 5 ) ) ec_clear_swatch_set( 5 );
  291. else if( ec_is_combo_box( 5 ) ) ec_clear_combo_box( 5 );
  292. }
  293. }
  294. function ec_initialize_options_product( modnum ){
  295. model_number = modnum;
  296. if( ec_uses_stock_quantities( modnum ) ){
  297. if( ec_is_swatch_set( 1 ) ) ec_set_swatches_by_stock_quantities( 1 );
  298. else if( ec_is_combo_box( 1 ) ) ec_set_combo_by_stock_quantities( 1 );
  299. if( ec_is_swatch_set( 1 ) && ec_is_swatch_set( 2 )) ec_set_swatches_by_stock_quantities( 2 );
  300. else if( ec_is_swatch_set( 1 ) && ec_is_combo_box( 2 )) ec_set_combo_by_stock_quantities( 2 );
  301. else if( ec_is_swatch_set( 2 ) ) ec_clear_swatch_set( 2 );
  302. else if( ec_is_combo_box( 2 ) ) ec_clear_combo_box( 2 );
  303. if( ec_is_swatch_set( 3 ) ) ec_clear_swatch_set( 3 );
  304. else if( ec_is_combo_box( 3 ) ) ec_clear_combo_box( 3 );
  305. if( ec_is_swatch_set( 4 ) ) ec_clear_swatch_set( 4 );
  306. else if( ec_is_combo_box( 4 ) ) ec_clear_combo_box( 4 );
  307. if( ec_is_swatch_set( 5 ) ) ec_clear_swatch_set( 5 );
  308. else if( ec_is_combo_box( 5 ) ) ec_clear_combo_box( 5 );
  309. }
  310. }
  311. // When a swatch changes, update the state of the page
  312. function ec_swatch_click( modelnum, level, num ){
  313. model_number = modelnum;
  314. if( document.getElementById( 'ec_swatch_quick_view_' + model_number + "_" + level + "_" + num ) )
  315. element_name = 'ec_swatch_quick_view_' + model_number + "_" + level + "_" + num;
  316. else
  317. element_name = 'ec_swatch_' + model_number + "_" + level + "_" + num;
  318. if( document.getElementById( element_name ).className != "ec_product_swatch_out_of_stock" ){
  319. // Update the selected optionitem_id
  320. document.getElementById( 'ec_option' + level + "_" + model_number ).value = document.getElementById( element_name ).getAttribute( "data-optionitemid" );
  321. // If first level, AND uses option item images, swap out the product image
  322. if( ec_uses_optionitem_images( ) && level == 1 ){
  323. ec_update_product_details_images( num, level );
  324. }
  325. // Update the swatches to reflect the new selection
  326. ec_update_swatch_images( level, num );
  327. // If we use stock quantities, update the next box to reflect the correct stock count
  328. if( ec_uses_stock_quantities( ) ){
  329. ec_update_next_option_level( level, num );
  330. }//close if uses stock quantities
  331. }//close check for out of stock
  332. }//close ec_product_details_swatch_change
  333. // Run when the combo box changes
  334. function ec_product_details_combo_change( level, modelnum ){
  335. model_number = modelnum;
  336. // Only update stock stuff if this product uses that option.
  337. if( ec_uses_stock_quantities( model_number ) ){
  338. // If the user selected a value (not index 0!)
  339. if( document.getElementById( 'ec_option' + level + "_" + model_number ).selectedIndex > 0 ){
  340. ec_update_next_option_level( level, document.getElementById( 'ec_option' + level + "_" + model_number ).selectedIndex );
  341. // Otherwise reset to the previous level or reset all if level 1
  342. }else{
  343. if( level == 1 ){
  344. if( ec_uses_optionitem_images( ) ){
  345. ec_update_product_details_images( level, 0 );
  346. }
  347. ec_update_next_option_level( level, document.getElementById( 'ec_option' + level + "_" + model_number ).selectedIndex - 1 );
  348. }else{
  349. ec_update_next_option_level( level-1, get_selected_option_index( level - 1) );
  350. }//close if/else for level 1
  351. }//close if/else for 0 index check
  352. }//close check if uses stock quantities
  353. if( ec_uses_optionitem_images( ) && level == 1 && document.getElementById( 'ec_option' + level + "_" + model_number ).selectedIndex > 0 ){
  354. ec_update_product_details_images( document.getElementById( 'ec_option' + level + "_" + model_number ).selectedIndex - 1, level );
  355. }
  356. }// close ec_option_combo_change
  357. // Swap the product image
  358. function ec_thumb_click( modelnum, image_index, image_number ){
  359. var model_number = modelnum;
  360. var i=1;
  361. while( document.getElementById( 'ec_image_' + model_number + "_" + i + "_" + image_index ) ){
  362. jQuery('#ec_image_' + model_number + "_" + i + "_" + image_index ).hide();
  363. jQuery('#ec_image_quick_view_' + model_number + "_" + i + "_" + image_index ).hide();
  364. i++;
  365. }
  366. jQuery('#ec_image_' + model_number + "_" + image_number + "_" + image_index ).show();
  367. jQuery('#ec_image_quick_view_' + model_number + "_" + image_number + "_" + image_index ).show();
  368. }
  369. // Update the swatch image classes
  370. function ec_update_swatch_images( level, num ){
  371. // Only change the swatch if someone clicked a swatch that is in stock
  372. if( document.getElementById( 'ec_swatch_quick_view_' + model_number + "_" + level + "_" + num ) )
  373. element_name = 'ec_swatch_quick_view_' + model_number + "_" + level + "_";
  374. else
  375. element_name = 'ec_swatch_' + model_number + "_" + level + "_";
  376. // Only update a swatch image if it isn't out of stock!
  377. if(this.document.getElementById( element_name + num ).className != "ec_product_swatch_out_of_stock" ){
  378. var i=0;
  379. element_name_temp = element_name + i;
  380. while( document.getElementById( element_name_temp ) ){
  381. //Don't touch out of stock swatches
  382. if( document.getElementById( 'ec_swatch_' + model_number + "_" + level + "_" + i ) &&
  383. document.getElementById( 'ec_swatch_' + model_number + "_" + level + "_" + i ).className != "ec_product_swatch_out_of_stock" ){
  384. ec_set_element_class_name( 'ec_swatch_' + model_number + "_" + level + "_" + i, "ec_product_swatch" );
  385. }
  386. if( document.getElementById( 'ec_swatch_quick_view_' + model_number + "_" + level + "_" + i ) &&
  387. document.getElementById( 'ec_swatch_quick_view_' + model_number + "_" + level + "_" + i ).className != "ec_product_swatch_out_of_stock" ){
  388. ec_set_element_class_name( 'ec_swatch_quick_view_' + model_number + "_" + level + "_" + i, "ec_product_swatch" );
  389. }
  390. i++;
  391. element_name_temp = element_name + i;
  392. }
  393. ec_set_element_class_name( 'ec_swatch_' + model_number + "_" + level + "_" + num, "ec_product_swatch_selected" );
  394. ec_set_element_class_name( 'ec_swatch_quick_view_' + model_number + "_" + level + "_" + num, "ec_product_swatch_selected" );
  395. }
  396. }
  397. // Update the next option level
  398. function ec_update_next_option_level( level, num ){
  399. if( ec_uses_stock_quantities( model_number ) ){
  400. // Check for a resetting combo box, manage the quantity values different for this.
  401. if( ec_is_combo_box( level ) && num == 0 ){
  402. // Reset this combo box, lets revert the quantities
  403. selected_option_quantity = get_stock_amount( level-1, get_selected_option_index( level-1 ) );
  404. if( document.getElementById( 'in_stock_amount_text_' + model_number ) )
  405. document.getElementById( 'in_stock_amount_text_' + model_number ).innerHTML = selected_option_quantity;
  406. else if( document.getElementById( 'in_stock_amount_text' ) )
  407. document.getElementById( 'in_stock_amount_text' ).innerHTML = selected_option_quantity;
  408. if( document.getElementById( 'quantity_' + model_number ) )
  409. document.getElementById( 'quantity_' + model_number ).value = selected_option_quantity;
  410. }else{
  411. // We are moving forward, update quantities and options
  412. selected_option_quantity = get_stock_amount( level, num );
  413. if( document.getElementById( 'in_stock_amount_text_' + model_number ) )
  414. document.getElementById( 'in_stock_amount_text_' + model_number ).innerHTML = selected_option_quantity;
  415. else if( document.getElementById( 'in_stock_amount_text' ) )
  416. document.getElementById( 'in_stock_amount_text' ).innerHTML = selected_option_quantity;
  417. if( document.getElementById( 'quantity_' + model_number ) )
  418. document.getElementById( 'quantity_' + model_number ).value = selected_option_quantity;
  419. }
  420. if( Number(level) < 5 ){
  421. level = Number(level)+1;
  422. if( ec_is_swatch_set( level ) ) ec_set_swatches_by_stock_quantities( level );
  423. else if( ec_is_combo_box( level ) ) ec_set_combo_by_stock_quantities( level );
  424. }
  425. while( level < 5 ){
  426. level++;
  427. if( ec_is_swatch_set( level ) ) ec_clear_swatch_set( level );
  428. else if( ec_is_combo_box( level ) ) ec_clear_combo_box( level );
  429. }
  430. }
  431. }
  432. // Update swatches in the NEXT level based on quantities
  433. function ec_set_swatches_by_stock_quantities( level ){
  434. //If this level has swatches, update the swatches to match stock quantities
  435. if( document.getElementById( 'ec_swatch_' + model_number + '_' + level + '_0' ) ){
  436. var i=0;
  437. while( document.getElementById('ec_swatch_' + model_number + '_' + level + '_' + i ) ){
  438. if( level != 1 )
  439. document.getElementById('ec_option' + level + "_" + model_number).value = 0;
  440. if( level == 1 && i == document.getElementById( 'initial_swatch_selected_' + model_number ).value ){
  441. if( document.getElementById( 'ec_swatch_' + model_number + '_' + level + '_' + i ) )
  442. document.getElementById( 'ec_swatch_' + model_number + '_' + level + '_' + i ).className = "ec_product_swatch_selected";
  443. selected_option_quantity = get_stock_amount(level, i);
  444. if( document.getElementById('in_stock_amount_text') )
  445. document.getElementById('in_stock_amount_text').innerHTML = selected_option_quantity;
  446. }else if( ec_is_in_stock( level, i ) ){
  447. if( document.getElementById( 'ec_swatch_' + model_number + '_' + level + '_' + i ) )
  448. document.getElementById( 'ec_swatch_' + model_number + '_' + level + '_' + i ).className = "ec_product_swatch";
  449. }else{
  450. if( document.getElementById( 'ec_swatch_' + model_number + '_' + level + '_' + i ) )
  451. document.getElementById( 'ec_swatch_' + model_number + '_' + level + '_' + i ).className = "ec_product_swatch_out_of_stock";
  452. }
  453. i++;
  454. }
  455. }else if( document.getElementById( 'ec_swatch_quick_view_' + model_number + '_' + level + '_0' ) ){
  456. var i=0;
  457. while( document.getElementById('ec_swatch_quick_view_' + model_number + '_' + level + '_' + i ) ){
  458. if( level == 1 && i == document.getElementById( 'initial_swatch_selected_' + model_number ).value ){
  459. if( document.getElementById( 'ec_swatch_quick_view_' + model_number + '_' + level + '_' + i ) )
  460. document.getElementById( 'ec_swatch_quick_view_' + model_number + '_' + level + '_' + i ).className = "ec_product_swatch_selected";
  461. selected_option_quantity = get_stock_amount(level, i);
  462. if( document.getElementById('in_stock_amount_text') )
  463. document.getElementById('in_stock_amount_text').innerHTML = selected_option_quantity;
  464. }else if( ec_is_in_stock( level, i ) ){
  465. if( document.getElementById( 'ec_swatch_quick_view_' + model_number + '_' + level + '_' + i ) )
  466. document.getElementById( 'ec_swatch_quick_view_' + model_number + '_' + level + '_' + i ).className = "ec_product_swatch";
  467. }else{
  468. if( document.getElementById( 'ec_swatch_quick_view_' + model_number + '_' + level + '_' + i ) )
  469. document.getElementById( 'ec_swatch_quick_view_' + model_number + '_' + level + '_' + i ).className = "ec_product_swatch_out_of_stock";
  470. }
  471. i++;
  472. }
  473. }
  474. }
  475. // Update combo in the NEXT level based on quantities
  476. function ec_set_combo_by_stock_quantities( level ){
  477. //If this level has swatches, update the swatches to match stock quantities
  478. if(level > 1 && get_selected_option_index(level-1) == -1){
  479. document.getElementById('ec_option' + level + "_" + model_number).disabled = "disabled";
  480. document.getElementById('ec_option' + level + "_" + model_number).selectedIndex = 0;
  481. }else{
  482. document.getElementById('ec_option' + level + "_" + model_number).disabled = "";
  483. document.getElementById('ec_option' + level + "_" + model_number).selectedIndex = 0;
  484. //Hide or show items
  485. for(var i=1; i<document.getElementById('ec_option'+level+"_"+model_number).options.length; i++){
  486. if(get_stock_amount(level, i) > 0){
  487. jQuery("#ec_option"+level+"_"+model_number+" option[value=" + document.getElementById('ec_option'+level+"_"+model_number).options[i].value + "]").show();
  488. }else{
  489. jQuery("#ec_option"+level+"_"+model_number+" option[value=" + document.getElementById('ec_option'+level+"_"+model_number).options[i].value + "]").hide();
  490. }
  491. }
  492. }
  493. }
  494. // Clear a swatch set
  495. function ec_clear_swatch_set( set_num ){
  496. if(document.getElementById( 'ec_swatch_' + model_number + '_' + set_num + '_0' ) ){
  497. var i=0;
  498. while( document.getElementById('ec_swatch_' + model_number + '_' + set_num + '_' + i ) ){
  499. document.getElementById( 'ec_swatch_' + model_number + '_' + set_num + '_' + i ).className = "ec_product_swatch_out_of_stock";
  500. document.getElementById( 'ec_swatch_quick_view' + model_number + '_' + set_num + '_' + i ).className = "ec_product_swatch_out_of_stock";
  501. i++;
  502. }
  503. document.getElementById( 'ec_option' + set_num + "_" + model_number ).value = 0;
  504. }
  505. }
  506. // Get an option's specific stock quantity
  507. function get_stock_amount( level, num ){
  508. if( num == -1 )
  509. num = 0;
  510. // Get the quantity string off of the element
  511. var quantity_string = "";
  512. if( ec_is_swatch_set( level ) && document.getElementById( 'ec_swatch_' + model_number + "_" + level + "_" + num ) )
  513. quantity_string = document.getElementById( 'ec_swatch_' + model_number + "_" + level + "_" + num ).getAttribute("data-quantitystring");
  514. else if( ec_is_swatch_set( level ) && document.getElementById( 'ec_swatch_quick_view_' + model_number + "_" + level + "_" + num ) )
  515. quantity_string = document.getElementById( 'ec_swatch_quick_view_' + model_number + "_" + level + "_" + num ).getAttribute("data-quantitystring");
  516. else if( ec_is_combo_box( level ) && document.getElementById( 'ec_option' + level + "_" + model_number ) )
  517. quantity_string = document.getElementById( 'ec_option' + level + "_" + model_number ).options[num].getAttribute('data-quantitystring');
  518. else if( ec_is_combo_box( level ) && document.getElementById( 'ec_option' + level + "_quick_view_" + model_number ) )
  519. quantity_string = document.getElementById( 'ec_option' + level + "_quick_view_" + model_number ).options[num].getAttribute('data-quantitystring');
  520. else return -1;
  521. // If level 1, that is the value, otherwise we need to split and find the quantity value.
  522. if(level == 1){
  523. return Number(quantity_string);
  524. }else{
  525. // Get the selected values so far
  526. var quantity_split_string = quantity_string.split(",");
  527. var option1_index = Number(get_selected_option_index(1));
  528. var option2_index = Number(get_selected_option_index(2));
  529. var option3_index = Number(get_selected_option_index(3));
  530. var option4_index = Number(get_selected_option_index(4));
  531. var option5_index = Number(get_selected_option_index(5));
  532. var quantity_id = 0;
  533. // Use the selected index values to decide the correct index of our quantity string split
  534. if(option1_index != -1 && level == 2)
  535. quantity_id = option1_index;
  536. else if(option2_index != -1 && level == 3)
  537. quantity_id = ( option1_index * get_num_options(2) ) + option2_index;
  538. else if(option3_index != -1 && level == 4)
  539. quantity_id = ( option1_index * get_num_options(2) * get_num_options(3) ) + ( option2_index * get_num_options(3) ) + option3_index;
  540. else if(option4_index != -1 && level == 5)
  541. quantity_id = ( option1_index * get_num_options(2) * get_num_options(3) * get_num_options(4) ) + ( option2_index * get_num_options(3) * get_num_options(4) ) + ( option3_index * get_num_options(4) ) + option4_index;
  542. // Return the correct quantity value.
  543. return Number(quantity_split_string[quantity_id]);
  544. }
  545. }
  546. // Get the number of options at this level for other calculations
  547. function get_num_options( level ){
  548. if( ec_is_swatch_set( level ) ){
  549. var i = 0;
  550. while( document.getElementById( 'ec_swatch_' + model_number + "_" + level + "_" + i )){
  551. i++;
  552. }
  553. return i;
  554. }else if( ec_is_combo_box( level ) ){
  555. return Number( document.getElementById('ec_option' + level + "_" + model_number).options.length ) - 1;
  556. }else{
  557. return 0;
  558. }
  559. }
  560. // Get the selected optionitem index for an option level
  561. function get_selected_option_index( level ){
  562. if(document.getElementById('ec_option' + level + "_" + model_number)){
  563. if( ec_is_swatch_set( level ) ){
  564. var i=0;
  565. while( document.getElementById( 'ec_swatch_' + model_number + "_" + level + "_" + i ) ){
  566. if( document.getElementById( 'ec_swatch_' + model_number + "_" + level + "_" + i ).className == "ec_product_swatch_selected" ){
  567. return i;
  568. }
  569. i++;
  570. }
  571. return -1;
  572. }else if( ec_is_combo_box( level ) ){
  573. return ( Number( document.getElementById( 'ec_option' + level + "_" + model_number ).selectedIndex ) - 1 );
  574. }else{
  575. return -1;
  576. }
  577. }else{
  578. return -1;
  579. }
  580. }
  581. ///////////// END OPTION FUNCTIONS /////////////////////////
  582. ///////////// CUSTOMER REVIEW FUNCTIONS /////////////////////////
  583. // Open Customer Review Panel
  584. function product_details_customer_review_open( ){
  585. jQuery( '#customer_review_popup_background' ).fadeIn( 500 );
  586. jQuery( '#customer_review_popup_box' ).fadeIn( 500 );
  587. }//close product_details_customer_review_open
  588. // Close Customer Review Panel
  589. function product_details_customer_review_close( ){
  590. jQuery( '#customer_review_popup_background' ).fadeOut( 500 );
  591. jQuery( '#customer_review_popup_box' ).fadeOut( 500 );
  592. }//close product_details_customer_review_close
  593. // On star hover
  594. function ec_customer_review_star_hover( rating ){
  595. ec_customer_review_star_set_to_value(rating);
  596. }
  597. // On star rollout
  598. function ec_customer_review_star_rollout( rating ){
  599. ec_customer_review_star_set_to_value(current_rating);
  600. }
  601. // On star click
  602. function ec_customer_review_star_click( rating ){
  603. current_rating = rating;
  604. document.getElementById('ec_customer_review_rating').value = rating+1;
  605. ec_customer_review_star_set_to_value(rating);
  606. }
  607. // Set the value of the review based on the selected value
  608. function ec_customer_review_star_set_to_value( rating ){
  609. rating++;
  610. for(var i=0; i<rating; i++){
  611. ec_set_element_class_name( 'ec_customer_review_star_' + i, "ec_customer_review_star_on" );
  612. }
  613. for(var j=rating; j<5; j++){
  614. ec_set_element_class_name( 'ec_customer_review_star_' + j, "ec_customer_review_star_off" );
  615. }
  616. }
  617. // Disable the customer review button by hiding and showing a non-button
  618. function disable_review_button(){
  619. document.getElementById('ec_open_review_button').style.display = "none";
  620. document.getElementById('ec_open_review_button_submitted').style.display = "block";
  621. }
  622. // Reset the customer review form
  623. function product_details_customer_review_reset_form(){
  624. //reset rating and stars
  625. document.getElementById('ec_customer_review_star_0').className = "ec_customer_review_star_off";
  626. document.getElementById('ec_customer_review_star_1').className = "ec_customer_review_star_off";
  627. document.getElementById('ec_customer_review_star_2').className = "ec_customer_review_star_off";
  628. document.getElementById('ec_customer_review_star_3').className = "ec_customer_review_star_off";
  629. document.getElementById('ec_customer_review_star_4').className = "ec_customer_review_star_off";
  630. document.getElementById('ec_customer_review_rating').value = 0;
  631. //reset title and description
  632. document.getElementById('ec_customer_review_title').value = "";
  633. document.getElementById('ec_customer_review_description').value = "";
  634. }
  635. ///////////// END CUSTOMER REVIEW FUNCTIONS //////////////////////
  636. ///////////// HELPER FUNCTIONS //////////////////////////////////
  637. function ec_update_product_details_images( image_index, image_number ){
  638. var i=0;
  639. var j=1;
  640. while( document.getElementById( 'ec_image_' + model_number + "_" + 1 + "_" + i ) ){
  641. j=1;
  642. while( document.getElementById( 'ec_image_' + model_number + "_" + j + "_" + i ) ){
  643. jQuery('#ec_image_' + model_number + "_" + j + "_" + i ).hide();
  644. jQuery('#ec_thumb_' + model_number + "_" + j + "_" + i ).hide();
  645. j++;
  646. }
  647. j=1;
  648. while( document.getElementById( 'ec_image_quick_view_' + model_number + "_" + j + "_" + i ) ){
  649. jQuery('#ec_image_quick_view_' + model_number + "_" + j + "_" + i ).hide();
  650. jQuery('#ec_thumb_quick_view_' + model_number + "_" + j + "_" + i ).hide();
  651. j++;
  652. }
  653. i++;
  654. }
  655. jQuery( '#ec_image_' + model_number + "_" + 1 + "_" + image_index ).show();
  656. jQuery( '#ec_image_quick_view_' + model_number + "_" + 1 + "_" + image_index ).show();
  657. if( document.getElementById( 'ec_thumb_' + model_number + '_' + 1 + '_' + image_index ) )
  658. jQuery('#ec_thumb_' + model_number + "_" + 1 + "_" + image_index ).show();
  659. if( document.getElementById( 'ec_thumb_' + model_number + '_' + 2 + '_' + image_index ) )
  660. jQuery('#ec_thumb_' + model_number + "_" + 2 + "_" + image_index ).show();
  661. if( document.getElementById( 'ec_thumb_' + model_number + '_' + 3 + '_' + image_index ) )
  662. jQuery('#ec_thumb_' + model_number + "_" + 3 + "_" + image_index ).show();
  663. if( document.getElementById( 'ec_thumb_' + model_number + '_' + 4 + '_' + image_index ) )
  664. jQuery('#ec_thumb_' + model_number + "_" + 4 + "_" + image_index ).show();
  665. if( document.getElementById( 'ec_thumb_' + model_number + '_' + 5 + '_' + image_index ) )
  666. jQuery('#ec_thumb_' + model_number + "_" + 5 + "_" + image_index ).show();
  667. if( document.getElementById( 'ec_thumb_quick_view_' + model_number + '_' + 1 + '_' + image_index ) )
  668. jQuery('#ec_thumb_quick_view_' + model_number + "_" + 1 + "_" + image_index ).show();
  669. if( document.getElementById( 'ec_thumb_quick_view_' + model_number + '_' + 2 + '_' + image_index ) )
  670. jQuery('#ec_thumb_quick_view_' + model_number + "_" + 2 + "_" + image_index ).show();
  671. if( document.getElementById( 'ec_thumb_quick_view_' + model_number + '_' + 3 + '_' + image_index ) )
  672. jQuery('#ec_thumb_quick_view_' + model_number + "_" + 3 + "_" + image_index ).show();
  673. if( document.getElementById( 'ec_thumb_quick_view_' + model_number + '_' + 4 + '_' + image_index ) )
  674. jQuery('#ec_thumb_quick_view_' + model_number + "_" + 4 + "_" + image_index ).show();
  675. if( document.getElementById( 'ec_thumb_quick_view_' + model_number + '_' + 5 + '_' + image_index ) )
  676. jQuery('#ec_thumb_quick_view_' + model_number + "_" + 5 + "_" + image_index ).show();
  677. }
  678. function ec_set_element_class_name( element_name, class_name ){
  679. if( document.getElementById( element_name ) )
  680. document.getElementById( element_name ).className = class_name;
  681. }
  682. ///////////////// QUICK IS OR USES CHECKS ///////////////////
  683. function ec_uses_stock_quantities( ){
  684. if( document.getElementById( 'use_optionitem_quantity_tracking_' + model_number ) &&
  685. document.getElementById( 'use_optionitem_quantity_tracking_' + model_number ).value == "1" ) return true;
  686. else return false;
  687. }
  688. function ec_uses_optionitem_images( ){
  689. if( document.getElementById( 'use_optionitem_images_' + model_number ).value == 1 ) return true;
  690. else return false;
  691. }
  692. function ec_is_swatch_set( level ){
  693. if( document.getElementById( 'ec_swatch_' + model_number + '_' + level + '_0' ) )
  694. return true;
  695. else if( document.getElementById( 'ec_swatch_quick_view_' + model_number + '_' + level + '_0' ) )
  696. return true;
  697. else return false;
  698. }
  699. function ec_is_combo_box( level ){
  700. if( !ec_is_swatch_set( level ) &&
  701. document.getElementById( 'ec_option' + level + "_" + model_number ) &&
  702. document.getElementById( 'ec_option' + level + "_" + model_number ).options &&
  703. document.getElementById( 'ec_option' + level + "_" + model_number ).options.length > 1 )
  704. return true;
  705. else if( !ec_is_swatch_set( level ) &&
  706. document.getElementById( 'ec_option' + level + "_quick_view_" + model_number ) &&
  707. document.getElementById( 'ec_option' + level + "_quick_view_" + model_number ).options &&
  708. document.getElementById( 'ec_option' + level + "_quick_view_" + model_number ).options.length > 1 )
  709. return true;
  710. else return false;
  711. }
  712. function ec_is_in_stock( level, num ){
  713. if( get_stock_amount( level, num ) ) return true;
  714. else return false;
  715. }
  716. function ec_clear_combo_box( set_num ){
  717. if(document.getElementById( 'ec_option' + set_num + "_" + model_number )){
  718. document.getElementById( 'ec_option' + set_num + "_" + model_number ).selectedIndex = 0;
  719. document.getElementById( 'ec_option' + set_num + "_" + model_number ).disabled = "disabled";
  720. }
  721. }
  722. ////////// FORM SUBMISSION FUNCTIONS /////////////////////
  723. // Submit the customer review form
  724. function submit_customer_review(){
  725. var errors=0;
  726. if(document.getElementById('ec_customer_review_rating').value == 0){
  727. errors++;
  728. document.getElementById('ec_customer_review_rating_error').style.display = 'block';
  729. }else{
  730. document.getElementById('ec_customer_review_rating_error').style.display = 'none';
  731. }
  732. if(document.getElementById('ec_customer_review_title').value.length == 0){
  733. errors++;
  734. document.getElementById('ec_product_details_customer_reviews_popup_label_title').className = 'ec_product_details_customer_reviews_popup_label_row_error';
  735. }else{
  736. document.getElementById('ec_product_details_customer_reviews_popup_label_title').className = 'ec_product_details_customer_reviews_popup_label_row';
  737. }
  738. if(document.getElementById('ec_customer_review_description').value.length == 0){
  739. errors++;
  740. document.getElementById('ec_product_details_customer_reviews_popup_label_description').className = 'ec_product_details_customer_reviews_popup_label_row_error';
  741. }else{
  742. document.getElementById('ec_product_details_customer_reviews_popup_label_description').className = 'ec_product_details_customer_reviews_popup_label_row';
  743. }
  744. if(errors == 0){
  745. jQuery('#ec_customer_review_loader').fadeIn(100);
  746. var data = {
  747. action: 'ec_ajax_insert_customer_review',
  748. product_id: document.getElementById('product_id').value,
  749. rating: document.getElementById('ec_customer_review_rating').value,
  750. title: document.getElementById('ec_customer_review_title').value,
  751. description: document.getElementById('ec_customer_review_description').value
  752. };
  753. jQuery.ajax({url: ajax_object.ajax_url, type: 'post', data: data, success: function(data){ jQuery('#ec_customer_review_loader').fadeOut(100); product_details_customer_review_close(); product_details_customer_review_reset_form(); disable_review_button(); } } );
  754. }
  755. return false;
  756. }
  757. // Add to cart function
  758. function ec_product_details_add_to_cart( modelnum ){
  759. model_number = modelnum;
  760. var errors = 0;
  761. if( document.getElementById( 'ec_option1_' + model_number ) ){
  762. if( document.getElementById( 'ec_option1_' + model_number ).value == "0" ){
  763. if( ec_is_combo_box( 1 ) ) document.getElementById( 'ec_option1_' + model_number ).className = "ec_product_details_option_combo_error";
  764. else ec_show_swatch_error( 1 );
  765. errors++;
  766. }else{
  767. if( ec_is_combo_box( 1 ) ) document.getElementById( 'ec_option1_' + model_number ).className = "ec_product_details_option_combo";
  768. else ec_hide_swatch_error( 1 );
  769. }
  770. }
  771. if( document.getElementById( 'ec_option2_' + model_number ) ){
  772. if( document.getElementById( 'ec_option2_' + model_number ).value == "0"){
  773. if( ec_is_combo_box( 2 ) ) document.getElementById( 'ec_option2_' + model_number ).className = "ec_product_details_option_combo_error";
  774. else ec_show_swatch_error( 2 );
  775. errors++;
  776. }else{
  777. if( ec_is_combo_box( 2 ) ) document.getElementById( 'ec_option2_' + model_number ).className = "ec_product_details_option_combo";
  778. else ec_hide_swatch_error( 2 );
  779. }
  780. }
  781. if( document.getElementById( 'ec_option3_' + model_number ) ){
  782. if( document.getElementById( 'ec_option3_' + model_number ).value == "0"){
  783. if( ec_is_combo_box( 3 ) ) document.getElementById( 'ec_option3_' + model_number ).className = "ec_product_details_option_combo_error";
  784. else ec_show_swatch_error( 3 );
  785. errors++;
  786. }else{
  787. if( ec_is_combo_box( 3 ) ) document.getElementById( 'ec_option3_' + model_number ).className = "ec_product_details_option_combo";
  788. else ec_hide_swatch_error( 3 );
  789. }
  790. }
  791. if( document.getElementById( 'ec_option4_' + model_number ) ){
  792. if( document.getElementById( 'ec_option4_' + model_number ).value == "0"){
  793. if( ec_is_combo_box( 4 ) ) document.getElementById( 'ec_option4_' + model_number ).className = "ec_product_details_option_combo_error";
  794. else ec_show_swatch_error( 4 );
  795. errors++;
  796. }else{
  797. if( ec_is_combo_box( 4 ) ) document.getElementById( 'ec_option4_' + model_number ).className = "ec_product_details_option_combo";
  798. else ec_hide_swatch_error( 4 );
  799. }
  800. }
  801. if( document.getElementById( 'ec_option5_' + model_number ) ){
  802. if( document.getElementById( 'ec_option5_' + model_number ).value == "0"){
  803. if( ec_is_combo_box( 5 ) ) document.getElementById( 'ec_option5_' + model_number ).className = "ec_product_details_option_combo_error";
  804. else ec_show_swatch_error( 5 );
  805. errors++;
  806. }else{
  807. if( ec_is_combo_box( 5 ) ) document.getElementById( 'ec_option5_' + model_number ).className = "ec_product_details_option_combo";
  808. else ec_hide_swatch_error( 5 );
  809. }
  810. }
  811. if( document.getElementById( 'is_donation_' + model_number ) && document.getElementById( 'is_donation_' + model_number ).value == "1" ){
  812. var donation_amount = document.getElementById( 'ec_product_input_price' ).value;
  813. var min_amount = document.getElementById( 'ec_product_min_donation_amount' ).value;
  814. if( isNaN( donation_amount ) || Number( donation_amount ) < min_amount ){
  815. document.getElementById('ec_product_details_donation_row').className = "ec_product_details_donation_error";
  816. errors++;
  817. }else{
  818. document.getElementById('ec_product_details_donation_row').className = "ec_product_details_donation";
  819. }
  820. }else{
  821. if( ( ec_track_basic_quantity( model_number ) && !ec_check_basic_quantity( model_number ) ) || !ec_has_valid_quantity( model_number, selected_option_quantity ) ){
  822. document.getElementById( 'ec_product_details_quantity_' + model_number ).className = "ec_product_details_quantity_error";
  823. errors++;
  824. }else{
  825. document.getElementById( 'ec_product_details_quantity_' + model_number ).className = "ec_product_details_quantity";
  826. }
  827. }
  828. if( document.getElementById( 'ec_gift_card_message_' + model_number ) && document.getElementById( 'ec_gift_card_message_' + model_number ).value.length == 0 ){
  829. document.getElementById( 'ec_gift_card_message_' + model_number ).className = "ec_gift_card_message_error";
  830. errors++;
  831. }else if( document.getElementById( 'ec_gift_card_message_' + model_number ) ){
  832. document.getElementById( 'ec_gift_card_message_' + model_number ).className = "ec_gift_card_message";
  833. }
  834. if( document.getElementById( 'ec_gift_card_to_name_' + model_number ) && document.getElementById( 'ec_gift_card_to_name_' + model_number ).value.length == 0 ){
  835. document.getElementById( 'ec_gift_card_to_name_' + model_number ).className = "ec_gift_card_to_name_error";
  836. errors++;
  837. }else if( document.getElementById( 'ec_gift_card_to_name_' + model_number ) ){
  838. document.getElementById( 'ec_gift_card_to_name_' + model_number ).className = "ec_gift_card_to_name";
  839. }
  840. if( document.getElementById( 'ec_gift_card_from_name_' + model_number ) && document.getElementById( 'ec_gift_card_from_name_' + model_number ).value.length == 0 ){
  841. document.getElementById( 'ec_gift_card_from_name_' + model_number ).className = "ec_gift_card_from_name_error";
  842. errors++;
  843. }else if( document.getElementById( 'ec_gift_card_from_name_' + model_number ) ){
  844. document.getElementById( 'ec_gift_card_from_name_' + model_number ).className = "ec_gift_card_from_name";
  845. }
  846. if(errors == 0)
  847. return true;
  848. else
  849. return false;
  850. }
  851. function ec_product_details_add_to_cart_advanced( model_number ){
  852. var i=0;
  853. var errors=0;
  854. while( document.getElementById( 'ec_option' + i + '_' + model_number ) || document.getElementById( 'ec_option' + i + '_' + model_number + '_0' ) ){
  855. if( document.getElementById( 'ec_option' + i + '_' + model_number ) ){
  856. if( document.getElementById( 'ec_option' + i + '_' + model_number ).value <= 0 && document.getElementById( 'ec_option' + i + '_' + model_number ).getAttribute( "data-ec-required" ) == '1' ){
  857. document.getElementById( 'ec_option' + i + '_' + model_number + "_error" ).style.display = "block";
  858. errors++;
  859. }else{
  860. document.getElementById( 'ec_option' + i + '_' + model_number + "_error" ).style.display = "none";
  861. }
  862. }else{
  863. var input_type = jQuery( '#ec_option' + i + '_' + model_number + "_0" ).attr("type").toLowerCase();
  864. if( input_type == "checkbox" ){
  865. var j=0;
  866. var selected = 0;
  867. while( document.getElementById( 'ec_option' + i + '_' + model_number + '_' + j ) ){
  868. if( jQuery( '#ec_option' + i + '_' + model_number + "_" + j ).prop("checked") ){
  869. selected++;
  870. }
  871. j++;
  872. }
  873. if( selected <= 0 && document.getElementById( 'ec_option' + i + '_' + model_number + '_0' ).getAttribute( "data-ec-required" ) == '1' ){
  874. document.getElementById( 'ec_option' + i + '_' + model_number + "_error" ).style.display = "block";
  875. errors++;
  876. }else{
  877. document.getElementById( 'ec_option' + i + '_' + model_number + "_error" ).style.display = "none";
  878. }
  879. }else if( input_type == "radio" ){
  880. var j=0;
  881. var selected = 0;
  882. while( document.getElementById( 'ec_option' + i + '_' + model_number + '_' + j ) ){
  883. if( jQuery( '#ec_option' + i + '_' + model_number + "_" + j ).prop("checked") ){
  884. selected++;
  885. }
  886. j++;
  887. }
  888. if( selected <= 0 && document.getElementById( 'ec_option' + i + '_' + model_number + '_0' ).getAttribute( "data-ec-required" ) == '1' ){
  889. document.getElementById( 'ec_option' + i + '_' + model_number + "_error" ).style.display = "block";
  890. errors++;
  891. }else{
  892. document.getElementById( 'ec_option' + i + '_' + model_number + "_error" ).style.display = "none";
  893. }
  894. }else if( input_type == "number" ){
  895. var j=0;
  896. var total=0;
  897. while( document.getElementById( 'ec_option' + i + '_' + model_number + '_' + j ) ){
  898. total = total + Number( jQuery( '#ec_option' + i + '_' + model_number + "_" + j ).val( ) );
  899. j++;
  900. }
  901. if( total <= 0 && document.getElementById( 'ec_option' + i + '_' + model_number + '_0' ).getAttribute( "data-ec-required" ) == '1' ){
  902. document.getElementById( 'ec_option' + i + '_' + model_number + "_error" ).style.display = "block";
  903. errors++;
  904. }else{
  905. document.getElementById( 'ec_option' + i + '_' + model_number + "_error" ).style.display = "none";
  906. }
  907. }
  908. }
  909. i++;
  910. }
  911. if( errors > 0 )
  912. return false;
  913. else
  914. return true;
  915. }
  916. function ec_track_basic_quantity( model_number ){
  917. if( document.getElementById( 'show_stock_quantity_' + model_number ) && document.getElementById( 'show_stock_quantity_' + model_number ).value == "1" )
  918. return true;
  919. else
  920. return false;
  921. }
  922. function ec_check_basic_quantity( model_number ){
  923. var quantity = Number( document.getElementById( 'product_quantity_' + model_number ).value );
  924. var stock_quantity = Number( document.getElementById( 'quantity_' + model_number ).value );
  925. if( quantity <= stock_quantity )
  926. return true;
  927. else
  928. return false;
  929. }
  930. function ec_has_valid_quantity( model_number, selected_option_quantity ){
  931. var quantity = Number( document.getElementById( 'product_quantity_' + model_number ).value );
  932. if( !is_valid_quantity_entry( model_number ) || ( ec_uses_stock_quantities( model_number ) && quantity > selected_option_quantity ) )
  933. return false;
  934. else{
  935. return true;
  936. }
  937. }
  938. function is_valid_quantity_entry( model_number ){
  939. if( isNaN( document.getElementById( 'product_quantity_' + model_number ).value ) || Number( document.getElementById('product_quantity_' + model_number).value ) < 1 )
  940. return false;
  941. else
  942. return true;
  943. }
  944. function ec_show_swatch_error( level ){
  945. var error_text = "Please select all options for this product.";
  946. if( document.getElementById( 'ec_quick_view_error_' + model_number ) ){
  947. document.getElementById( 'ec_quick_view_error_' + model_number ).innerHTML = error_text;
  948. jQuery( '#ec_quick_view_error_' + model_number ).fadeIn(200);
  949. }
  950. }
  951. function ec_hide_swatch_error( level ){
  952. if( document.getElementById( 'ec_quick_view_error_' + model_number ) ){
  953. document.getElementById( 'ec_quick_view_error_' + model_number ).innerHTML = "";
  954. jQuery( '#ec_quick_view_error_' + model_number ).fadeOut(100);
  955. }else if( document.getElementById( 'ec_quick_view_error' ) ){
  956. document.getElementById( 'ec_quick_view_error' ).innerHTML = "";
  957. jQuery( '#ec_quick_view_error').fadeOut(100);
  958. }
  959. }
  960. function ec_product_details_update_quantity_value( ){
  961. if( document.getElementById( 'use_optionitem_quantity_tracking_' + model_number ) && document.getElementById( 'use_optionitem_quantity_tracking_' + model_number ).value == 1 ){
  962. selected_option_quantity = selected_option_quantity - document.getElementById('product_quantity_' + model_number).value;
  963. document.getElementById('in_stock_amount_text_' + model_number ).innerHTML = selected_option_quantity;
  964. }else{
  965. document.getElementById( 'quantity_' + model_number ).value = document.getElementById( 'quantity_' + model_number ).value - document.getElementById( 'product_quantity_' + model_number ).value;
  966. document.getElementById( 'in_stock_amount_text_' + model_number ).innerHTML = document.getElementById( 'quantity_' + model_number ).value;
  967. }
  968. document.getElementById('product_quantity_' + model_number).value = 1;
  969. }
  970. function ec_continue_shopping_click(){
  971. jQuery('#ec_product_details_temp_cart_holder').fadeOut(100);
  972. }
  973. function ec_image_click( model, level, num ){
  974. return false;
  975. }// Base Theme - Product Filter Bar Javascript Document// Base Theme - Product Filter Bar Javascript Document// Base Theme - Product Filter Bar Javascript Document// Base Theme - EC Cart Page Javascript Document
  976. function ec_cart_validate_checkout_info( ){
  977. var billing_country_code = document.getElementById('ec_cart_billing_country').value;
  978. var shipping_country_code = document.getElementById('ec_cart_shipping_country').value;
  979. if( document.getElementById('ec_contact_first_name') ){
  980. var first_name = document.getElementById('ec_contact_first_name').value;
  981. var last_name = document.getElementById('ec_contact_last_name').value;
  982. }
  983. var create_account = false;
  984. if( document.getElementById('ec_contact_email') ){
  985. var email = document.getElementById('ec_contact_email').value;
  986. var retype_email = document.getElementById('ec_contact_email_retype').value;
  987. }
  988. if( document.getElementById('ec_contact_create_account') && document.getElementById('ec_contact_create_account').checked ){
  989. create_account = true;
  990. var password = document.getElementById('ec_contact_password').value;
  991. var retype_password = document.getElementById('ec_contact_password_retype').value;
  992. }
  993. var shipping_selector = false;
  994. if( document.getElementById('ec_cart_use_shipping_for_shipping') && document.getElementById('ec_cart_use_shipping_for_shipping').checked )
  995. shipping_selector = true;
  996. var errors = 0;
  997. var input_names = ['first_name', 'last_name', 'address', 'city', 'state', 'zip', 'country'];
  998. if( document.getElementById( 'ec_cart_billing_phone' ) ){
  999. input_names.push( 'phone' );
  1000. }
  1001. for( var i=0; i< input_names.length; i++){
  1002. if( input_names[i] == "state" && document.getElementById( 'ec_cart_billing_' + input_names[i] + '_' + billing_country_code ) && document.getElementById( 'ec_cart_billing_' + input_names[i] + '_' + billing_country_code ).options ){
  1003. var value = document.getElementById( 'ec_cart_billing_' + input_names[i] + '_' + billing_country_code ).options[document.getElementById( 'ec_cart_billing_' + input_names[i] + '_' + billing_country_code ).selectedIndex].value;
  1004. }else{
  1005. var value = document.getElementById( 'ec_cart_billing_' + input_names[i] ).value;
  1006. }
  1007. // validate billing
  1008. if( !ec_validation( "validate_" + input_names[i], value, billing_country_code ) ){
  1009. errors++;
  1010. document.getElementById('ec_cart_billing_' + input_names[i] + '_row').className = "ec_cart_billing_row_error";
  1011. jQuery( '#ec_cart_error_billing_' + input_names[i] ).show( );
  1012. }else{
  1013. document.getElementById('ec_cart_billing_' + input_names[i] + '_row').className = "ec_cart_billing_row";
  1014. jQuery( '#ec_cart_error_billing_' + input_names[i] ).hide( );
  1015. }
  1016. }
  1017. if( shipping_selector ){
  1018. for( i=0; i < input_names.length; i++ ){
  1019. if( input_names[i] == "state" && document.getElementById( 'ec_cart_shipping_' + input_names[i] + '_' + shipping_country_code ) && document.getElementById( 'ec_cart_shipping_' + input_names[i] + '_' + shipping_country_code ).options ){
  1020. var value = document.getElementById( 'ec_cart_shipping_' + input_names[i] + '_' + shipping_country_code ).options[document.getElementById( 'ec_cart_shipping_' + input_names[i] + '_' + shipping_country_code ).selectedIndex].value;
  1021. }else{
  1022. var value = document.getElementById( 'ec_cart_shipping_' + input_names[i] ).value;
  1023. }
  1024. // validate shipping
  1025. if( !ec_validation( "validate_" + input_names[i], value, shipping_country_code ) ){
  1026. errors++;
  1027. document.getElementById('ec_cart_shipping_' + input_names[i] + '_row').className = "ec_cart_shipping_row_error";
  1028. jQuery( '#ec_cart_error_shipping_' + input_names[i] ).show( );
  1029. }else{
  1030. document.getElementById('ec_cart_shipping_' + input_names[i] + '_row').className = "ec_cart_shipping_row";
  1031. jQuery( '#ec_cart_error_shipping_' + input_names[i] ).hide( );
  1032. }
  1033. }
  1034. }
  1035. if( document.getElementById('ec_contact_first_name') ){
  1036. if( !ec_validation( "validate_first_name", first_name, billing_country_code ) ){
  1037. errors++;
  1038. document.getElementById('ec_contact_first_name_row').className = "ec_cart_contact_information_row_error";
  1039. jQuery( '#ec_cart_error_contact_first_name' ).show( );
  1040. }else{
  1041. document.getElementById('ec_contact_first_name_row').className = "ec_cart_contact_information_row";
  1042. jQuery( '#ec_cart_error_contact_first_name' ).hide( );
  1043. }
  1044. if( !ec_validation( "validate_last_name", last_name, billing_country_code ) ){
  1045. errors++;
  1046. document.getElementById('ec_contact_last_name_row').className = "ec_cart_contact_information_row_error";
  1047. jQuery( '#ec_cart_error_contact_last_name' ).show( );
  1048. }else{
  1049. document.getElementById('ec_contact_last_name_row').className = "ec_cart_contact_information_row";
  1050. jQuery( '#ec_cart_error_contact_last_name' ).hide( );
  1051. }
  1052. }
  1053. if( document.getElementById('ec_contact_email') ){
  1054. if( !ec_validation( "validate_email", email, billing_country_code ) ){
  1055. errors++;
  1056. document.getElementById('ec_contact_email_row').className = "ec_cart_contact_information_row_error";
  1057. jQuery( '#ec_cart_error_email' ).show( );
  1058. }else{
  1059. document.getElementById('ec_contact_email_row').className = "ec_cart_contact_information_row";
  1060. jQuery( '#ec_cart_error_email' ).hide( );
  1061. }
  1062. if( retype_email.length == 0 || email != retype_email ){
  1063. errors++;
  1064. document.getElementById('ec_contact_email_retype_row').className = "ec_cart_contact_information_row_error";
  1065. }else{
  1066. document.getElementById('ec_contact_email_retype_row').className = "ec_cart_contact_information_row";
  1067. }
  1068. if( retype_email.length == 0 ){
  1069. jQuery( '#ec_cart_error_retype_email' ).show( );
  1070. }else if( email != retype_email ){
  1071. jQuery( '#ec_cart_error_retype_email' ).hide( );
  1072. jQuery( '#ec_cart_error_email_match' ).show( );
  1073. }else{
  1074. jQuery( '#ec_cart_error_retype_email' ).hide( );
  1075. jQuery( '#ec_cart_error_email_match' ).hide( );
  1076. }
  1077. }
  1078. if( create_account ){
  1079. if( !ec_validation( "validate_password", password, billing_country_code ) ){
  1080. errors++;
  1081. document.getElementById('ec_contact_password_row').className = "ec_cart_contact_information_row_error";
  1082. }else{
  1083. document.getElementById('ec_contact_password_row').className = "ec_cart_contact_information_row";
  1084. }
  1085. if( retype_password.length == 0 || password != retype_password ){
  1086. errors++;
  1087. document.getElementById('ec_contact_password_retype_row').className = "ec_cart_contact_information_row_error";
  1088. }else{
  1089. document.getElementById('ec_contact_password_retype_row').className = "ec_cart_contact_information_row";
  1090. }
  1091. if( retype_password.length == 0 ){
  1092. jQuery( '#ec_cart_error_retype_password' ).show( );
  1093. }else if( password != retype_password ){
  1094. jQuery( '#ec_cart_error_retype_password' ).hide( );
  1095. jQuery( '#ec_cart_error_password_match' ).show( );
  1096. }else{
  1097. jQuery( '#ec_cart_error_retype_password' ).hide( );
  1098. jQuery( '#ec_cart_error_password_match' ).hide( );
  1099. }
  1100. if( password.length <= 0 ){
  1101. jQuery( '#ec_cart_error_password' ).show( );
  1102. }else if( password.length < 6 ){
  1103. jQuery( '#ec_cart_error_password_length' ).show( );
  1104. jQuery( '#ec_cart_error_password' ).hide( );
  1105. }else{
  1106. jQuery( '#ec_cart_error_password_length' ).hide( );
  1107. jQuery( '#ec_cart_error_password' ).hide( );
  1108. }
  1109. }
  1110. if( errors ){
  1111. jQuery( '#ec_cart_error_text' ).show( );
  1112. jQuery( 'html, body' ).animate( {
  1113. scrollTop: jQuery("#ec_cart_error_scroll").offset( ).top - 150
  1114. }, 750);
  1115. return false;
  1116. }else{
  1117. jQuery( '#ec_cart_error_text' ).hide( );
  1118. return true;
  1119. }
  1120. }
  1121. function ec_cart_validate_checkout_shipping( ){
  1122. var errors = 0;
  1123. if ( !jQuery( "input[name='ec_cart_shipping_method']:checked" ).val( ) ){
  1124. errors++;
  1125. jQuery( ".ec_cart_shipping_method_row" ).css("color", "#900");
  1126. }else{
  1127. jQuery( ".ec_cart_shipping_method_row" ).css("color", "#999");
  1128. }
  1129. if( errors )
  1130. return false;
  1131. else
  1132. return true;
  1133. }
  1134. function ec_cart_validate_checkout_submit_order( ){
  1135. jQuery( '.ec_cart_final_loader_overlay' ).show( );
  1136. var errors = 0;
  1137. var payment_type = jQuery('input[name=ec_cart_payment_selection]:checked').val();
  1138. if( !document.getElementById( 'ec_cart_pay_by_manual_payment' ) && !document.getElementById( 'ec_cart_pay_by_third_party' ) && !document.getElementById( 'ec_cart_pay_by_credit_card_holder' ) ){
  1139. return true;
  1140. }else if( payment_type ){
  1141. jQuery('.ec_cart_payment_information_payment_type_row.error').removeClass('error');
  1142. if( payment_type == "credit_card" ){
  1143. var card_number = document.getElementById('ec_card_number').value;
  1144. var exp_month = document.getElementById('ec_expiration_month').value;
  1145. var exp_year = document.getElementById('ec_expiration_year').value;
  1146. var sec_code = document.getElementById('ec_security_code').value;
  1147. if( card_number.length <= 0 ){
  1148. errors++;
  1149. jQuery('#ec_cart_error_payment_card_number').show( );
  1150. }else{
  1151. jQuery('#ec_cart_error_payment_card_number').hide( );
  1152. }
  1153. if( card_number.length > 0 && !ec_validation( "validate_card_number", card_number, "" ) ){
  1154. jQuery('#ec_cart_error_payment_card_number_error').show( );
  1155. errors++;
  1156. }else{
  1157. jQuery('#ec_cart_error_payment_card_number_error').hide( );
  1158. }
  1159. if( !ec_validation( "validate_expiration_month", exp_month, "" ) || !ec_validation( "validate_expiration_year", exp_year, "" ) )
  1160. errors++;
  1161. if( !ec_validation( "validate_expiration_month", exp_month, "" ) ){
  1162. jQuery('#ec_cart_error_payment_card_exp_month').show( );
  1163. }else{
  1164. jQuery('#ec_cart_error_payment_card_exp_month').hide( );
  1165. }
  1166. if( !ec_validation( "validate_expiration_year", exp_year, "" ) ){
  1167. jQuery('#ec_cart_error_payment_card_exp_year').show( );
  1168. }else{
  1169. jQuery('#ec_cart_error_payment_card_exp_year').hide( );
  1170. }
  1171. if( !ec_validation( "validate_security_code", sec_code, "" ) ){
  1172. errors++;
  1173. jQuery('#ec_cart_error_payment_card_code').show( );
  1174. }else{
  1175. jQuery('#ec_cart_error_payment_card_code').hide( );
  1176. }
  1177. }
  1178. }else{
  1179. jQuery('.ec_cart_payment_information_payment_type_row').addClass('error');
  1180. errors++;
  1181. }
  1182. if( errors ){
  1183. jQuery('#ec_cart_payment_error_text').show( );
  1184. jQuery( 'html, body' ).animate( {
  1185. scrollTop: jQuery("#ec_cart_payment_error_text").offset( ).top - 150
  1186. }, 750);
  1187. return false;
  1188. }else{
  1189. jQuery('#ec_cart_payment_error_text').hide( );
  1190. return true;
  1191. }
  1192. }
  1193. function ec_cart_validate_subscription_order( ){
  1194. var errors = 0;
  1195. var billing_country_code = document.getElementById('ec_cart_billing_country').value;
  1196. var payment_method = document.getElementById('ec_cart_payment_type').value;
  1197. var card_holder_name = document.getElementById('ec_card_holder_name').value;
  1198. var card_number = document.getElementById('ec_card_number').value;
  1199. var exp_month = document.getElementById('ec_expiration_month').value;
  1200. var exp_year = document.getElementById('ec_expiration_year').value;
  1201. var sec_code = document.getElementById('ec_security_code').value;
  1202. // Validate Billing Information
  1203. var input_names = ['first_name', 'last_name', 'address', 'city', 'state', 'zip', 'country', 'phone'];
  1204. for( var i=0; i< input_names.length; i++){
  1205. if( input_names[i] == "state" && document.getElementById( 'ec_cart_billing_' + input_names[i] ).options ){
  1206. var value = document.getElementById( 'ec_cart_billing_' + input_names[i] ).options[document.getElementById( 'ec_cart_billing_' + input_names[i] ).selectedIndex].value;
  1207. }else{
  1208. var value = document.getElementById( 'ec_cart_billing_' + input_names[i] ).value;
  1209. }
  1210. // validate billing
  1211. if( !ec_validation( "validate_" + input_names[i], value, billing_country_code ) ){
  1212. errors++;
  1213. document.getElementById('ec_cart_billing_' + input_names[i] + '_row').className = "ec_cart_billing_row_error";
  1214. }else{
  1215. document.getElementById('ec_cart_billing_' + input_names[i] + '_row').className = "ec_cart_billing_row";
  1216. }
  1217. }
  1218. // Validate Credit Card Information
  1219. if( payment_method == "0" ){
  1220. errors++;
  1221. document.getElementById('ec_cart_payment_type_row').className = "ec_cart_payment_information_row_error";
  1222. }else{
  1223. document.getElementById('ec_cart_payment_type_row').className = "ec_cart_payment_information_row";
  1224. }
  1225. if( !ec_validation( "validate_card_holder_name", card_holder_name, payment_method ) ){
  1226. errors++;
  1227. document.getElementById('ec_card_holder_name_row').className = "ec_cart_payment_information_row_error";
  1228. }else{
  1229. document.getElementById('ec_card_holder_name_row').className = "ec_cart_payment_information_row";
  1230. }
  1231. if( !ec_validation( "validate_card_number", card_number, payment_method ) ){
  1232. errors++;
  1233. document.getElementById('ec_card_number_row').className = "ec_cart_payment_information_row_error";
  1234. }else{
  1235. document.getElementById('ec_card_number_row').className = "ec_cart_payment_information_row";
  1236. }
  1237. if( !ec_validation( "validate_expiration_month", exp_month, payment_method ) || !ec_validation( "validate_expiration_year", exp_year, payment_method ) ){
  1238. errors++;
  1239. document.getElementById('ec_expiration_date_row').className = "ec_cart_payment_information_row_error";
  1240. }else{
  1241. document.getElementById('ec_expiration_date_row').className = "ec_cart_payment_information_row";
  1242. }
  1243. if( !ec_validation( "validate_security_code", sec_code, payment_method ) ){
  1244. errors++;
  1245. document.getElementById('ec_security_code_row').className = "ec_cart_payment_information_row_error";
  1246. }else{
  1247. document.getElementById('ec_security_code_row').className = "ec_cart_payment_information_row";
  1248. }
  1249. // If new account, Validate Account Info
  1250. if( document.getElementById( 'ec_contact_email' ) ){
  1251. var email = jQuery( '#ec_contact_email' ).val( );
  1252. var retype_email = jQuery( '#ec_contact_email_retype' ).val( );
  1253. var password = jQuery( '#ec_contact_password' ).val( );
  1254. var retype_password = jQuery( '#ec_contact_password_retype' ).val( );
  1255. if( !ec_validation( "validate_email", email, billing_country_code ) ){
  1256. errors++;
  1257. document.getElementById('ec_contact_email_row').className = "ec_cart_contact_information_row_error";
  1258. }else{
  1259. document.getElementById('ec_contact_email_row').className = "ec_cart_contact_information_row";
  1260. }
  1261. if( retype_email.length == 0 || email != retype_email ){
  1262. errors++;
  1263. document.getElementById('ec_contact_email_retype_row').className = "ec_cart_contact_information_row_error";
  1264. }else{
  1265. document.getElementById('ec_contact_email_retype_row').className = "ec_cart_contact_information_row";
  1266. }
  1267. if( !ec_validation( "validate_password", password, billing_country_code ) ){
  1268. errors++;
  1269. document.getElementById('ec_contact_password_row').className = "ec_cart_contact_information_row_error";
  1270. }else{
  1271. document.getElementById('ec_contact_password_row').className = "ec_cart_contact_information_row";
  1272. }
  1273. if( retype_password.length == 0 || password != retype_password ){
  1274. errors++;
  1275. document.getElementById('ec_contact_password_retype_row').className = "ec_cart_contact_information_row_error";
  1276. }else{
  1277. document.getElementById('ec_contact_password_retype_row').className = "ec_cart_contact_information_row";
  1278. }
  1279. }
  1280. if( errors )
  1281. return false;
  1282. else
  1283. return true;
  1284. }// Base Theme - EC Cart Javascript Document
  1285. function ec_estimate_shipping_click( ){
  1286. jQuery('#ec_estimate_shipping_loader').fadeIn(100);
  1287. var data = {
  1288. action: 'ec_ajax_estimate_shipping',
  1289. zipcode: document.getElementById( 'ec_cart_zip_code' ).value,
  1290. country: document.getElementById( 'ec_cart_country' ).value
  1291. };
  1292. jQuery.ajax({url: ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ ec_estimate_shipping_complete( data ); } } );
  1293. return false;
  1294. }
  1295. function ec_estimate_shipping_complete( data ){
  1296. jQuery('#ec_estimate_shipping_loader').fadeOut(100);
  1297. var values = data.split("***");
  1298. if( values.length == 2 ){
  1299. document.getElementById('ec_cart_shipping').innerHTML = values[0];
  1300. document.getElementById('ec_cart_grandtotal').innerHTML = values[1];
  1301. }else{
  1302. document.getElementById('ec_cart_shipping').innerHTML = values[0];
  1303. document.getElementById('ec_cart_grandtotal').innerHTML = values[1];
  1304. document.getElementById('ec_cart_shipping_methods').innerHTML = values[2];
  1305. }
  1306. }// Base Theme - EC Cart Item Javascript Document
  1307. function ec_cart_item_update( cartitem_id ){
  1308. var data = {
  1309. action: 'ec_ajax_cartitem_update',
  1310. cartitem_id: cartitem_id,
  1311. quantity: document.getElementById( 'ec_cartitem_quantity_' + cartitem_id ).value,
  1312. session_id: document.getElementById( 'ec_cart_session_id' ).value
  1313. };
  1314. ec_cart_item_show_loader( cartitem_id );
  1315. jQuery.ajax({url: ajax_object.ajax_url, type: 'post', data: data, success: function( data ){ ec_cart_item_update_finished( data, cartitem_id ); } } );
  1316. }
  1317. function ec_cart_item_update_finished( data, cartitem_id ){
  1318. ec_cart_item_hide_loader( cartitem_id );
  1319. var currency = document.getElementById( 'ec_cartitem_unit_price_' + cartitem_id ).innerHTML.substring(0,1);
  1320. var item_unit_price = parseFloat( document.getElementById( 'ec_cartitem_unit_price_' + cartitem_id ).innerHTML.substring(1).replace( /,/g,'') );
  1321. var item_quantity = Number( document.getElementById( 'ec_cartitem_quantity_' + cartitem_id ).value ).toFixed(2);
  1322. var item_total_price = currency + (item_unit_price * item_quantity).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  1323. document.getElementById('ec_cartitem_total_' + cartitem_id).innerHTML = item_total_price;
  1324. if( document.getElementById( 'ec_cart_zip_code' ) ){
  1325. ec_estimate_shipping_click( );
  1326. }
  1327. if( document.getElementById('ec_cart_subtotal') ){
  1328. var data_split = data.split("***");
  1329. //document.getElementById('ec_cart_total_items').innerHTML = data_split[0];
  1330. if( document.getElementById( 'ec_cartitem_unit_price_' + cartitem_id ) )
  1331. document.getElementById( 'ec_cartitem_unit_price_' + cartitem_id ).innerHTML = data_split[0];
  1332. if( document.getElementById( 'ec_cartitem_total_' + cartitem_id ) )
  1333. document.getElementById( 'ec_cartitem_total_' + cartitem_id ).innerHTML = data_split[1];
  1334. if( document.getElementById( 'ec_cartitem_quantity_' + cartitem_id ) )
  1335. document.getElementById( 'ec_cartitem_quantity_' + cartitem_id ).value = data_split[2];
  1336. if( document.getElementById('ec_cart_subtotal') )
  1337. document.getElementById('ec_cart_subtotal').innerHTML = data_split[3];
  1338. if( document.getElementById('ec_cart_tax') )
  1339. document.getElementById('ec_cart_tax').innerHTML = data_split[4];
  1340. if( document.getElementById('ec_cart_shipping') )
  1341. document.getElementById('ec_cart_shipping').innerHTML = data_split[5];
  1342. if( document.getElementById('ec_cart_duty') )
  1343. document.getElementById('ec_cart_duty').innerHTML = data_split[6];
  1344. if( document.getElementById('ec_cart_vat') )
  1345. document.getElementById('ec_cart_vat').innerHTML = data_split[7];
  1346. if( document.getElementById('ec_cart_discount') )
  1347. document.getElementById('ec_cart_discount').innerHTML = data_split[8];
  1348. if( document.getElementById('ec_cart_grandtotal') )
  1349. document.getElementById('ec_cart_grandtotal').innerHTML = data_split[9];
  1350. }
  1351. }
  1352. function ec_cart_item_delete( cartitem_id ){
  1353. var data = {
  1354. action: 'ec_ajax_cartitem_delete',
  1355. cartitem_id: cartitem_id,
  1356. quantity: document.getElementById( 'ec_cartitem_quantity_' + cartitem_id ).value,
  1357. session_id: document.getElementById( 'ec_cart_session_id' ).value
  1358. }
  1359. ec_cart_item_show_loader( cartitem_id );
  1360. jQuery.ajax({url: ajax_object.ajax_url, type: 'post', data: data, success: function(data){ ec_cart_item_delete_finished( data, cartitem_id ); } } );
  1361. }
  1362. function ec_cart_item_delete_finished( data, cartitem_id ){
  1363. var data_split = data.split("***");
  1364. if( data_split[0] == 0 ){
  1365. document.location = document.getElementById('ec_cart_page').value;
  1366. }else{
  1367. ec_cart_item_hide_loader( cartitem_id );
  1368. if( document.getElementById( 'ec_cart_zip_code' ) ){
  1369. ec_estimate_shipping_click( );
  1370. }
  1371. jQuery('#ec_cart_item_' + cartitem_id ).remove();
  1372. if( document.getElementById( 'ec_cart_final_item_' + cartitem_id ) ){
  1373. jQuery('#ec_cart_final_item_' + cartitem_id ).remove();
  1374. }
  1375. if( document.getElementById('ec_cart_subtotal') )
  1376. document.getElementById('ec_cart_subtotal').innerHTML = data_split[1];
  1377. if( document.getElementById('ec_cart_tax') )
  1378. document.getElementById('ec_cart_tax').innerHTML = data_split[2];
  1379. if( document.getElementById('ec_cart_shipping') )
  1380. document.getElementById('ec_cart_shipping').innerHTML = data_split[3];
  1381. if( document.getElementById('ec_cart_duty') )
  1382. document.getElementById('ec_cart_duty').innerHTML = data_split[4];
  1383. if( document.getElementById('ec_cart_vat') )
  1384. document.getElementById('ec_cart_vat').innerHTML = data_split[5];
  1385. if( document.getElementById('ec_cart_discount') )
  1386. document.getElementById('ec_cart_discount').innerHTML = data_split[6];
  1387. if( document.getElementById('ec_cart_grandtotal') )
  1388. document.getElementById('ec_cart_grandtotal').innerHTML = data_split[7];
  1389. }
  1390. }
  1391. function ec_cart_item_show_loader( cartitem_id ){
  1392. jQuery('#ec_cart_item_loader_' + cartitem_id).fadeIn( 100 );
  1393. }
  1394. function ec_cart_item_hide_loader( cartitem_id ){
  1395. jQuery('#ec_cart_item_loader_' + cartitem_id).fadeOut( 100 );
  1396. }// Base Theme - EC Cart Login Javascript Document// Base Theme - EC Cart Billing Javascript Document
  1397. function ec_cart_billing_validate_input_update( input_name ){
  1398. alert( input_name + " changed" );
  1399. var country_code = document.getElementById('ec_cart_billing_country').value;
  1400. var value = document.getElementById('ec_cart_billing_' + input_name).value;
  1401. // validate billing
  1402. if( !ec_validation( "validate_" + input_name, value, country_code ) ){
  1403. document.getElementById('ec_cart_billing_' + input_name + '_row').className = "ec_cart_billing_row_error";
  1404. }else{
  1405. document.getElementById('ec_cart_billing_' + input_name + '_row').className = "ec_cart_billing_row";
  1406. }
  1407. }
  1408. jQuery( document ).ready( function( ){
  1409. jQuery( '#ec_cart_billing_country' ).change( function( ){
  1410. var country = jQuery( '#ec_cart_billing_country' ).val( );
  1411. if( document.getElementById( 'ec_cart_billing_state_' + country ) ){
  1412. jQuery( '.ec_cart_billing_input_text.ec_billing_state_dropdown' ).hide( );
  1413. jQuery( '#ec_cart_billing_state' ).hide( );
  1414. jQuery( '#ec_cart_billing_state_' + country ).show( );
  1415. }else{
  1416. jQuery( '.ec_cart_billing_input_text.ec_billing_state_dropdown' ).hide( );
  1417. jQuery( '#ec_cart_billing_state' ).show( );
  1418. }
  1419. } );
  1420. } );// Base Theme - EC Cart Shipping Javascript Document
  1421. function ec_cart_use_billing_for_shipping_change(){
  1422. jQuery('.ec_cart_shipping_holder').fadeOut(400);
  1423. }
  1424. function ec_cart_use_shipping_for_shipping_change(){
  1425. jQuery('.ec_cart_shipping_holder').fadeIn(400);
  1426. }
  1427. jQuery( document ).ready( function( ){
  1428. jQuery( '#ec_cart_shipping_country' ).change( function( ){
  1429. var country = jQuery( '#ec_cart_shipping_country' ).val( );
  1430. if( document.getElementById( 'ec_cart_shipping_state_' + country ) ){
  1431. jQuery( '.ec_cart_shipping_input_text.ec_shipping_state_dropdown' ).hide( );
  1432. jQuery( '#ec_cart_shipping_state' ).hide( );
  1433. jQuery( '#ec_cart_shipping_state_' + country ).show( );
  1434. }else{
  1435. jQuery( '.ec_cart_shipping_input_text.ec_shipping_state_dropdown' ).hide( );
  1436. jQuery( '#ec_cart_shipping_state' ).show( );
  1437. }
  1438. } );
  1439. } );// Base Theme - EC Cart Shipping Method Javascript Document
  1440. function ec_cart_shipping_method_change( shipping_method, shipping_price ){
  1441. var data = {
  1442. action: 'ec_ajax_update_shipping_method',
  1443. shipping_method: shipping_method
  1444. };
  1445. jQuery.ajax({url: ajax_object.ajax_url, type: 'post', data: data, success: function(data){ ec_cart_shipping_method_change_finished( data ); } } );
  1446. }
  1447. function ec_cart_shipping_method_change_finished( data ){
  1448. var values = data.split("***");
  1449. if( values.length == 2 ){
  1450. document.getElementById('ec_cart_shipping').innerHTML = values[0];
  1451. document.getElementById('ec_cart_grandtotal').innerHTML = values[1];
  1452. }else{
  1453. document.getElementById('ec_cart_shipping').innerHTML = values[0];
  1454. document.getElementById('ec_cart_grandtotal').innerHTML = values[1];
  1455. document.getElementById('ec_cart_shipping_methods').innerHTML = values[2];
  1456. }
  1457. }
  1458. // Base Theme - EC Cart Coupon Javascript Document
  1459. function ec_cart_coupon_code_redeem( ){
  1460. jQuery('#ec_cart_coupon_loader').fadeIn(100);
  1461. var data = {
  1462. action: 'ec_ajax_redeem_coupon_code',
  1463. couponcode: document.getElementById('ec_cart_coupon_code').value
  1464. };
  1465. jQuery.ajax({url: ajax_object.ajax_url, type: 'post', data: data, success: function(data){ ec_cart_coupon_code_redeem_complete( data ); } } );
  1466. }
  1467. function ec_cart_coupon_code_redeem_complete( data ){
  1468. jQuery('#ec_cart_coupon_loader').fadeOut(100);
  1469. var data_split = data.split("***");
  1470. if( document.getElementById('ec_cart_subtotal') )
  1471. document.getElementById('ec_cart_subtotal').innerHTML = data_split[1];
  1472. if( document.getElementById('ec_cart_tax') )
  1473. document.getElementById('ec_cart_tax').innerHTML = data_split[2];
  1474. if( document.getElementById('ec_cart_shipping') )
  1475. document.getElementById('ec_cart_shipping').innerHTML = data_split[3];
  1476. if( document.getElementById('ec_cart_discount') )
  1477. document.getElementById('ec_cart_discount').innerHTML = data_split[4];
  1478. if( document.getElementById('ec_cart_duty') )
  1479. document.getElementById('ec_cart_duty').innerHTML = data_split[5];
  1480. if( document.getElementById('ec_cart_vat') )
  1481. document.getElementById('ec_cart_vat').innerHTML = data_split[6];
  1482. if( document.getElementById('ec_cart_grandtotal') )
  1483. document.getElementById('ec_cart_grandtotal').innerHTML = data_split[7];
  1484. if( data_split.length > 8 ){
  1485. document.getElementById('ec_cart_coupon_row_message').innerHTML = data_split[8];
  1486. }else{
  1487. document.getElementById('ec_cart_coupon_row_message').innerHTML = "";
  1488. }
  1489. }
  1490. // Base Theme - EC Cart Gift Card Javascript Document
  1491. function ec_cart_gift_card_redeem( ){
  1492. jQuery('#ec_cart_gift_card_loader').fadeIn(100);
  1493. var data = {
  1494. action: 'ec_ajax_redeem_gift_card',
  1495. giftcard: document.getElementById('ec_cart_gift_card').value
  1496. };
  1497. jQuery.ajax({url: ajax_object.ajax_url, type: 'post', data: data, success: function(data){ ec_cart_gift_card_redeem_complete( data ); } } );
  1498. }
  1499. function ec_cart_gift_card_redeem_complete( data ){
  1500. jQuery('#ec_cart_gift_card_loader').fadeOut(100);
  1501. var data_split = data.split("***");
  1502. if( document.getElementById('ec_cart_subtotal') )
  1503. document.getElementById('ec_cart_subtotal').innerHTML = data_split[1];
  1504. if( document.getElementById('ec_cart_tax') )
  1505. document.getElementById('ec_cart_tax').innerHTML = data_split[2];
  1506. if( document.getElementById('ec_cart_shipping') )
  1507. document.getElementById('ec_cart_shipping').innerHTML = data_split[3];
  1508. if( document.getElementById('ec_cart_discount') )
  1509. document.getElementById('ec_cart_discount').innerHTML = data_split[4];
  1510. if( document.getElementById('ec_cart_duty') )
  1511. document.getElementById('ec_cart_duty').innerHTML = data_split[5];
  1512. if( document.getElementById('ec_cart_vat') )
  1513. document.getElementById('ec_cart_vat').innerHTML = data_split[6];
  1514. if( document.getElementById('ec_cart_grandtotal') )
  1515. document.getElementById('ec_cart_grandtotal').innerHTML = data_split[7];
  1516. if( data_split.length > 8 ){
  1517. document.getElementById('ec_cart_gift_card_row_message').innerHTML = data_split[8];
  1518. }else{
  1519. document.getElementById('ec_cart_gift_card_row_message').innerHTML = "";
  1520. }
  1521. }
  1522. // Base Theme - EC Cart Payment Information Javascript Document
  1523. function ec_cart_update_payment_type( payment_type ){
  1524. jQuery('#ec_cart_pay_by_manual_payment').hide();
  1525. jQuery('#ec_cart_pay_by_third_party').hide();
  1526. jQuery('#ec_cart_pay_by_credit_card_holder').hide();
  1527. if( payment_type == "manual_bill" )
  1528. jQuery('#ec_cart_pay_by_manual_payment').show();
  1529. else if( payment_type == "third_party" )
  1530. jQuery('#ec_cart_pay_by_third_party').show();
  1531. else if( payment_type == "credit_card" )
  1532. jQuery('#ec_cart_pay_by_credit_card_holder').show();
  1533. }// Base Theme - EC Cart Contact Information Javascript Document
  1534. function ec_contact_create_account_change( ){
  1535. if( document.getElementById('ec_contact_create_account').checked == true )
  1536. jQuery( '#ec_cart_password_input').fadeIn(150);
  1537. else
  1538. jQuery( '#ec_cart_password_input').fadeOut(150);
  1539. }// Base Theme - EC Cart Submit Order Javascript Document
  1540. function ec_cart_submit_order_click(){
  1541. var has_errors = false;
  1542. if( !ec_cart_payment_method_check( ) ) has_errors = true;
  1543. if( !ec_cart_card_holder_name_check( ) ) has_errors = true;
  1544. if( !ec_cart_card_number_check( ) ) has_errors = true;
  1545. if( !ec_cart_expiration_month_check( ) ) has_errors = true;
  1546. if( !ec_cart_expiration_year_check( ) ) has_errors = true;
  1547. if( !ec_cart_security_code_check( ) ) has_errors = true;
  1548. if( !ec_cart_email_check( ) ) has_errors = true;
  1549. if( !ec_cart_email_retype_check( ) ) has_errors = true;
  1550. return !has_errors;
  1551. }
  1552. function ec_cart_payment_method_check( ){
  1553. if( document.getElementById('ec_payment_type').value != 0 ){
  1554. ec_text_field_highlight_error_remove( document.getElementById('ec_payment_type') );
  1555. return true;
  1556. }else{
  1557. ec_text_field_highlight_error( document.getElementById('ec_payment_type') );
  1558. return false;
  1559. }
  1560. }
  1561. function ec_cart_card_holder_name_check( ){
  1562. if( document.getElementById('ec_card_holder_name').value.length > 0 ){
  1563. ec_text_field_highlight_error_remove( document.getElementById('ec_card_holder_name') );
  1564. return true;
  1565. }else{
  1566. ec_text_field_highlight_error( document.getElementById('ec_card_holder_name') );
  1567. return false;
  1568. }
  1569. }
  1570. function ec_cart_card_number_check( ){
  1571. if( document.getElementById('ec_card_number').value.length > 0 ){
  1572. ec_text_field_highlight_error_remove( document.getElementById('ec_card_number') );
  1573. return true;
  1574. }else{
  1575. ec_text_field_highlight_error( document.getElementById('ec_card_number') );
  1576. return false;
  1577. }
  1578. }
  1579. function ec_cart_expiration_month_check( ){
  1580. if( document.getElementById('ec_expiration_month').value != 0 ){
  1581. ec_text_field_highlight_error_remove( document.getElementById('ec_expiration_month') );
  1582. return true;
  1583. }else{
  1584. ec_text_field_highlight_error( document.getElementById('ec_expiration_month') );
  1585. return false;
  1586. }
  1587. }
  1588. function ec_cart_expiration_year_check( ){
  1589. if( document.getElementById('ec_expiration_year').value != 0 ){
  1590. ec_text_field_highlight_error_remove( document.getElementById('ec_expiration_year') );
  1591. return true;
  1592. }else{
  1593. ec_text_field_highlight_error( document.getElementById('ec_expiration_year') );
  1594. return false;
  1595. }
  1596. }
  1597. function ec_cart_security_code_check( ){
  1598. if( document.getElementById('ec_security_code').value.length > 0 ){
  1599. ec_text_field_highlight_error_remove( document.getElementById('ec_security_code') );
  1600. return true;
  1601. }else{
  1602. ec_text_field_highlight_error( document.getElementById('ec_security_code') );
  1603. return false;
  1604. }
  1605. }
  1606. function ec_cart_email_check( ){
  1607. if( document.getElementById('ec_contact_email').value.length > 0 ){
  1608. ec_text_field_highlight_error_remove( document.getElementById('ec_contact_email') );
  1609. return true;
  1610. }else{
  1611. ec_text_field_highlight_error( document.getElementById('ec_contact_email') );
  1612. return false;
  1613. }
  1614. }
  1615. function ec_cart_email_retype_check( ){
  1616. if( document.getElementById('ec_contact_email_retype').value.length > 0 && document.getElementById('ec_contact_email').value.length == document.getElementById('ec_contact_email_retype').value.length ){
  1617. ec_text_field_highlight_error_remove( document.getElementById('ec_contact_email_retype') );
  1618. return true;
  1619. }else{
  1620. ec_text_field_highlight_error( document.getElementById('ec_contact_email_retype') );
  1621. return false;
  1622. }
  1623. }
  1624. function ec_text_field_highlight_error( field ){
  1625. field.style.backgroundColor = 'Yellow';
  1626. }
  1627. function ec_text_field_highlight_error_remove( field ){
  1628. field.style.backgroundColor = 'White';
  1629. }
  1630. // JavaScript Document// JavaScript Document// Base Theme - EC Cart Third Party Javascript Document////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1631. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1632. //All Code and Design is copyrighted by Level Four Development, llc
  1633. //
  1634. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  1635. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  1636. //
  1637. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  1638. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  1639. //contact Level Four Development, llc and EasyCart prior to use.
  1640. //
  1641. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  1642. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1643. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1644. // Base Theme - EC Account Billing Information Javascript Document
  1645. function ec_account_billing_information_update_click( ){
  1646. var errors = 0;
  1647. var country = document.getElementById('ec_account_billing_information_country').value;
  1648. var first_name = document.getElementById('ec_account_billing_information_first_name').value;
  1649. var last_name = document.getElementById('ec_account_billing_information_last_name').value;
  1650. var address = document.getElementById('ec_account_billing_information_address').value;
  1651. var city = document.getElementById('ec_account_billing_information_city').value;
  1652. var state = document.getElementById('ec_account_billing_information_state').value;
  1653. // Check for special drop down
  1654. if( document.getElementById( 'ec_account_billing_information_state_' + country ) && document.getElementById( 'ec_account_billing_information_state_' + country ).options ){
  1655. state = document.getElementById( 'ec_account_billing_information_state_' + country ).options[document.getElementById( 'ec_account_billing_information_state_' + country ).selectedIndex].value;
  1656. }
  1657. var zip = document.getElementById('ec_account_billing_information_zip').value;
  1658. var phone = document.getElementById('ec_account_billing_information_phone').value;
  1659. if( !ec_validation( "validate_first_name", first_name, country ) ){
  1660. errors++;
  1661. document.getElementById('ec_account_billing_information_first_name_row').className = "ec_account_billing_information_row_error";
  1662. }else{
  1663. document.getElementById('ec_account_billing_information_first_name_row').className = "ec_account_billing_information_row";
  1664. }
  1665. if( !ec_validation( "validate_last_name", last_name, country ) ){
  1666. errors++;
  1667. document.getElementById('ec_account_billing_information_last_name_row').className = "ec_account_billing_information_row_error";
  1668. }else{
  1669. document.getElementById('ec_account_billing_information_last_name_row').className = "ec_account_billing_information_row";
  1670. }
  1671. if( !ec_validation( "validate_address", address, country ) ){
  1672. errors++;
  1673. document.getElementById('ec_account_billing_information_address_row').className = "ec_account_billing_information_row_error";
  1674. }else{
  1675. document.getElementById('ec_account_billing_information_address_row').className = "ec_account_billing_information_row";
  1676. }
  1677. if( !ec_validation( "validate_city", city, country ) ){
  1678. errors++;
  1679. document.getElementById('ec_account_billing_information_city_row').className = "ec_account_billing_information_row_error";
  1680. }else{
  1681. document.getElementById('ec_account_billing_information_city_row').className = "ec_account_billing_information_row";
  1682. }
  1683. if( !ec_validation( "validate_state", state, country ) ){
  1684. errors++;
  1685. document.getElementById('ec_account_billing_information_state_row').className = "ec_account_billing_information_row_error";
  1686. }else{
  1687. document.getElementById('ec_account_billing_information_state_row').className = "ec_account_billing_information_row";
  1688. }
  1689. if( !ec_validation( "validate_zip", zip, country ) ){
  1690. errors++;
  1691. document.getElementById('ec_account_billing_information_zip_row').className = "ec_account_billing_information_row_error";
  1692. }else{
  1693. document.getElementById('ec_account_billing_information_zip_row').className = "ec_account_billing_information_row";
  1694. }
  1695. if( !ec_validation( "validate_country", country, country ) ){
  1696. errors++;
  1697. document.getElementById('ec_account_billing_information_country_row').className = "ec_account_billing_information_row_error";
  1698. }else{
  1699. document.getElementById('ec_account_billing_information_country_row').className = "ec_account_billing_information_row";
  1700. }
  1701. if( !ec_validation( "validate_phone", phone, country ) ){
  1702. errors++;
  1703. document.getElementById('ec_account_billing_information_phone_row').className = "ec_account_billing_information_row_error";
  1704. }else{
  1705. document.getElementById('ec_account_billing_information_phone_row').className = "ec_account_billing_information_row";
  1706. }
  1707. if( errors > 0 )
  1708. return false;
  1709. else
  1710. return true;
  1711. }
  1712. jQuery( document ).ready( function( ){
  1713. jQuery( '#ec_account_billing_information_country' ).change( function( ){
  1714. var country = jQuery( '#ec_account_billing_information_country' ).val( );
  1715. if( document.getElementById( 'ec_account_billing_information_state_' + country ) ){
  1716. jQuery( '.ec_account_billing_information_input_field.ec_billing_state_dropdown' ).hide( );
  1717. jQuery( '#ec_account_billing_information_state' ).hide( );
  1718. jQuery( '#ec_account_billing_information_state_' + country ).show( );
  1719. }else{
  1720. jQuery( '.ec_account_billing_information_input_field.ec_billing_state_dropdown' ).hide( );
  1721. jQuery( '#ec_account_billing_information_state' ).show( );
  1722. }
  1723. } );
  1724. } );
  1725. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1726. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1727. //All Code and Design is copyrighted by Level Four Development, llc
  1728. //
  1729. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  1730. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  1731. //
  1732. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  1733. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  1734. //contact Level Four Development, llc and EasyCart prior to use.
  1735. //
  1736. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  1737. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1738. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1739. // Base Theme - EC Account Dashboard Javascript Document
  1740. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1741. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1742. //All Code and Design is copyrighted by Level Four Development, llc
  1743. //
  1744. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  1745. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  1746. //
  1747. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  1748. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  1749. //contact Level Four Development, llc and EasyCart prior to use.
  1750. //
  1751. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  1752. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1753. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1754. // Base Theme - EC Account Login Javascript Document
  1755. function ec_account_login_button_click( ){
  1756. var errors = 0;
  1757. var email = document.getElementById( 'ec_account_login_email' ).value;
  1758. var password = document.getElementById( 'ec_account_login_password' ).value;
  1759. if( !ec_validation( "validate_email", email, "US" ) ){
  1760. errors++;
  1761. document.getElementById('ec_account_login_email_row').className = "ec_account_login_row_error";
  1762. }else{
  1763. document.getElementById('ec_account_login_email_row').className = "ec_account_login_row";
  1764. }
  1765. if( !ec_validation( "validate_password", password, "US" ) ){
  1766. errors++;
  1767. document.getElementById('ec_account_login_password_row').className = "ec_account_login_row_error";
  1768. }else{
  1769. document.getElementById('ec_account_login_password_row').className = "ec_account_login_row";
  1770. }
  1771. if( errors > 0 )
  1772. return false;
  1773. else
  1774. return true;
  1775. }////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1776. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1777. //All Code and Design is copyrighted by Level Four Development, llc
  1778. //
  1779. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  1780. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  1781. //
  1782. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  1783. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  1784. //contact Level Four Development, llc and EasyCart prior to use.
  1785. //
  1786. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  1787. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1788. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1789. // Base Theme - EC Account Order Details Javascript Document/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1790. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1791. //All Code and Design is copyrighted by Level Four Development, llc
  1792. //
  1793. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  1794. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  1795. //
  1796. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  1797. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  1798. //contact Level Four Development, llc and EasyCart prior to use.
  1799. //
  1800. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  1801. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1802. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1803. // Base Theme - EC Account Orders Javascript Document
  1804. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1805. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1806. //All Code and Design is copyrighted by Level Four Development, llc
  1807. //
  1808. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  1809. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  1810. //
  1811. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  1812. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  1813. //contact Level Four Development, llc and EasyCart prior to use.
  1814. //
  1815. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  1816. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1817. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1818. // Base Theme - EC Account Page Javascript Document////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1819. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1820. //All Code and Design is copyrighted by Level Four Development, llc
  1821. //
  1822. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  1823. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  1824. //
  1825. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  1826. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  1827. //contact Level Four Development, llc and EasyCart prior to use.
  1828. //
  1829. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  1830. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1831. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1832. // Base Theme - EC Account Password Javascript Document
  1833. function ec_account_password_button_click( ){
  1834. var errors = 0;
  1835. var password = document.getElementById('ec_account_password_current_password').value;
  1836. var new_password = document.getElementById('ec_account_password_new_password').value;
  1837. var retype_new_password = document.getElementById('ec_account_password_retype_new_password').value;
  1838. if( !ec_validation( "validate_password", password, "US" ) ){
  1839. errors++;
  1840. document.getElementById('ec_account_password_current_password_row').className = "ec_account_password_row_error";
  1841. }else{
  1842. document.getElementById('ec_account_password_current_password_row').className = "ec_account_password_row";
  1843. }
  1844. if( !ec_validation( "validate_password", new_password, "US" ) ){
  1845. errors++;
  1846. document.getElementById('ec_account_password_new_password_row').className = "ec_account_password_row_error";
  1847. }else{
  1848. document.getElementById('ec_account_password_new_password_row').className = "ec_account_password_row";
  1849. }
  1850. if( retype_new_password != new_password ){
  1851. errors++;
  1852. document.getElementById('ec_account_password_retype_new_password_row').className = "ec_account_password_row_error";
  1853. }else{
  1854. document.getElementById('ec_account_password_retype_new_password_row').className = "ec_account_password_row";
  1855. }
  1856. if( errors > 0 )
  1857. return false;
  1858. else
  1859. return true;
  1860. }////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1861. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1862. //All Code and Design is copyrighted by Level Four Development, llc
  1863. //
  1864. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  1865. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  1866. //
  1867. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  1868. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  1869. //contact Level Four Development, llc and EasyCart prior to use.
  1870. //
  1871. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  1872. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1873. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1874. // Base Theme - EC Account Personal Information Javascript Document
  1875. function ec_account_personal_information_update_click( ){
  1876. var errors = 0;
  1877. var first_name = document.getElementById('ec_account_personal_information_first_name').value;
  1878. var last_name = document.getElementById('ec_account_personal_information_last_name').value;
  1879. var email = document.getElementById('ec_account_personal_information_email').value;
  1880. if( !ec_validation( "validate_first_name", first_name, "US" ) ){
  1881. errors++;
  1882. document.getElementById('ec_account_personal_information_first_name_row').className = "ec_account_personal_information_row_error";
  1883. }else{
  1884. document.getElementById('ec_account_personal_information_first_name_row').className = "ec_account_personal_information_row";
  1885. }
  1886. if( !ec_validation( "validate_last_name", last_name, "US" ) ){
  1887. errors++;
  1888. document.getElementById('ec_account_personal_information_last_name_row').className = "ec_account_personal_information_row_error";
  1889. }else{
  1890. document.getElementById('ec_account_personal_information_last_name_row').className = "ec_account_personal_information_row";
  1891. }
  1892. if( !ec_validation( "validate_email", email, "US" ) ){
  1893. errors++;
  1894. document.getElementById('ec_account_personal_information_email_row').className = "ec_account_personal_information_row_error";
  1895. }else{
  1896. document.getElementById('ec_account_personal_information_email_row').className = "ec_account_personal_information_row";
  1897. }
  1898. if( errors > 0 )
  1899. return false;
  1900. else
  1901. return true;
  1902. }
  1903. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1904. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1905. //All Code and Design is copyrighted by Level Four Development, llc
  1906. //
  1907. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  1908. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  1909. //
  1910. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  1911. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  1912. //contact Level Four Development, llc and EasyCart prior to use.
  1913. //
  1914. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  1915. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1916. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1917. // Base Theme - EC Account Shipping Information Javascript Document
  1918. function ec_account_shipping_information_update_click( ){
  1919. var errors = 0;
  1920. var country = document.getElementById('ec_account_shipping_information_country').value;
  1921. var first_name = document.getElementById('ec_account_shipping_information_first_name').value;
  1922. var last_name = document.getElementById('ec_account_shipping_information_last_name').value;
  1923. var address = document.getElementById('ec_account_shipping_information_address').value;
  1924. var city = document.getElementById('ec_account_shipping_information_city').value;
  1925. var state = document.getElementById('ec_account_shipping_information_state').value;
  1926. // Check for special drop down
  1927. if( document.getElementById( 'ec_account_shipping_information_state_' + country ) && document.getElementById( 'ec_account_shipping_information_state_' + country ).options ){
  1928. state = document.getElementById( 'ec_account_shipping_information_state_' + country ).options[document.getElementById( 'ec_account_shipping_information_state_' + country ).selectedIndex].value;
  1929. }
  1930. var zip = document.getElementById('ec_account_shipping_information_zip').value;
  1931. var phone = document.getElementById('ec_account_shipping_information_phone').value;
  1932. if( !ec_validation( "validate_first_name", first_name, country ) ){
  1933. errors++;
  1934. document.getElementById('ec_account_shipping_information_first_name_row').className = "ec_account_shipping_information_row_error";
  1935. }else{
  1936. document.getElementById('ec_account_shipping_information_first_name_row').className = "ec_account_shipping_information_row";
  1937. }
  1938. if( !ec_validation( "validate_last_name", last_name, country ) ){
  1939. errors++;
  1940. document.getElementById('ec_account_shipping_information_last_name_row').className = "ec_account_shipping_information_row_error";
  1941. }else{
  1942. document.getElementById('ec_account_shipping_information_last_name_row').className = "ec_account_shipping_information_row";
  1943. }
  1944. if( !ec_validation( "validate_address", address, country ) ){
  1945. errors++;
  1946. document.getElementById('ec_account_shipping_information_address_row').className = "ec_account_shipping_information_row_error";
  1947. }else{
  1948. document.getElementById('ec_account_shipping_information_address_row').className = "ec_account_shipping_information_row";
  1949. }
  1950. if( !ec_validation( "validate_city", city, country ) ){
  1951. errors++;
  1952. document.getElementById('ec_account_shipping_information_city_row').className = "ec_account_shipping_information_row_error";
  1953. }else{
  1954. document.getElementById('ec_account_shipping_information_city_row').className = "ec_account_shipping_information_row";
  1955. }
  1956. if( !ec_validation( "validate_state", state, country ) ){
  1957. errors++;
  1958. document.getElementById('ec_account_shipping_information_state_row').className = "ec_account_shipping_information_row_error";
  1959. }else{
  1960. document.getElementById('ec_account_shipping_information_state_row').className = "ec_account_shipping_information_row";
  1961. }
  1962. if( !ec_validation( "validate_zip", zip, country ) ){
  1963. errors++;
  1964. document.getElementById('ec_account_shipping_information_zip_row').className = "ec_account_shipping_information_row_error";
  1965. }else{
  1966. document.getElementById('ec_account_shipping_information_zip_row').className = "ec_account_shipping_information_row";
  1967. }
  1968. if( !ec_validation( "validate_country", country, country ) ){
  1969. errors++;
  1970. document.getElementById('ec_account_shipping_information_country_row').className = "ec_account_shipping_information_row_error";
  1971. }else{
  1972. document.getElementById('ec_account_shipping_information_country_row').className = "ec_account_shipping_information_row";
  1973. }
  1974. if( !ec_validation( "validate_phone", phone, country ) ){
  1975. errors++;
  1976. document.getElementById('ec_account_shipping_information_phone_row').className = "ec_account_shipping_information_row_error";
  1977. }else{
  1978. document.getElementById('ec_account_shipping_information_phone_row').className = "ec_account_shipping_information_row";
  1979. }
  1980. if( errors > 0 )
  1981. return false;
  1982. else
  1983. return true;
  1984. }
  1985. jQuery( document ).ready( function( ){
  1986. jQuery( '#ec_account_shipping_information_country' ).change( function( ){
  1987. var country = jQuery( '#ec_account_shipping_information_country' ).val( );
  1988. if( document.getElementById( 'ec_account_shipping_information_state_' + country ) ){
  1989. jQuery( '.ec_account_shipping_information_input_field.ec_shipping_state_dropdown' ).hide( );
  1990. jQuery( '#ec_account_shipping_information_state' ).hide( );
  1991. jQuery( '#ec_account_shipping_information_state_' + country ).show( );
  1992. }else{
  1993. jQuery( '.ec_account_shipping_information_input_field.ec_shipping_state_dropdown' ).hide( );
  1994. jQuery( '#ec_account_shipping_information_state' ).show( );
  1995. }
  1996. } );
  1997. } );
  1998. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1999. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2000. //All Code and Design is copyrighted by Level Four Development, llc
  2001. //
  2002. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  2003. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  2004. //
  2005. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  2006. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  2007. //contact Level Four Development, llc and EasyCart prior to use.
  2008. //
  2009. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  2010. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2011. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2012. // Base Theme - EC Account Forgot Password Javascript Document
  2013. function ec_account_forgot_password_button_click( ){
  2014. var errors = 0;
  2015. var email = document.getElementById( 'ec_account_forgot_password_email' ).value;
  2016. if( !ec_validation( "validate_email", email, "US" ) ){
  2017. errors++;
  2018. document.getElementById('ec_account_forgot_password_email_row').className = "ec_account_forgot_password_row_error";
  2019. }else{
  2020. document.getElementById('ec_account_forgot_password_email_row').className = "ec_account_forgot_password_row";
  2021. }
  2022. if( errors > 0 )
  2023. return false;
  2024. else
  2025. return true;
  2026. }
  2027. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2028. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2029. //All Code and Design is copyrighted by Level Four Development, llc
  2030. //
  2031. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  2032. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  2033. //
  2034. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  2035. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  2036. //contact Level Four Development, llc and EasyCart prior to use.
  2037. //
  2038. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  2039. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2040. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2041. // Base Theme - EC Account Register Javascript Document
  2042. function ec_account_register_button_click( ){
  2043. var errors = 0;
  2044. var first_name = document.getElementById('ec_account_register_first_name').value;
  2045. var last_name = document.getElementById('ec_account_register_last_name').value;
  2046. var email = document.getElementById('ec_account_register_email').value;
  2047. var password = document.getElementById('ec_account_register_password').value;
  2048. var retype_password = document.getElementById('ec_account_register_password_retype').value;
  2049. if( !ec_validation( "validate_first_name", first_name, "US" ) ){
  2050. errors++;
  2051. document.getElementById('ec_account_register_first_name_row').className = "ec_account_register_row_error";
  2052. }else{
  2053. document.getElementById('ec_account_register_first_name_row').className = "ec_account_register_row";
  2054. }
  2055. if( !ec_validation( "validate_last_name", last_name, "US" ) ){
  2056. errors++;
  2057. document.getElementById('ec_account_register_last_name_row').className = "ec_account_register_row_error";
  2058. }else{
  2059. document.getElementById('ec_account_register_last_name_row').className = "ec_account_register_row";
  2060. }
  2061. if( !ec_validation( "validate_email", email, "US" ) ){
  2062. errors++;
  2063. document.getElementById('ec_account_register_email_row').className = "ec_account_register_row_error";
  2064. }else{
  2065. document.getElementById('ec_account_register_email_row').className = "ec_account_register_row";
  2066. }
  2067. if( !ec_validation( "validate_password", password, "US" ) ){
  2068. errors++;
  2069. document.getElementById('ec_account_register_password_row').className = "ec_account_register_row_error";
  2070. document.getElementById('ec_account_register_password_retype_row').className = "ec_account_register_row_error";
  2071. }else{
  2072. document.getElementById('ec_account_register_password_row').className = "ec_account_register_row";
  2073. }
  2074. if( !ec_validation( "validate_password", password, "US" ) || password != retype_password ){
  2075. errors++;
  2076. document.getElementById('ec_account_register_password_retype_row').className = "ec_account_register_row_error";
  2077. }else{
  2078. document.getElementById('ec_account_register_password_retype_row').className = "ec_account_register_row";
  2079. }
  2080. if( errors > 0 )
  2081. return false;
  2082. else
  2083. return true;
  2084. }
  2085. function ec_account_register_button_click2( ){
  2086. var top_half = ec_account_register_button_click( );
  2087. var bottom_half = ec_account_billing_information_update_click( );
  2088. if( top_half && bottom_half ){
  2089. return true;
  2090. }else{
  2091. return false;
  2092. }
  2093. }////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2094. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2095. //All Code and Design is copyrighted by Level Four Development, llc
  2096. //
  2097. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  2098. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  2099. //
  2100. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  2101. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  2102. //contact Level Four Development, llc and EasyCart prior to use.
  2103. //
  2104. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  2105. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2106. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2107. // Base Theme - Account Order Line Javascript Document
  2108. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2109. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2110. //All Code and Design is copyrighted by Level Four Development, llc
  2111. //
  2112. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  2113. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  2114. //
  2115. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  2116. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  2117. //contact Level Four Development, llc and EasyCart prior to use.
  2118. //
  2119. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  2120. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2121. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2122. // Base Theme - EC Account Order Details Item Display Javascript Document
  2123. function update_download_count( orderdetail_id ){
  2124. if( document.getElementById( 'ec_download_count_' + orderdetail_id ) ){
  2125. var count = Number(document.getElementById( 'ec_download_count_' + orderdetail_id ).innerHTML);
  2126. var max_count = Number(document.getElementById( 'ec_download_count_max_' + orderdetail_id ).innerHTML);
  2127. if( count < max_count ){
  2128. count++;
  2129. document.getElementById( 'ec_download_count_' + orderdetail_id ).innerHTML = count;
  2130. }
  2131. }
  2132. }////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2133. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2134. //All Code and Design is copyrighted by Level Four Development, llc
  2135. //
  2136. //Level Four Development, LLC provides this code "as is" without warranty of any kind, either express or implied,
  2137. //including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
  2138. //
  2139. //Only licnesed users may use this code and storfront for live purposes. All other use is prohibited and may be
  2140. //subject to copyright violation laws. If you have any questions regarding proper use of this code, please
  2141. //contact Level Four Development, llc and EasyCart prior to use.
  2142. //
  2143. //All use of this storefront is subject to our terms of agreement found on Level Four Development, llc's website.
  2144. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2145. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2146. // Base Theme - Account Order Line Javascript Document
  2147. function show_billing_info( ){
  2148. jQuery( '#ec_account_subscription_billing_information' ).fadeIn( );
  2149. jQuery( '#ec_account_subscription_payment' ).fadeIn( );
  2150. return false;
  2151. }
  2152. function ec_cancel_subscription_check( confirm_text ){
  2153. return confirm( confirm_text );
  2154. }// JavaScript Document
  2155. jQuery(document).ready(function() {
  2156. var hasTouch = ("ontouchstart" in window);
  2157. if( hasTouch ){
  2158. var elements = jQuery( ".has-submenu" );
  2159. for( var i=0; i<elements.length; i++){
  2160. elements[i].addEventListener( "click", ec_horizontal_click, false);
  2161. }
  2162. }
  2163. function ec_horizontal_click( e ) {
  2164. e.preventDefault();
  2165. }
  2166. });
  2167. jQuery(document).ready(function() {
  2168. jQuery(".ec_menu_vertical").accordion({
  2169. accordion:true,
  2170. speed: 500,
  2171. closedSign: '[+]',
  2172. openedSign: '[-]'
  2173. });
  2174. });
  2175. (function(jQuery){
  2176. jQuery.fn.extend({
  2177. accordion: function(options) {
  2178. var defaults = {
  2179. accordion: 'true',
  2180. speed: 300,
  2181. closedSign: '[+]',
  2182. openedSign: '[-]'
  2183. };
  2184. var opts = jQuery.extend(defaults, options);
  2185. var jQuerythis = jQuery(this);
  2186. jQuerythis.find("li").each(function() {
  2187. if(jQuery(this).find("ul").size() != 0){
  2188. jQuery(this).find("a:first").append("<span>"+ opts.closedSign +"</span>");
  2189. if(jQuery(this).find("a:first").attr('href') == "#"){
  2190. jQuery(this).find("a:first").click(function(){return false;});
  2191. }
  2192. }
  2193. });
  2194. jQuerythis.find("li.active").each(function() {
  2195. jQuery(this).parents("ul").slideDown(opts.speed);
  2196. jQuery(this).parents("ul").parent("li").find("span:first").html(opts.openedSign);
  2197. });
  2198. jQuerythis.find("li a").click(function() {
  2199. if(jQuery(this).parent().find("ul").size() != 0){
  2200. if(opts.accordion){
  2201. if(!jQuery(this).parent().find("ul").is(':visible')){
  2202. parents = jQuery(this).parent().parents("ul");
  2203. visible = jQuerythis.find("ul:visible");
  2204. visible.each(function(visibleIndex){
  2205. var close = true;
  2206. parents.each(function(parentIndex){
  2207. if(parents[parentIndex] == visible[visibleIndex]){
  2208. close = false;
  2209. return false;
  2210. }
  2211. });
  2212. if(close){
  2213. if(jQuery(this).parent().find("ul") != visible[visibleIndex]){
  2214. jQuery(visible[visibleIndex]).slideUp(opts.speed, function(){
  2215. jQuery(this).parent("li").find("span:first").html(opts.closedSign);
  2216. });
  2217. }
  2218. }
  2219. });
  2220. }
  2221. }
  2222. if(jQuery(this).parent().find("ul:first").is(":visible")){
  2223. jQuery(this).parent().find("ul:first").slideUp(opts.speed, function(){
  2224. jQuery(this).parent("li").find("span:first").delay(opts.speed).html(opts.closedSign);
  2225. });
  2226. }else{
  2227. jQuery(this).parent().find("ul:first").slideDown(opts.speed, function(){
  2228. jQuery(this).parent("li").find("span:first").delay(opts.speed).html(opts.openedSign);
  2229. });
  2230. }
  2231. }
  2232. });
  2233. }
  2234. });
  2235. })(jQuery);
  2236. function ec_cart_widget_click( ){
  2237. if( !jQuery('.ec_cart_widget_minicart_wrap').is(':visible') )
  2238. jQuery('.ec_cart_widget_minicart_wrap').fadeIn( 200 );
  2239. else
  2240. jQuery('.ec_cart_widget_minicart_wrap').fadeOut( 100 );
  2241. }
  2242. function ec_cart_widget_mouseover( ){
  2243. if( !jQuery('.ec_cart_widget_minicart_wrap').is(':visible') ){
  2244. jQuery('.ec_cart_widget_minicart_wrap').fadeIn( 200 );
  2245. jQuery('.ec_cart_widget_minicart_bg').css( "display", "block" );
  2246. }
  2247. }
  2248. function ec_cart_widget_mouseout( ){
  2249. if( jQuery('.ec_cart_widget_minicart_wrap').is(':visible') ) {
  2250. jQuery('.ec_cart_widget_minicart_wrap').fadeOut( 100 );
  2251. jQuery('.ec_cart_widget_minicart_bg').css( "display", "none" );
  2252. }
  2253. }
  2254. function ec_validation( function_name, input, country_code ){
  2255. if( function_name == "validate_first_name" ){
  2256. if( input.length > 0)
  2257. return true;
  2258. else
  2259. return false;
  2260. }else if( function_name == "validate_last_name" ){
  2261. if( input.length > 0)
  2262. return true;
  2263. else
  2264. return false;
  2265. }else if( function_name == "validate_address" ){
  2266. if( country_code == "US" ){
  2267. if( input.length > 0 )
  2268. return true;
  2269. else
  2270. return false;
  2271. }else{
  2272. if( input.length > 0)
  2273. return true;
  2274. else
  2275. return false;
  2276. }
  2277. }else if( function_name == "validate_city" ){
  2278. if( country_code == "US" ){
  2279. if( input.length > 0 )
  2280. return true;
  2281. else
  2282. return false;
  2283. }else{
  2284. if( input.length > 0)
  2285. return true;
  2286. else
  2287. return false;
  2288. }
  2289. }else if( function_name == "validate_state" ){
  2290. var us_states = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY', 'AS', 'GU', 'MP', 'PR', 'VI', 'UM', 'ALABAMA', 'ALASKA', 'ARIZONA', 'ARKANSAS', 'CALIFORNIA', 'COLORADO', 'CONNECTICUT', 'DELAWARE', 'DISTRICT OF COLUMBIA', 'D.C.', 'FLORIDA', 'GEORGIA', 'HAWAII', 'IDAHO', 'ILLINOIS', 'INDIANA', 'IOWA', 'KANSAS', 'KENTUCKY', 'LOUISIANA', 'MAINE', 'MARYLAND', 'MASSACHUSETTS', 'MICHIGAN', 'MINNESOTA', 'MISSISSIPPI', 'MISSOURI', 'MONTANA', 'NEBRASKA', 'NEVADA', 'NEW HAMPSHIRE', 'NEW JERSEY', 'NEW MEXICO', 'NEW YORK', 'NORTH CAROLINA', 'NORTH DAKOTA', 'OHIO', 'OKLAHOMA', 'OREGON', 'PENNSYLVANIA', 'RHODE ISLAND', 'SOUTH CAROLINA', 'SOUTH DAKOTA', 'TENNESSEE', 'TEXAS', 'UTAH', 'VERMONT', 'VIRGINIA', 'WASHINGTON', 'WEST VIRGINIA', 'WISCONSIN', 'WYOMING', 'AMERICAN SAMOA', 'GUAM', 'NORTH MARINANA ISLANDS', 'PUERTO RICO', 'VIRGIN ISLANDS']
  2291. input = input.toUpperCase();
  2292. if( country_code == "US" ){
  2293. if( jQuery.inArray( input, us_states ) != -1 )
  2294. return true;
  2295. else
  2296. return false;
  2297. }else{
  2298. return true;
  2299. }
  2300. }else if( function_name == "validate_zip" ){
  2301. var no_zip_countries = ['AO', 'AG', 'AW', 'BS', 'BZ', 'BJ', 'BW', 'BF', 'BI', 'KM', 'CG', 'CK', 'CI', 'DJ', 'DM', 'TP', 'GQ', 'ER', 'FJ', 'GM', 'GH', 'GD', 'GN', 'GY', 'HK', 'IE', 'KI', 'MO', 'MW', 'ML', 'MR', 'MU', 'MS', 'NA', 'NR', 'NU', 'PA', 'QA', 'RW', 'KN', 'LC', 'ST', 'SC', 'SL', 'SB', 'SO', 'SR', 'SY', 'TK', 'TO', 'TT', 'TV', 'UG', 'AE', 'VU', 'YE', 'ZW'];
  2302. if( country_code == "US" ){
  2303. if( /(^\d{5}$)|(^\d{5}-\d{4}$)/.test( input ) )
  2304. return true;
  2305. else
  2306. return false;
  2307. }else if( jQuery.inArray( country_code, no_zip_countries ) ){
  2308. return true;
  2309. }else{
  2310. if( input.length > 0 )
  2311. return true;
  2312. else
  2313. return false;
  2314. }
  2315. }else if( function_name == "validate_country" ){
  2316. if( input != 0 && input.length > 0)
  2317. return true;
  2318. else
  2319. return false;
  2320. }else if( function_name == "validate_phone" ){
  2321. if( country_code == "US" ){
  2322. if( /^(?:\(\d{3}\)|\d{3})(?:\s|[-,.])?\d{3}(?:\s|[-,.])?\d{4}$/.test( input ) )
  2323. return true;
  2324. else
  2325. return false;
  2326. }else{
  2327. if( input.length > 0 )
  2328. return true;
  2329. else
  2330. return false;
  2331. }
  2332. }else if( function_name == "validate_email" ){
  2333. if( /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/.test( input ) )
  2334. return true;
  2335. else
  2336. return false;
  2337. }else if( function_name == "validate_password" ){
  2338. if( input.length > 5 )
  2339. return true;
  2340. else
  2341. return false;
  2342. }else if( function_name == "validate_card_holder_name" ){
  2343. if( country_code == "paypal" )
  2344. return true;
  2345. else if( input.length > 0 )
  2346. return true;
  2347. else
  2348. return false;
  2349. }else if( function_name == "validate_card_number" ){
  2350. input = input.replace(/[^\d]/g,'');
  2351. if( /^4[0-9]{12}(?:[0-9]{3}|[0-9]{6})?$/.test( input ) )
  2352. return true;
  2353. else if( /^6(?:011|5[0-9]{2})[0-9]{12}$/.test( input ) )
  2354. return true;
  2355. else if( /^5[1-5]\d{14}$/.test( input ) )
  2356. return true;
  2357. else if( /^3[47][0-9]{13}$/.test( input ) )
  2358. return true;
  2359. else if( /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/.test( input ) )
  2360. return true;
  2361. else if( /^1800\d{11}$|^3\d{15}$/.test( input ) )
  2362. return true;
  2363. else if( /(^(5[0678]\d{11,18}$))|(^(6[^0357])\d{11,18}$)|(^(3)\d{13,20}$)/.test( input ) )
  2364. return true;
  2365. else
  2366. return false;
  2367. }else if( function_name == "validate_expiration_month" ){
  2368. if( country_code == "paypal" )
  2369. return true;
  2370. else if( !isNaN( input ) && input.length == 2 )
  2371. return true;
  2372. else
  2373. return false;
  2374. }else if( function_name == "validate_expiration_year" ){
  2375. if( country_code == "paypal" )
  2376. return true;
  2377. else if( !isNaN( input ) && input.length == 4 )
  2378. return true;
  2379. else
  2380. return false;
  2381. }else if( function_name == "validate_security_code" ){
  2382. if( country_code == "paypal" )
  2383. return true;
  2384. else if( /^[0-9]{3,4}$/.test( input ) )
  2385. return true;
  2386. else
  2387. return false;
  2388. }
  2389. }
  2390. function ec_open_login_click( ){
  2391. jQuery( '#ec_alt_login' ).slideToggle(300);
  2392. return false;
  2393. }
  2394. function ec_cart_show_review_panel( ){
  2395. jQuery( '.ec_cart_final_loader_overlay' ).show( );
  2396. var data = { action: 'ec_ajax_get_cart' };
  2397. jQuery.ajax({url: ajax_object.ajax_url, type: 'post', data: data, success: function(data){ ec_cart_load_finalize_cart( data ); } } );
  2398. var data = { action: 'ec_ajax_get_cart_totals' };
  2399. jQuery.ajax({url: ajax_object.ajax_url, type: 'post', data: data, success: function(data){ ec_cart_load_finalize_cart_totals( data ); } } );
  2400. if( document.getElementById( 'ec_order_notes' ) && document.getElementById( 'ec_order_notes' ).value.length > 0 ){
  2401. jQuery( '.ec_cart_final_custom_notes_title' ).show( );
  2402. jQuery( '#ec_cart_final_custom_notes' ).show( );
  2403. document.getElementById( 'ec_cart_final_custom_notes' ).innerHTML = document.getElementById( 'ec_order_notes' ).value;
  2404. }else if( document.getElementById( 'ec_order_notes' ) ){
  2405. jQuery( '.ec_cart_final_custom_notes_title' ).hide( );
  2406. jQuery( '#ec_cart_final_custom_notes' ).hide( );
  2407. }
  2408. jQuery( 'html, body' ).animate( {
  2409. scrollTop: 0
  2410. }, 750);
  2411. jQuery( '#ec_cart_final_review_background' ).fadeIn( 100 );
  2412. jQuery( '#ec_cart_final_review_holder' ).fadeIn( 300 );
  2413. }
  2414. function ec_cart_load_finalize_cart( data ){
  2415. var json = jQuery.parseJSON( data );
  2416. for( var i=0; i<json.length; i++ ){
  2417. jQuery( '#ec_cart_final_item_' + json[i].cartitem_id ).removeClass( 'ec_final_item_row_color1' ).removeClass( 'ec_final_item_row_color2' );
  2418. if( i%2 ){
  2419. jQuery( '#ec_cart_final_item_' + json[i].cartitem_id ).addClass( 'ec_final_item_row_color1' );
  2420. }else{
  2421. jQuery( '#ec_cart_final_item_' + json[i].cartitem_id ).addClass( 'ec_final_item_row_color2' );
  2422. }
  2423. document.getElementById( 'ec_cart_final_item_quantity_' + json[i].cartitem_id ).innerHTML = json[i].quantity;
  2424. document.getElementById( 'ec_cart_final_item_price_' + json[i].cartitem_id ).innerHTML = json[i].unit_price;
  2425. }
  2426. }
  2427. function ec_cart_load_finalize_cart_totals( data ){
  2428. var json = jQuery.parseJSON( data );
  2429. if( document.getElementById( 'ec_cart_final_subtotal' ) )
  2430. document.getElementById( 'ec_cart_final_subtotal' ).innerHTML = json.sub_total;
  2431. if( document.getElementById( 'ec_cart_final_tax' ) )
  2432. document.getElementById( 'ec_cart_final_tax' ).innerHTML = json.tax_total;
  2433. if( document.getElementById( 'ec_cart_final_shipping' ) )
  2434. document.getElementById( 'ec_cart_final_shipping' ).innerHTML = json.shipping_total;
  2435. if( document.getElementById( 'ec_cart_final_discount' ) )
  2436. document.getElementById( 'ec_cart_final_discount' ).innerHTML = json.duty_total;
  2437. if( document.getElementById( 'ec_cart_final_duty' ) )
  2438. document.getElementById( 'ec_cart_final_duty' ).innerHTML = json.vat_total;
  2439. if( document.getElementById( 'ec_cart_final_vat' ) )
  2440. document.getElementById( 'ec_cart_final_vat' ).innerHTML = json.discount_total;
  2441. if( document.getElementById( 'ec_cart_final_grand_total' ) )
  2442. document.getElementById( 'ec_cart_final_grand_total' ).innerHTML = json.grand_total;
  2443. jQuery( '.ec_cart_final_loader_overlay' ).fadeOut( 250 );
  2444. }
  2445. function ec_cart_cancel_order( ){
  2446. jQuery( '#ec_cart_final_review_background' ).fadeOut( 100 );
  2447. jQuery( '#ec_cart_final_review_holder' ).fadeOut( 100 );
  2448. return false;
  2449. }
  2450. function ec_stop_enter_press( evt ){
  2451. var evt = (evt) ? evt : ((event) ? event : null);
  2452. var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
  2453. if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
  2454. }
  2455. function ec_check_success_passwords( ){
  2456. var password = document.getElementById( 'ec_password' ).value;
  2457. var verify_password = document.getElementById( 'ec_verify_password' ).value;
  2458. var errors = 0;
  2459. if( password.length < 6 || password.length > 12 ){
  2460. jQuery( '#ec_cart_error_password_length' ).show( );
  2461. jQuery( '#ec_cart_error_password_match' ).hide( );
  2462. errors++;
  2463. }else if( password != verify_password ){
  2464. jQuery( '#ec_cart_error_password_length' ).hide( );
  2465. jQuery( '#ec_cart_error_password_match' ).show( );
  2466. errors++;
  2467. }
  2468. if( errors ){
  2469. jQuery( '#ec_cart_success_error_text' ).show( );
  2470. return false;
  2471. }else{
  2472. jQuery( '#ec_cart_success_error_text' ).hide( );
  2473. return true;
  2474. }
  2475. }
  2476. jQuery( document ).ready( function( ){
  2477. jQuery( '#ec_card_number' ).on( 'input', ec_check_credit_card_type );
  2478. } );
  2479. function ec_check_credit_card_type( ){
  2480. var num = document.getElementById( 'ec_card_number' ).value;
  2481. // first, sanitize the number by removing all non-digit characters.
  2482. num = num.replace(/[^\d]/g,'');
  2483. // now test the number against some regexes to figure out the card type.
  2484. if( num.match( /^5[1-5]\d{14}$/ ) ){
  2485. ec_show_cc_type( "mastercard" );
  2486. }else if( num.match( /^4\d{15}/ ) || num.match( /^4\d{12}/ ) ){
  2487. ec_show_cc_type( "visa" );
  2488. }else if( num.match( /(^3[47])((\d{11}$)|(\d{13}$))/ ) ){
  2489. ec_show_cc_type( "amex" );
  2490. }else if( num.match( /(^3[47])((\d{11}$)|(\d{13}$))/ ) ){
  2491. ec_show_cc_type( "discover" );
  2492. }else if( num.match( /^(?:5[0678]\d\d|6304|6390|67\d\d)\d{8,15}$/ ) ){
  2493. ec_show_cc_type( "maestro" );
  2494. }else if( num.match( /(^(352)[8-9](\d{11}$|\d{12}$))|(^(35)[3-8](\d{12}$|\d{13}$))/ ) ){
  2495. ec_show_cc_type( "jcb" );
  2496. }else if( num.match( /(^(30)[0-5]\d{11}$)|(^(36)\d{12}$)|(^(38[0-8])\d{11}$)/ ) ){
  2497. ec_show_cc_type( "diners" );
  2498. }else{
  2499. ec_show_cc_type( "all" );
  2500. }
  2501. }
  2502. function ec_show_cc_type( type ){
  2503. if( document.getElementById( 'ec_cart_payment_credit_card_icon_visa' ) ){
  2504. if( type == "visa" || type == "all" ){
  2505. jQuery( '#ec_cart_payment_credit_card_icon_visa' ).show( );
  2506. jQuery( '#ec_cart_payment_credit_card_icon_visa_inactive' ).hide( );
  2507. }else{
  2508. jQuery( '#ec_cart_payment_credit_card_icon_visa' ).hide( );
  2509. jQuery( '#ec_cart_payment_credit_card_icon_visa_inactive' ).show( );
  2510. }
  2511. }
  2512. if( document.getElementById( 'ec_cart_payment_credit_card_icon_delta' ) ){
  2513. if( type == "delta" || type == "all" ){
  2514. jQuery( '#ec_cart_payment_credit_card_icon_delta' ).show( );
  2515. jQuery( '#ec_cart_payment_credit_card_icon_delta_inactive' ).hide( );
  2516. }else{
  2517. jQuery( '#ec_cart_payment_credit_card_icon_delta' ).hide( );
  2518. jQuery( '#ec_cart_payment_credit_card_icon_delta_inactive' ).show( );
  2519. }
  2520. }
  2521. if( document.getElementById( 'ec_cart_payment_credit_card_icon_uke' ) ){
  2522. if( type == "uke" || type == "all" ){
  2523. jQuery( '#ec_cart_payment_credit_card_icon_uke' ).show( );
  2524. jQuery( '#ec_cart_payment_credit_card_icon_uke_inactive' ).hide( );
  2525. }else{
  2526. jQuery( '#ec_cart_payment_credit_card_icon_uke' ).hide( );
  2527. jQuery( '#ec_cart_payment_credit_card_icon_uke_inactive' ).show( );
  2528. }
  2529. }
  2530. if( document.getElementById( 'ec_cart_payment_credit_card_icon_discover' ) ){
  2531. if( type == "discover" || type == "all" ){
  2532. jQuery( '#ec_cart_payment_credit_card_icon_discover' ).show( );
  2533. jQuery( '#ec_cart_payment_credit_card_icon_discover_inactive' ).hide( );
  2534. }else{
  2535. jQuery( '#ec_cart_payment_credit_card_icon_discover' ).hide( );
  2536. jQuery( '#ec_cart_payment_credit_card_icon_discover_inactive' ).show( );
  2537. }
  2538. }
  2539. if( document.getElementById( 'ec_cart_payment_credit_card_icon_mastercard' ) ){
  2540. if( type == "mastercard" || type == "all" ){
  2541. jQuery( '#ec_cart_payment_credit_card_icon_mastercard' ).show( );
  2542. jQuery( '#ec_cart_payment_credit_card_icon_mastercard_inactive' ).hide( );
  2543. }else{
  2544. jQuery( '#ec_cart_payment_credit_card_icon_mastercard' ).hide( );
  2545. jQuery( '#ec_cart_payment_credit_card_icon_mastercard_inactive' ).show( );
  2546. }
  2547. }
  2548. if( document.getElementById( 'ec_cart_payment_credit_card_icon_amex' ) ){
  2549. if( type == "amex" || type == "all" ){
  2550. jQuery( '#ec_cart_payment_credit_card_icon_amex' ).show( );
  2551. jQuery( '#ec_cart_payment_credit_card_icon_amex_inactive' ).hide( );
  2552. }else{
  2553. jQuery( '#ec_cart_payment_credit_card_icon_amex' ).hide( );
  2554. jQuery( '#ec_cart_payment_credit_card_icon_amex_inactive' ).show( );
  2555. }
  2556. }
  2557. if( document.getElementById( 'ec_cart_payment_credit_card_icon_jcb' ) ){
  2558. if( type == "jcb" || type == "all" ){
  2559. jQuery( '#ec_cart_payment_credit_card_icon_jcb' ).show( );
  2560. jQuery( '#ec_cart_payment_credit_card_icon_jcb_inactive' ).hide( );
  2561. }else{
  2562. jQuery( '#ec_cart_payment_credit_card_icon_jcb' ).hide( );
  2563. jQuery( '#ec_cart_payment_credit_card_icon_jcb_inactive' ).show( );
  2564. }
  2565. }
  2566. if( document.getElementById( 'ec_cart_payment_credit_card_icon_diners' ) ){
  2567. if( type == "diners" || type == "all" ){
  2568. jQuery( '#ec_cart_payment_credit_card_icon_diners' ).show( );
  2569. jQuery( '#ec_cart_payment_credit_card_icon_diners_inactive' ).hide( );
  2570. }else{
  2571. jQuery( '#ec_cart_payment_credit_card_icon_diners' ).hide( );
  2572. jQuery( '#ec_cart_payment_credit_card_icon_diners_inactive' ).show( );
  2573. }
  2574. }
  2575. if( document.getElementById( 'ec_cart_payment_credit_card_icon_laser' ) ){
  2576. if( type == "laser" || type == "all" ){
  2577. jQuery( '#ec_cart_payment_credit_card_icon_laser' ).show( );
  2578. jQuery( '#ec_cart_payment_credit_card_icon_laser_inactive' ).hide( );
  2579. }else{
  2580. jQuery( '#ec_cart_payment_credit_card_icon_laser' ).hide( );
  2581. jQuery( '#ec_cart_payment_credit_card_icon_laser_inactive' ).show( );
  2582. }
  2583. }
  2584. if( document.getElementById( 'ec_cart_payment_credit_card_icon_maestro' ) ){
  2585. if( type == "maestro" || type == "all" ){
  2586. jQuery( '#ec_cart_payment_credit_card_icon_maestro' ).show( );
  2587. jQuery( '#ec_cart_payment_credit_card_icon_maestro_inactive' ).hide( );
  2588. }else{
  2589. jQuery( '#ec_cart_payment_credit_card_icon_maestro' ).hide( );
  2590. jQuery( '#ec_cart_payment_credit_card_icon_maestro_inactive' ).show( );
  2591. }
  2592. }
  2593. }