var ie = document.all;

function pressenterkey(evt,id)
{
    //alert(evt);
    // alert(id);
	  
    var key = (evt.which) ? evt.which : event.keyCode
    if(key==13)
    {
        document.getElementById(id).focus();
    }
}


function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        xmlHttp=new XMLHttpRequest();
    }
    catch(e)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}
/*********** Ajax Loader New *************/
function ProcessLoader()
{
    document.getElementById('dvprocessing').style.display = '';
}

function ProcessLoaderNew()
{
    document.getElementById('overlay').style.display = 'block';
    document.getElementById('loader').style.display = 'block';
    document.getElementById('gridbody').clientWidth;
    document.getElementById('overlay').style.width = document.getElementById('gridbody').clientWidth;
    document.getElementById('overlay').style.height = document.getElementById('gridbody').clientHeight;
    document.getElementById('loader').style.width = document.getElementById('gridbody').clientWidth;
    document.getElementById('loader').style.height = document.getElementById('gridbody').clientHeight;
    
}

/****************************************/
function CalculateTop(Height)
{
    var ScrollTop=document.body.scrollTop;
    if(ScrollTop==0)
    {
        if(window.pageYOffset)
            ScrollTop=window.pageYOffset;
        else
            ScrollTop=(document.body.parentElement)?document.body.parentElement.scrollTop:0;
    }

    var BodyHeight=document.body.clientHeight;

    if(BodyHeight==0)
    {
        BodyHeight=window.innerHeight;
    }
    if(BodyHeight==0)
    {
        BodyHeight=document.documentElement.clientHeight
    }

    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' )
    {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    }
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    var FinalTop=((myHeight-Height)/2)+ScrollTop;
    return FinalTop;
}
function CalculateLeft(Weight)
{
    var ScrollLeft=document.body.scrollLeft;

    if(ScrollLeft==0)
    {
        if(window.pageXOffset)
            ScrollLeft=window.pageXOffset;
        else
            ScrollLeft=(document.body.parentElement)?document.body.parentElement.scrollLeft:0;
    }

    var BodyWeight=document.documentElement.clientWidth;

    if(BodyWeight==0)
    {
        BodyWeight=document.body.clientWidth;
    }

    var FinalLeft=(BodyWeight+ScrollLeft-Weight)/2;

    return FinalLeft;
}

/***************** Setting the Dimmer while loading *********************/
function SetBackground()
{
	document.getElementById('dimmer').style.width  = GetBodyWidth();
    document.getElementById('dimmer').style.height = GetBodyHeight();
    document.getElementById('dimmer').style.visibility="visible";
    document.getElementById('dvprocessing').style.display = '';
}
function SetBackgroundNew()
{
	document.getElementById('dimmer').style.width  = GetBodyWidth();
    document.getElementById('dimmer').style.height = GetBodyHeight();
    document.getElementById('dimmer').style.visibility="visible";
}
function UnsetBackground()
{
    document.getElementById('dimmer').style.width=0;
    document.getElementById('dimmer').style.height=0;
    document.getElementById('dimmer').style.visibility="";
    document.getElementById('dvprocessing').style.display = 'none';
    //unhideIframe();
}
function unhideIframe()
{
    if(ie)
    {

        var theIframe=document.getElementById("fadeboxiframe")
        var theDiv=document.getElementById("dvregisterfrm");
        if((theIframe)&&(theDiv))
        {
            theIframe.style.width=theDiv.offsetWidth+'px';
            theIframe.style.height=theDiv.offsetHeight+'px';
            theIframe.style.top=theDiv.offsetTop+'px';
            theIframe.style.left=theDiv.offsetLeft+'px';
            theIframe.style.display='';
        }
    }
}

function close_popup(e){
    var unicode=e.keyCode? e.keyCode : e.charCode
    if (unicode == '27')
    {
           styledPopupClose();
    }
}

function styledPopupClose()
{
   location.reload( true );
	
	
  
}
function reloadlist()
{

    location.reload( true );

}

function hideIframe()
{
	
    if(ie)
    {
        var theIframe=document.getElementById("fadeboxiframe")
		
        if(theIframe!=null)
        {
            theIframe.style.display="none";
        }
    }
}


/***********************************************************************/

function GetBodyWidth()
{
    var theWidth=0;
    if(document.body)
    {
        theWidth=document.body.clientWidth;
    }
    else if(document.documentElement&&document.documentElement.clientWidth)
    {
        theWidth=document.documentElement.clientWidth;
    }
    else if(window.innerWidth)
    {
        theWidth=window.innerWidth;
    }

    theWidth=theWidth-80;

    return theWidth+ "px";
}

function GetBodyHeight()
{		
    var theHeight1=0;
    var theHeight2=0;
    var theHeight3=0;
	
    //alert(window.innerHeight);
    if(window.innerHeight)
    {
        theHeight1=window.innerHeight;
    }
	
    if(document.documentElement&&document.documentElement.clientHeight)
    {
        //alert(document.documentElement.clientHeight);
        theHeight2 = document.documentElement.clientHeight;
    }
    /*if(document.body)
	 {
       theHeight3=document.body.clientHeight;
		if(isMozilla)
		{   
		  var theHeight4 = 0;
		}
		else
		{
			theHeight4=document.body.scrollHeight;
		}
	}*/
    FinalHeight=Math.max(theHeight1,theHeight2,theHeight3);
    FinalHeight=FinalHeight-70;
    return FinalHeight+ "px";
}


// Ajax Check if common type exists
// Implemented in Add Module Menu Page


function loginreminderpopup()
{
    xmlHttp=GetXmlHttpObject()

    if(xmlHttp==null)
    {
        alert("Browser does not support HTTP Request")
        return
    }

    var url="howitwork.php";
   // alert(url);
    xmlHttp.onreadystatechange= stateChangeloginpopup
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}



function stateChangeloginpopup()
{
    SetBackground();
    
    if(xmlHttp.readyState==1)
    {
        ProcessLoader();
    }
    
    if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
    {
        var popuph = 316;
        var popupw = 560;
        var popuph2 = popuph/2;
        var popupw2 = popupw/2;
        var winW = screen.width;
        var winH = screen.height;

        //alert(xmlHttp.responseText);

        if (parseInt(navigator.appVersion)>3) {

            if (navigator.appName=="Netscape") {
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            }

            if (navigator.appName.indexOf("Microsoft")!=-1) {
                winW = document.body.clientWidth;
                winH = document.body.offsetHeight;
            }
        }
        
        var sh = winH;
        var sw = winW;
        var sh2 = sh/2;
        var sw2 = sw/2;
        var topf1 = sh2 - popuph;
        var leftf1 = sw2 - popupw2;

        document.getElementById('dvprocessing').style.display='none';
        document.getElementById('dvregisterfrm').style.display='';
        document.getElementById('dvregisterfrm').style.top=CalculateTop('611')+ "px";
		document.getElementById('dvregisterfrm').style.width="646px";
        document.getElementById('dvregisterfrm').style.left=leftf1 + "px";
        document.getElementById("dvregisterfrm").innerHTML=xmlHttp.responseText;
		
		
    //unhideIframe();
    }
}


///////////// End of Vendor Rejected popup ////////////////
