﻿/**
 * Description: general javascript actions and functions for the Module Extranet
 * User: antonio.r
 * Date: 21/Out/2011
 **/
var str_globalOrderID;

function getItems(str_orderID) {
  var str_url = location.protocol + "//" + location.hostname + "/public/getOrderStatus.aspx?OrderID=" + str_orderID;

  $.ajax( {
    url: str_url,
    type: "GET",
    success: function(data) {
      var xml;
      if ( $.browser.msie && typeof data == "string" ) {
        xml = new ActiveXObject( "Microsoft.XMLDOM" );
        xml.async = false;
        xml.loadXML( data );
      }
      else {
        xml = data;
      }

      str_globalOrderID = $( xml ).find( "item" ).attr( 'name' );
    }
  } );
}

function onLoadGetStatus() {
  var str_orderID,
      str_urlFirst,
      str_urlSecond,
      str_url;

  $( "td.actionValue a.refresh" ).each( function(index) {
    str_urlFirst = $( this ).attr( "href" ).split( "ID=" );
    str_urlSecond = str_urlFirst[1].split( "&" );
    $( this ).attr( "href" , str_urlFirst[0] + "ID=" + num_cartPageId + "&" + str_urlSecond[1] + "&ReorderID=" + $(this).parents("tr").find("td.orderId").text() );
  } );

  $( "tr.clientAreaValues td.statusValue" ).each( function(i) {
    str_orderID = $( this ).attr( "id" );
    //alert(str_orderID);
    getItems( str_orderID );
    $( this ).text( str_globalOrderID );
  } );

  //todo meter border no .paragraph
}
