﻿var arrDropDownVisibilityStatus = new Array();
function ShowBlocker()
{
    var intLoop;
    var blocker = document.getElementById("divMask");
    arrSelects = new Array();
    
    arrSelects = document.getElementsByTagName("SELECT");
    for (intLoop=0; intLoop < arrSelects.length; intLoop++)
    {
        arrDropDownVisibilityStatus[intLoop] = arrSelects[intLoop].style.visibility;
        arrSelects[intLoop].style.visibility = "hidden";
    }
    
    blocker.style.top = "0px";
    blocker.style.left = "0px";
    blocker.style.width = document.documentElement.clientWidth + "px";
    blocker.style.height = document.documentElement.scrollHeight + "px";
    blocker.style.display = "";
    blocker.style.opacity='.70';
	blocker.style.filter="alpha(opacity=70)";
}

function HideBlocker()
{
    var intLoop;
    var blocker = document.getElementById("divMask");
    arrSelects = new Array();
    
    arrSelects = document.getElementsByTagName("SELECT");
    for (intLoop=0; intLoop < arrSelects.length; intLoop++)
    {
        arrSelects[intLoop].style.visibility = arrDropDownVisibilityStatus[intLoop];
    }
    blocker.style.display = "none";
}


function ShowSelects(popUpId)
{
    var intLoop;
    var blocker = document.getElementById(popUpId);
    arrSelects = new Array();
    
    arrSelects = blocker.getElementsByTagName("SELECT");
    for (intLoop=0; intLoop < arrSelects.length; intLoop++)
    {
        arrSelects[intLoop].style.visibility = arrDropDownVisibilityStatus[intLoop];
    }
}

function Alert(Title, Message)
{
    ShowBlocker();
    //document.getElementById("spnTitle").innerHTML = Title;
    //document.getElementById("spnMessage").innerHTML = Message;
    
    document.getElementById("divAlert").style.visibility = "hidden";
    document.getElementById("divAlert").style.display = "";
    setPopUpPoistion("divAlert");
    getImageForPopup("divAlert");
    document.getElementById("divAlert").style.visibility = "visible";
        
    return false;
}

function getImageForPopup(popUpId)
{
    var imgsrc = document.getElementById("ctl00_ContentPlaceHolder1_imgProduct").src;
    var index = imgsrc.indexOf("Data/");
    imgsrc = imgsrc.slice(index);
    document.getElementById("imgPopup").src = imgsrc;
}

function CloseAlert()
{
    document.getElementById("divAlert").style.display = "none";
    HideBlocker();
}

function setPopUpPoistion(popUpId)
{
   var divHeight = 300;
   var divWidth = 200;
  
   if(parseInt(document.getElementById(popUpId).style.height) > 0)
   {
        divHeight = parseInt(document.getElementById(popUpId).style.height);
   }
   else if(parseInt(document.getElementById(popUpId).offsetHeight) > 0)
   {
        divHeight = parseInt(document.getElementById(popUpId).offsetHeight);
   }
        
   if(parseInt(document.getElementById(popUpId).style.width) > 0)
   {
        divWidth = parseInt(document.getElementById(popUpId).style.width);
   }
   else if(parseInt(document.getElementById(popUpId).offsetWidth) > 0)
   {
        divWidth = parseInt(document.getElementById(popUpId).offsetWidth);
   }

   document.getElementById(popUpId).style.top = ((screen.availHeight - divHeight)/2 + getScrollTop() - 70) + "px";
   
   document.getElementById(popUpId).style.left = ((screen.availWidth - divWidth)/2 + document.documentElement.scrollLeft) + "px";
}

function getScrollTop()
{
	var scrollTop;
	
	if(document.body.scrollTop == 0)
	{
	    scrollTop=document.documentElement.scrollTop;
	}
	else
	{
	    scrollTop=document.body.scrollTop;
	}
	return scrollTop;
}

function openmap(id){
var ancid=id+"anc";
document.getElementById("cntid").style.display="none";
document.getElementById("indiaid").style.display="none";
document.getElementById("indianepal").style.display="none";
document.getElementById(id).style.display="";
document.getElementById("indiaidanc").style.color="#535353";
document.getElementById("domesticid").style.color="#535353";
document.getElementById("indianepalanc").style.color="#535353";
document.getElementById(ancid).style.color="#EE1C23";
}
function openmaps(id){
var ancid=id+"anc";
document.getElementById("export").style.display="none";
document.getElementById("africaid").style.display="none";
document.getElementById("asiaid").style.display="none";
document.getElementById("europeid").style.display="none";
document.getElementById(id).style.display="";
document.getElementById("africaidanc").style.color="#535353";
document.getElementById("europeidanc").style.color="#535353";
document.getElementById("asiaidanc").style.color="#535353";
document.getElementById("exportid").style.color="#535353";
document.getElementById(ancid).style.color="#EE1C23";

}

function IncludeAnd(strErr)
{        
    var lastindex=0;        
    if(strErr.indexOf(",")>-1)
    {            
        lastindex=strErr.lastIndexOf(",") 
        var strcheckstringwithcoma="";
        var strcheckstringwithand="";
        strcheckstring=strErr.substring(lastindex,parseInt(strErr.length));
        strcheckstringwithand=strcheckstring.replace(","," And")
        strErr=strErr.replace(strcheckstring, strcheckstringwithand);
    }
    return strErr; 
} 

function ChkValidPhone(object)
{
    var myRegxp = /^(\+\d{1,2}\s\d{10})$|^(\+\d{1,2}\s\d{11})$|^(\d{3}-\d{8})$|^(\d{4}-\d{7})$|^(\d{3}(-|\s)\d{3}(-|\s)\d{4})$/;

    return myRegxp.test(object);
}

function GotoPreviousPage()
{
    if(history.length > 0)
    {
        window.history.back();
        return false;
    }
    //window.history.go(-1);
}

