var imp_check = true;
var imp_base_per = 40;
var mp_catid;
var compareProductLength = new Array(0);
function Redirect_Back(id) {
if (id == 1) {
if (queryString("action") == "html") {
parent.window.location = "http://" + window.location.host + "/myaccount.aspx";
}
else {
parent.window.location = "http://" + window.location.host + "/Customer/Home.aspx";
}
}
else if (id == 2) {
if (queryString("action") == "html") {
parent.window.location = "http://" + window.location.host;
}
else {
parent.window.location = "http://" + window.location.host;
}
}
else {
if (queryString("action") == "html") {
var url = "http://" + window.location.host + "/MP_AJAX/MP_RedirectInfinimarket.aspx?" + id;
var xmlRequest = DoCallback(url, "")
parent.window.location = "http://" + window.location.host + "/checkout1.aspx?product_id=" + xmlRequest.responseText;
}
else {
var url = "http://" + window.location.host + "/MP_AJAX/MP_RedirectInfinimarket.aspx?" + id;
var xmlRequest = DoCallback(url, "")
if (xmlRequest) {
var str = xmlRequest.responseText;
parent.window.location = "http://" + window.location.host + "/default.aspx?ProURL_ID=" + str;
}
}
}
}
function PlaceBestOfferBid() {
var url = "http://" + window.location.host + "/MP_AJAX/MP_ApprovedSuppiler.aspx" + window.location.search + "&check=supplier";
var xmlRequest = DoCallback(url, "")
if (xmlRequest) {
var str = xmlRequest.responseText;
if (str == 'APPROVED') {
parent.Placeapprovebid()
}
else if (str == 'CONTROLLEDBID') {
parent.downslide();
parent.SetSource("/loadingpage.html");
parent.RedirectPlaceBidHTML();
}
else if (str == 'NOTAPPROVED') {
var url = "http://" + window.location.host + "/MP_AJAX/MP_PlaceBid.aspx" + window.location.search;
parent.SetSourceNew(url)
}
else if (str == 'FIXTENDER') {
parent.SubmitBestOfferBid();
}
else if (str == 'FIXBIDDER') {
parent.SubmitBestOfferBid();
}
else if (str == 'SELLING') {
parent.Placeapprovebid()
}
else if (str == 'NOTAPPROVEDBIDDER') {
var url = "http://" + window.location.host + "/MP_AJAX/MP_PlaceBid.aspx" + window.location.search;
parent.SetSourceNew(url)
}
else if (str == 'NOTALLOWED') {
var url = "http://" + window.location.host + "/MP_AJAX/MP_PlaceBid.aspx" + window.location.search + "&bidder=NOTALLOWED";
parent.SetSourceNew(url)
}
}
}
function Placeapprovebid() {
var url = "http://" + window.location.host + "/MP_AJAX/displayDescription.aspx" + window.location.search + "&checkBanner=true&_screen=" + screen.width;
var xmlRequest = DoCallback(url, "")
if (xmlRequest) {
var str = xmlRequest.responseText;
if (str == 'ok') {
var merchant_id = queryStringNew("merchant_product_id");
src = '../ProductFiles/' + merchant_id + '/1/1/resolution/index.htm';
SetSourceWithCommands(src);
}
else {
SetSourceWithCommands("http://" + window.location.host + "/MP_AJAX/displayDescription.aspx" + window.location.search);
}
}
var url = "http://" + window.location.host + "/MP_AJAX/MP_ProductDetails.aspx" + window.location.search + "&qstr=login";
var xmlRequest = DoCallback(url, "")
if (xmlRequest) {
document.getElementById('ACTIVECOMMANDS').style.visibility = 'visible';
document.getElementById('ACTIVECOMMANDS').innerHTML = xmlRequest.responseText;
}
}
function loadbidhistory(productid) {
var url = "/MP_AJAX/MP_BidHistory.aspx" + GlobalMpQuery;
window.frames["frame_details"].location = url;
}
function fixMoney(fld, sep) { // monetary field check
document.getElementById('err_msg').value = ' ';
document.getElementById('err_msg_head').value = ' ';
if (!fld.value.length || fld.disabled) return true; // blank fields are the domain of requireValue
var val = fld.value;
if (fieldname(fld) == 'Budget' && (val == 0 || val == 'N/A' || val == 'na' || val == 'n/a' || val == 'NA')) {
if (val == 'N/A' || val == 'na' || val == 'n/a' || val == 'NA')
return true;
else {
document.getElementById('err_msg').value = '* Invalid Amount';
return false;
}
}
if (typeof (sep) != 'undefined') val = val.replace(new RegExp(sep, 'g'), '');
if (val.indexOf('$') == 0)
val = parseFloat(val.substring(1, 40));
else
val = parseFloat(val);
if (isNaN(val)) { // parse error
document.getElementById('err_msg').value = '* Invalid Amount.'
return false;
}
var sign = (val < 0 ? '-' : '');
val = Number(Math.round(Math.abs(val) * 100)).toString();
while (val.length < 2) val = '0' + val;
var len = val.length;
val = sign + (len == 2 ? '0' : val.substring(0, len - 2)) + '.' + val.substring(len - 2, len + 1);
fld.value = val;
return true;
}
function fieldname(fld) { // get the field label text or name
if (fld.id && document.getElementsByTagName) {
for (var i = 0, lbl = document.getElementsByTagName('LABEL'); i < lbl.length; i++)
if (lbl[i].htmlFor == fld.id) return lbl[i].nodeValue || lbl[i].textContent || lbl[i].innerText;
for (var i = 0, lbl = document.getElementsByTagName('label'); i < lbl.length; i++)
if (lbl[i].htmlFor == fld.id) return lbl[i].nodeValue || lbl[i].textContent || lbl[i].innerText;
}
return fld.name || fld.type;
}
function SubmitBestOfferBid() {
GlobalMpQuery = window.location.search
if (queryString("isfixpricetender") == 'Y') {
var url = "http://" + window.location.host + "/MP_AJAX/MP_PlaceBid.aspx" + window.location.search;
SetSource(url);
}
else if (queryString("type") == 'profile') {
var PQnty = document.getElementById('lbl_quantity').innerText;
var NPrice = document.getElementById('new_offer').value;
var qstring = "new_offer=" + NPrice + "&purchased_quantity=" + PQnty;
var url = "http://" + window.location.host + "/MP_AJAX/MP_CheckBid.aspx" + GlobalMpQuery + "&" + qstring + "&" + "check=" + imp_check + "&base_percentage=" + imp_base_per;
if (fixMoney(document.getElementById('new_offer')) == true) {
var xmlRequest = DoCallback(url, "")
{
var str = xmlRequest.responseText;
var temp = new Array();
temp = str.split('&');
if (queryString("type") == 'profile') {
if (temp[0] == 'false1') {
document.getElementById('err_msg_head').value = "  * Enter bid";
document.getElementById('err_msg').value = "amount greater than current bid";
}
else if (temp[0] == 'false2') {
document.getElementById('err_msg_head').value = "* You can not ";
document.getElementById('err_msg').value = "place amount bid greater than " + temp[1];
}
else if (temp[0] == 'false3') {
document.getElementById('err_msg_head').value = "* One Bidder Cannot ";
document.getElementById('err_msg').value = " place consecutively 2 bids";
}
else {
var url = "http://" + window.location.host + "/MP_AJAX/MP_PlaceBid.aspx" + GlobalMpQuery + "&" + qstring + "&" + str;
SetSource(url);
}
}
else {
if (temp[0] == 'false1') {
document.getElementById('err_msg_head').value = "  * Enter bid";
document.getElementById('err_msg').value = "amount greater than current bid";
}
else if (temp[0] == 'false2') {
document.getElementById('err_msg_head').value = "* You can not ";
document.getElementById('err_msg').value = "place bid amount greater than " + temp[1];
}
else {
var url = "http://" + window.location.host + "/MP_AJAX/MP_PlaceBid.aspx" + GlobalMpQuery + "&" + qstring + "&" + str;
SetSource(url);
}
}
}
}
}
else if (queryString("type") == 'selling') {
var NPrice = document.getElementById('new_offer').value;
var qstring = "new_offer=" + NPrice; //+"&purchased_quantity="+PQnty;
var url = "http://" + window.location.host + "/MP_AJAX/MP_CheckBid.aspx" + GlobalMpQuery + "&" + qstring + "&" + "check=" + imp_check + "&base_percentage=" + imp_base_per;
if (fixMoney(document.getElementById('new_offer')) == true) {
var xmlRequest = DoCallback(url, "")
{
var str = xmlRequest.responseText;
var temp = new Array();
temp = str.split('&');
if (queryString("type") == 'selling') {
if (temp[0] == 'false1') {
document.getElementById('err_msg_head').value = "Enter bid amount";
document.getElementById('err_msg').value = " greater than current bid";
}
else if (temp[0] == 'false2') {
document.getElementById('err_msg_head').value = "You can not place bid ";
document.getElementById('err_msg').value = "amount greater than " + temp[1];
}
else if (temp[0] == 'false3') {
document.getElementById('err_msg_head').value = "Bid not allowed.Please wait";
document.getElementById('err_msg').value = " until someone else places bid";
}
else if (temp[0] == 'false4') {
document.getElementById('err_msg_head').value = "Place a bid greater than 5% of ";
document.getElementById('err_msg').value = "current bid i.e." + temp[1];
}
else {
var url = "http://" + window.location.host + "/MP_AJAX/MP_PlaceBid.aspx" + GlobalMpQuery + "&" + qstring + "&" + str;
SetSource(url);
}
}
}
}
}
else {
var PQnty = "";
if (navigator.userAgent.indexOf('iPhone') != -1) {
PQnty = document.getElementById('lbl_quantity').innerText;
} else {
PQnty = document.getElementById('lbl_quantity').value;
}
var NPrice = document.getElementById('new_offer').value;
var qstring = "new_offer=" + NPrice + "&purchased_quantity=" + PQnty;
var url = "http://" + window.location.host + "/MP_AJAX/MP_CheckBid.aspx" + GlobalMpQuery + "&" + qstring + "&" + "check=" + imp_check + "&base_percentage=" + imp_base_per;
if (fixMoney(document.getElementById('new_offer')) == true) {
var xmlRequest = DoCallback(url, "")
{
var str = xmlRequest.responseText;
var temp = new Array();
temp = str.split('&');
if (temp[0] == 'false1') {
document.getElementById('err_msg_head').value = "Enter bid";
document.getElementById('err_msg').value = "amount less than current bid";
}
else if (temp[0] == 'false2') {
document.getElementById('err_msg_head').value = "You can not place bid ";
document.getElementById('err_msg').value = "amount less than " + temp[1];
}
else if (temp[0] == 'false3') {
document.getElementById('err_msg_head').value = "Bid not allowed.Please wait";
document.getElementById('err_msg').value = " until someone else places bid";
}
else if (temp[0] == 'false4') {
document.getElementById('err_msg_head').value = "Place a bid less than 5% of ";
document.getElementById('err_msg').value = "current bid i.e." + temp[1];
}
else {
var url = "http://" + window.location.host + "/MP_AJAX/MP_PlaceBid.aspx" + GlobalMpQuery + "&" + qstring + "&" + str;
SetSource(url);
}
}
}
}
}
function Redirect_infinimarket() {
var url = "http://" + window.location.host + "/MP_AJAX/MP_RedirectInfinimarket.aspx" + window.location.search;
var xmlRequest = DoCallback(url, "")
if (xmlRequest) {
var str = xmlRequest.responseText;
if (window == parent.window) {
parent.window.location = "http://" + str + "&category=" + queryString("category");
}
else {
parent.changeParentLocation("http://" + str + "&category=" + queryString("category"));
}
}
}
function LoadProductAttribute(param) {
SetSourceWithCommands("/loadingpage.html");
document.getElementById("RelatedProductDiv").style.display = "none";
document.getElementById("FavouriteProductDiv").style.display = "none";
document.getElementById("HistoryProductDiv").style.display = "none";
document.getElementById("CompareProductDiv").style.display = 'none';
document.getElementById("comparePro").innerHTML = "";
SetSourceWithCommands("MP_Ajax/MP_ProductAttribute.aspx" + param);
}
function renderProductAttibute(params) {
var xmlRequest = DoCallback("../MP_AJAX/MP_Attribute.aspx", params);
document.getElementById("Attribute").innerHTML = "";
{
document.getElementById("Attribute").style.display = 'block';
document.getElementById("Attribute").innerHTML = xmlRequest.responseText;
document.getElementById("CompareProductDiv").style.display = 'none';
document.getElementById("comparePro").innerHTML = "";
}
}
function AttributeHide() {
document.getElementById("Attribute").style.display = 'none';
document.getElementById("Attribute").innerHTML = ""
document.getElementById("CompareProductDiv").style.display = 'none';
document.getElementById("comparePro").innerHTML = "";
}
function CompareProduct(CurrentproId) {
document.getElementById("FavouriteProductDiv").style.display = "none";
document.getElementById("HistoryProductDiv").style.display = "none";
currentRelatedProId = CurrentproId;
var params;
params = mp_catid // "?CurrentProId="+CurrentproId + "&CategoryID="+mp_catid;
document.getElementById("comparePro").innerHTML = frameLoading;
var _RelatedResult;
var req = null;
req = initXMLHTTPRequest();
if (req) {
if (params == undefined) {
req.open("POST", "MP_AJAX/MP_CompareProduct.aspx?search=true&CurrentproId=" + currentRelatedProId, true);
}
else {
SetSourceWithCommands("/loadingpage.html");
req.open("POST", "MP_AJAX/MP_CompareProduct.aspx" + params + "&CurrentproId=" + currentRelatedProId, true);
}
req.onreadystatechange = function() {
var ready = req.readyState;
var data = null;
if (ready == 4) {
xmlResult = req.responseText;
if (xmlResult == "No Data") {
_RelatedResult = xmlResult;
document.getElementById("CompareProductDiv").style.display = 'block';
document.getElementById("comparePro").innerHTML = "<table width='100%' border='0'  cellspacing='0' cellpadding='0'><tr><td width='16%' class='red_text' align='center'> No Products For Compare </td></tr></table>"
}
else {
document.getElementById("CompareProductDiv").style.display = 'block';
document.getElementById("comparePro").innerHTML = xmlResult;
_resWizardPro = document.getElementById("RelatedProductDiv").innerHTML;
initArrow('reletedProducts');
var lengthArr;
lengthArr = document.getElementById("arrayLength").innerText;
lengthArr = lengthArr;
compareProductLength = new Array(lengthArr);
for (var i = 0; i < lengthArr; i++) {
if (document.getElementById("CompareCheckBox" + i) != null) {
if (document.getElementById("CompareCheckBox" + i).checked == true) {
compareProductLength[i] = document.getElementById("CompareCheckBox" + i).value;
}
else {
compareProductLength[i] = null;
}
}
}
var cat_str
cat_str = params.replace('?', '');
cat_str = cat_str.replace(/&/g, "~~");
var temp = new Array();
var str
str = params
temp = str.split('&');
if (temp[2] == "mp_catType=1") {
var tem1 = new Array();
var str1
temp1 = temp[1].split('=');
cat_str = "chk=1&cat_str=" + cat_str
CompareCheck(temp1[1], currentRelatedProId, 1, 'true', 0, 1)
}
else {
var tem1 = new Array();
var str1
temp1 = temp[0].split('=');
cat_str = "chk=2&cat_str=" + cat_str
CompareCheck(temp1[1], currentRelatedProId, 1, 'true', 0, 2)
}
}
}
else {
document.getElementById("comparePro").innerHTML = frameLoading;
}
}
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.send("");
}
}
function CompareCheck(catID, productId, chkBoxId, chkBoxChecked, RelatedproductLength, params) {
SetSourceWithCommands("/loadingpage.html");
_resWizardPro = document.getElementById("RelatedProductDiv").innerHTML;
var lengthArr;
lengthArr = document.getElementById("arrayLength").innerText;
lengthArr = lengthArr;
compareProductLength = new Array(lengthArr);
for (var i = 0; i < lengthArr; i++) {
if (document.getElementById("CompareCheckBox" + i) != null) {
if (document.getElementById("CompareCheckBox" + i).checked == true) {
compareProductLength[i] = document.getElementById("CompareCheckBox" + i).value;
}
else {
compareProductLength[i] = null;
}
}
}
var params_str = "?categoryID=" + catID + "&CurrentProId=" + productId + "&checkboxId=" + chkBoxId + "&checkBoxChecked=" + chkBoxChecked + "&proids=" + compareProductLength + "&catType=" + params;
SetSourceWithCommands("MP_Ajax/MP_comparing.aspx" + params_str);
}
function PlaceProfileBid() {
GlobalMpQuery = window.location.search;
var url = "http://" + window.location.host + "/MP_AJAX/MP_ApprovedSuppiler.aspx" + window.location.search + "&check=supplier";
var xmlRequest = DoCallback(url, "")
if (xmlRequest) {
var str = xmlRequest.responseText;
if (str == 'APPROVED') {
parent.Placeapprovebid()
}
else if (str == 'CONTROLLEDBID') {
parent.downslide();
parent.SetSource("/loadingpage.html");
parent.RedirectPlaceBid();
}
else if (str == 'NOTAPPROVED') {
var url = "http://" + window.location.host + "/MP_AJAX/MP_PlaceBid.aspx" + window.location.search;
parent.SetSourceNew(url)
}
else if (str == 'FIXTENDER') {
parent.SubmitBestOfferBid();
}
}
}
function ApprovedBidder() {
var url = "http://" + window.location.host + "/MP_AJAX/MP_PlaceBid.aspx" + window.location.search + '&mp_approved=approvedbidder';
var frm = parent.document.getElementById('frame_details')
frm.src = url;
}
function RedirectProduct(url) {
parent.window.location = url;
}
function BestOfferBidNew_HTML() {
var url = "http://" + window.location.host + "/MP_AJAX/MP_ProductDetails.aspx" + window.location.search + "&placebid=true";
var xmlRequest = DoCallbackNew(url, "")
if (xmlRequest) {
var str = xmlRequest.responseText;
if (str == 'NOTLOGIN') {
SetSourceNew('/MP_AJAX/MP_bid.aspx' + window.location.search)
}
else {
PlaceBestOfferBid();
}
}
else {
}
}
function RedirectPlaceBidHTML() {
src = "http://" + window.location.host + "/Specialize/PlaceControllBidBid.aspx" + window.location.search;
SetSource(src);
}
function Redirectmarketplace() {
var url = "http://" + window.location.host + "/MP_AJAX/MP_Advertisement.aspx?checkAd=redirect";
var xmlRequest = DoCallbackNew(url, "")
if (xmlRequest) {
var str = xmlRequest.responseText;
parent.window.location = "http://" + str + "/default.aspx";
}
}

