// rendering of dynamic market place
function renderDynamicMarketPlaceWidget()
{
    var source;
    source = vertical + "/widget/marketplacedynamicwidget.html"

    if(typeof uri != "undefined" && uri != null){
        source += "?uri=" + uri;
        if(adGroupId && adGroupId != null) {
            source += "&marketPlaceAdGroupId=" + adGroupId;
        }
    }else{
        if(adGroupId && adGroupId != null) {
            source += "?marketPlaceAdGroupId=" + adGroupId;
        }
    }

    if(typeof defaultProductId != "undefined" && defaultProductId != null) {
        source += "&defaultProductId=" + defaultProductId;
    }
    
    document.write("<iframe id='iframeDynamicMP' src='"+ source + "' frameborder='0' scrolling='no' target='_parent' style='width:234px;height:800px;'></iframe>");
}

function renderStaticMarketPlaceWidget(config)
{
    var mPWidget = typeof config.mPWidget !='undefined' && config.mPWidget!='' ? config.mPWidget : '';
    var productType = typeof config.productType!='undefined' && config.productType!=''  ? config.productType : 'loan';
    var bgColor = typeof config.bgColor!='undefined' && config.bgColor!=''  ? config.bgColor : '#EEF5E4';
    var src = '';
    if(productType=="loan"){
        src = 'http://www.apnaloan.com/widget/marketplacestaticwidget.html?widgetToShow=';
        src = src + mPWidget;
        src = src + '&bgColor='+ bgColor;
    }
    else if(productType=="insurance"){
        src = 'http://www.apnainsurance.com/widget/marketplacestaticwidget.html?widgetToShow=';
        src = src + mPWidget;
        src = src + '&bgColor='+ bgColor;
    }
    if(productType=="loan"){
        document.write("<iframe id='marketPlaceStaticWidget'  onload='scrollBy(0,0);'  src='"+src+"' style='width:574px;height:445px;position:inherit'  scrolling='no' frameborder='0' ></iframe>");
    }
    else if(productType=="insurance"){
        document.write("<iframe id='marketPlaceStaticWidget'  onload='scrollBy(0,0);'  src='"+src+"' style='width:574px;height:445px;position:inherit'  scrolling='no' frameborder='0' ></iframe>");
    }
}


// capturing mouse position
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var mouseCordinate={xPos:0,yPos:0};

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  mouseCordinate.xPos = tempX;
  mouseCordinate.yPos = tempY;
  return true
}

function showMessage(id,alignReq)
{
    if(alignReq == 'no'){
        document.getElementById(id).style.display = 'block';
    }
    else {
        var container = document.getElementById(id);
        container.style.top = mouseCordinate.yPos - 135;
        container.style.left = mouseCordinate.xPos - 80;
        container.style.display = 'block';
    }
}

function hideMessage(id)
{
    document.getElementById(id).style.display = 'none';
}
