﻿// Call this function and send the object ID which will be used to display the contents of the rendered page
// params: v 
//  is the ID of the DIV/SPAN or object in general that will be updated
//  pageID is the ID of the page to be displayed, the ID will be provided by the PA.
// This file must not be modified unless specific requirements are to be implemented
function LoadPageAndSetValue(v,pageId){
var webPage;

    try{
    // this is the actual call to the wrapper, the wsRenderCall.ashx must reside in the same location as the web site with its DLL.
    // if the location of the wsRenderCall.ashx file changes, you will need to update this value to reflect its current location.
    webPage = render('wsRenderCall.ashx?dealerid='+dlrId+'&siteid='+stId+'&pageid='+pageId);
    
    }catch(e) {
        //if an error is found it will display it on the page (change this if you want to hide errors)
    webPage=e.description;
    }
    
    document.getElementById(v).innerHTML = webPage;
}
function LoadPageAndReturnValue(pageId){
var webPage;

    try{
    // this is the actual call to the wrapper, the wsRenderCall.ashx must reside in the same location as the web site with its DLL.
    // if the location of the wsRenderCall.ashx file changes, you will need to update this value to reflect its current location.
    webPage = render('wsRenderCall.ashx?dealerid='+dlrId+'&siteid='+stId+'&pageid='+pageId);
    
    }catch(e) {
        //if an error is found it will display it on the page (change this if you want to hide errors)
    webPage=e.description;
    }
    return webPage;
}


function LoadPageAndSetValueWithSize(v,pageId,width,height){
var webPage;

try{
// this is the actual call to the wrapper, the wsRenderCall.ashx must reside in the same location as the web site with its DLL.
// if the location of the wsRenderCall.ashx file changes, you will need to update this value to reflect its current location.
webPage = render('wsRenderCall.ashx?dealerid='+dlrId+'&siteid='+stId+'&pageid='+pageId);
}catch(e) {
//if an error is found it will display it on the page (change this if you want to hide errors)
webPage=e.description;
}
	if(webPage.length<2){
	document.getElementById(v).style.height = height;
	document.getElementById(v).style.width = width;
	}
document.getElementById(v).innerHTML = webPage;
}


/* This will create a request for javascript*/
function createXMLHttpRequest() {
   try { return new XMLHttpRequest(); } catch(e) {}
   try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
   return null;
 }
function render(url){
    var xmlHttpReq = createXMLHttpRequest();
    xmlHttpReq.open("GET", url, false);
    xmlHttpReq.send(null);
    var yourJSString = xmlHttpReq.responseText;
    // this works cross browser
    return yourJSString;
}

