var lastEndorses = []; lastEndorses[ 0 ] = []; function CsEndorseLaunch( productId, action ) { new CsRegisterLayer(); return; if( lastEndorses[ productId ] ) { if( lastEndorses[ productId ].length > 1 ) { if( lastEndorses[ productId ][ lastEndorses[ productId ].length - 2 ] + 30000 > new Date().getTime() ) { var delay = parseInt( ( lastEndorses[ productId ][ lastEndorses[ productId ].length - 1 ] + 30000 - new Date().getTime() ) / 1000 ) + 1; alert( 'Perhaps you should take a deep breath and think it over for ' + delay + ' second' + ( delay == 1 ? '' : 's' ) + ' before you change your mind again.' ); return; } } } else { lastEndorses[ productId ] = []; } if( lastEndorses[ 0 ].length > 3 ) { if( lastEndorses[ 0 ][ lastEndorses[ 0 ].length - 4 ] + 30000 > new Date().getTime() ) { var delay = parseInt( ( lastEndorses[ 0 ][ lastEndorses[ 0 ].length - 4 ] + 30000 - new Date().getTime() ) / 1000 ) + 1; alert( 'Perhaps you should take a deep breath for ' + delay + ' second' + ( delay == 1 ? '' : 's' ) + ' and consider your recommendations carefully.' ); return; } } lastEndorses[ 0 ][ lastEndorses[ 0 ].length ] = new Date().getTime(); lastEndorses[ productId ][ lastEndorses[ productId ].length ] = new Date().getTime(); new CsEndorse( productId, action ); } CsEndorse = function( productId, action ) { this.getResponse = function( id, status ) { if( DrAjax.statuses[ status ] == 'Complete' ) { var xml = DrAjax.getResponse( id ); var redirect = xml.getElementsByTagName("redirect").item(0); if ( redirect ) { self.location = redirect.getAttribute("url"); } else { var error = xml.getElementsByTagName("e").item(0); if ( error ) { alert ( error.getAttribute("m") ); } else { parseResponse( xml ); } } } } var parseResponse = function( xml ) { var product = xml.getElementsByTagName( 'r' ).item(0); $( 'endor_' + product.getAttribute( 'id') ).innerHTML = product.getAttribute( 'c' ); } DrAjax.sendRequest( 'AjaxServer.php', this.getResponse, 'call=Product.endorse&p=' + productId + '&a=' + action ); }