﻿/*!
 * JavaScript File
 * Created By: umer Qureshi
 * Date: 28 June 2010
 * Modify By Ayaz Tariq 2010
 */


var popUp=null;
var popUpParent=null;
var contentFrame=null;
var divFrame = null;
function OpenPopup(width,height,popUpElement,parent,frame,src,headingElement,heading,showCloseButton)
{
    popUp=document.getElementById(popUpElement);
    popUpParent=document.getElementById(parent);
    contentFrame=document.getElementById(frame);
    divFrame = document.getElementById('divFrame');
   // popUp.style.width=width + "px";
   // popUp.style.height=height +  "px";
    SetDivLocation(width,height,popUp);
    popUp.style.display="block";

       if (src!="")
       {
            contentFrame.src=src;
            contentFrame.width=width-20;
            contentFrame.height=height-90;
            divFrame.style.width=width -20 + "px";
            divFrame.style.height=height-90 + "px";
       }
    document.getElementById(headingElement).innerHTML=heading;
    
       if (showCloseButton!=true)
       {
            document.getElementById('btnClose').style.visibility="hidden";
       }
       else
       {
            document.getElementById('btnClose').style.visibility="visible";
       }
    
}
function ClosePopup()
{
    if (popUp!=null)
    {   popUp.style.display="none";
        popUpParent=null;
	//contentFrame.src=getBaseURL()+'general/Loading.aspx';
	contentFrame.src='http://www.yadig.com/general/Loading.aspx';
        contentFrame=null;
        popUp=null;
       
    }
}

function getBaseURL() {
        var url = location.href;  // entire url including querystring - also: window.location.href;
        var baseURL = url.substring(0, url.indexOf('/', 14));
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);
        return baseLocalUrl + "/";

}

function SetDivLocation(w, h,div)
{  
  var LeftPosition=0;
  var TopPosition=0;
  LeftPosition=(screen.width)?(screen.width-w)/2:100;
  TopPosition=(screen.height)?(((screen.height-h)/2)):100;

  if ((TopPosition+h)>=screen.height - 250)
  { 
    TopPosition = TopPosition-(h/4);
  }
  else
  { 
 
    TopPosition = TopPosition-(h/2);
  }
  div.style.left=LeftPosition + "px";
  div.style.top=TopPosition + "px";
}
function SetHeading(txt)
{
 if (txt !=null)
 {
    var head=document.getElementById('lblHeading');
    if(head!=null)
    head.innerHTML=txt;
 }
}

function setSize(width,height)
{
    if(contentFrame && divFrame)
    {
       // contentFrame.width=width;
       // divFrame.style.width=width + "px";
       // divFrame.style.height=height +"px";  
        
        contentFrame.width=width;
        contentFrame.height=height;
        divFrame.style.width=width + "px";
        divFrame.style.height=height+ "px";
            
        SetDivLocation(width,height,popUp);
    }
}