﻿
var ImagePath = "/images/PWMenus/";
function HighLightColor(e,path)
{
    var image = document.getElementById(e);
    //image.src = ImagePath + "A" + image + ".jpg";
   // alert(e);
    image.src = path;
    image.style.cursor = "hand";
}
 
function BackToNormal(e,path)
{
    var image = document.getElementById(e);
    image.src = path;
}

 // get XMLHTTP object
var baseUrl = null;
var divId = null;
var divList = null;
var pageName = null;


function getXMLHTTP()
{
    var A = null;
    try
    {
        A = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e){
        try{
              A = new ActiveXObject("Microsoft.XMLHTTP");
        } catch(oc){
              A = null;
        }
  }
  if(!A && typeof XMLHttpRequest != "undefined") {
        A = new XMLHttpRequest();
  }
  return A;
}

function AjaxStart()
{
    // public members
    this.baseUrl = baseUrl;
    getSource();

    // XMLHTTP object
    var xmlHttp;

    // call XMLHTTP to get source data

    function getSource()
    {
          var requestUrl = baseUrl;
          xmlHttp = getXMLHTTP();
          if (xmlHttp)
          {
                xmlHttp.onreadystatechange = doReadyStateChange;
                xmlHttp.open("GET", requestUrl, true);
                xmlHttp.send(null);
          }             
    }
    // process the response from XMLHTTP
    function doReadyStateChange()
    {
          if (xmlHttp.readyState == 4)    
          {
                if (xmlHttp.status == 200)
                {
                    var d = xmlHttp.responseText;
                      if (d != null)
                      {
                          alert(d);
                          imageCell = document.getElementById('CenterImage');
                          imageCell.value = d;   
                      }
                }
                else
                {
                      alert("There was a problem retrieving the data:\n" + xmlHttp.statusText);
                }
          }             
    }
    }

function Intialise(url)
{
    alert(url);
    baseUrl = url;
    AjaxStart();
}

    
//function ShowBigImage(path,hrefPath)
//{
//    var bigImage = document.getElementById("bigImg");
//    bigImage.src = path;
//    var customize = document.getElementById("customizeLink");
//    customize.href = hrefPath;
//}
var g_frontimagepath;
var g_innerimagepath;
var g_backimagepath;
var g_hrefPath;
var g_selectedCell;
function ShowBigImage(frontimagepath,innerimagepath,backimagepath,hrefPath,tdId)
{
//alert(tdId);
if(tdId!=null)
 {
    var selectedCell = document.getElementById(tdId);
    if(selectedCell==g_selectedCell)
    {
        return;
    }
    // alert(selectedCell.style.borderColor);
    selectedCell.style.borderColor = "#8CA13E";
    selectedCell.style.borderWidth = "2px";
    
    if(g_selectedCell!=null)
    {
        g_selectedCell.style.borderColor = "#6E6F70"
        g_selectedCell.style.borderWidth = "1px";
    }
    g_selectedCell = selectedCell
 }
 g_frontimagepath = frontimagepath;
 g_innerimagepath = innerimagepath;
 g_backimagepath = backimagepath;
 g_hrefPath = hrefPath;
 showFrontPage();    
 var customize = document.getElementById("customizeLink");
 customize.href = hrefPath;
 
 
 
}
function showFrontPage()
{
 
 var OneImage = document.getElementById("onlyOneImage");
    OneImage.style.display='block';
 
 
 var innDiv = document.getElementById("innerDiv");
    innDiv.style.display='none';
    
 var bigImage = document.getElementById("bigImg");
 bigImage.src = g_frontimagepath;
 //alert("hello");
 showFrontHighLighted();
 showBackNormal();
 showInnerNormal();
 
}

function showFrontNormal()
{
    displayFrontIcon.src = "images/inner_01_NEW_08.gif";
}
function showFrontHighLighted()
{
    displayFrontIcon.src = "images/jai-inner_01_new_08.gif";
}
function showInnerNormal()
{
    displayInnerIcon.src = "images/inner_01_NEW_09.gif";
}
function showInnerHighLighted()
{
    displayInnerIcon.src = "images/jai-inner_01_NEW_09.gif";
}
function showBackNormal()
{
    displayBackIcon.src = "images/inner_01_NEW_10.gif";
}
function showBackHighLighted()
{
    displayBackIcon.src = "images/jai-inner_01_NEW_10.gif";
}

function showInnerPage()
{
// var innDiv = document.getElementById("innerDiv");
//    innDiv.style.display='block';
//    
//    var OneImage = document.getElementById("onlyOneImage");
//    OneImage.style.display='none';
//    
//    var innerRightImage = document.getElementById("innerRightImage");
// innerRightImage.src = g_innerimagepath;
    
      var OneImage = document.getElementById("onlyOneImage");
    OneImage.style.display='block';
    
    var innDiv = document.getElementById("innerDiv");
    innDiv.style.display='none';
    
    var bigImage = document.getElementById("bigImg");
    bigImage.src = g_innerimagepath;
    bigImage.style.width=300;
    bigImage.style.height=190;
                                  
}

function showBackPage()
{
    var OneImage = document.getElementById("onlyOneImage");
    OneImage.style.display='block';
    
    var innDiv = document.getElementById("innerDiv");
    innDiv.style.display='none';
    
    var bigImage = document.getElementById("bigImg");
    bigImage.src = g_backimagepath;
    bigImage.style.width=150;
    bigImage.style.height=190;
}

//For Paging validation 
function ValidatePageTextBox(id,totalpage)
{
    txtBox = document.getElementById(id);
    if (txtBox.value.length < 1)
    {
        alert("Please Enter Page Number");
        return false;
    }
    for (var i = 0; i < txtBox.value.length; i++) // numeric?
    {
        var testChar = txtBox.value.charAt(i);
        if (testChar < "0" || testChar > "9")
        {
            alert("Invalid Page Number");
            return false;
        }
    }
    if(txtBox.value>totalpage)
    {
            alert("Please enter less than or equal to "+totalpage);
              return false;
    }
    return true;   
}

function ValidateEditTextBox(txtBox)
{
    
    if (txtBox.value.length < 1)
    {
        alert("Invalid conversion rate");
        return false;
    }
    for (var i = 0; i < txtBox.value.length; i++) // numeric?
    {
        var testChar = txtBox.value.charAt(i);
        if (testChar < "0" || testChar > "9"||testChar == ".")
        {
            alert("Invalid Page Number");
            return false;
        }
    }
    }

