﻿
/*************************************************/	
function ShowDialog(pagePath, width, height)
{                      
    window.document.body.scroll = 'no';
    //Open First Level Window (like Search Window);
    var winFirstLevel = radopen(pagePath, 'abc')
    if(width && height)
        winFirstLevel.SetSize(width, height);
        
    winFirstLevel.SetSize(600, 400);
    winFirstLevel.SetTitle('.: President of Pakistan :.');
    winFirstLevel.center();
    return false; 
}

function ShowImageDialog(pagePath, width, height)
{                      
    window.document.body.scroll = 'no';
    //Open First Level Window (like Search Window);
    var winFirstLevel = radopen(pagePath, 'abc')
    if(width && height)
        winFirstLevel.SetSize(width, height);
        
    winFirstLevel.SetSize(800, 600);
    winFirstLevel.SetTitle('.: President of Pakistan :.');
    winFirstLevel.center();
    return false; 
}

function OnRadWindowClose(sender,args)
{
    window.document.body.scroll = 'yes'; 
}

function CustomClose(postBackButton)
{
	
	if (navigator.userAgent.indexOf("MSIE") != -1)
	{			
		var a = window.dialogArguments;
		a[0].__doPostBack(postBackButton, '');
	}
	else
	{
		window.opener.__doPostBack(postBackButton, '');
	}
	window.close();
}

function addToFavorite(favTitle)
{
    if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4)) 
    {
        window.external.AddFavorite(location.href, unescape(favTitle));
    }
}
function ShowTooltip(tooltip)
{ 
 
    var hdiv= document.getElementById("preview_div"); 

//    hdiv.style.position=absolute;
//	hdiv.top=20px;
//	hdiv.right=20px;

  //  var html = "<img width='400px' height='500px' src='" + tooltip + "'/>";
    //hdiv.innerHTML = html;
   // alert(hdiv.innerHTML);
      
    //hdiv.style.display='block';
    
 }

function HideTooltip()
{
  var hdiv= document.getElementById("preview_div"); 
    hdiv.style.display="none";
}

function AutoCompleteDropDown (dropdownlist,caseSensitive) {
  // check the keypressBuffer attribute is defined on the dropdownlist
  var undefined; 
  caseSensitive =false;
  if (dropdownlist.keypressBuffer == undefined) { 
    dropdownlist.keypressBuffer = ''; 
  } 
  // get the key that was pressed 
  var key = String.fromCharCode(window.event.keyCode); 
  dropdownlist.keypressBuffer += key;
  if (!caseSensitive) {
    // convert buffer to lowercase
    dropdownlist.keypressBuffer = dropdownlist.keypressBuffer.toLowerCase();
  }
  // find if it is the start of any of the options 
  var optionsLength = dropdownlist.options.length; 
  for (var n=0; n < optionsLength; n++) { 
    var optionText = dropdownlist.options[n].text; 
    if (!caseSensitive) {
      optionText = optionText.toLowerCase();
    }
    if (optionText.indexOf(dropdownlist.keypressBuffer,0) == 0) { 
      dropdownlist.selectedIndex = n; 
      return false; // cancel the default behavior since 
                    // we have selected our own value 
    } 
  } 
  // reset initial key to be inline with default behavior 
  dropdownlist.keypressBuffer = key; 
  return true; // give default behavior 
} 
function AnyInput_KeyDown ( e, target ) 
	{ 
		if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) 
		{ 
			document.getElementById(target).focus();
			return false; 
		} 
			return true; 
	} 
	
function CalculateCharCount(webcontrol, charcount ) 
{ 
    if ( document.getElementById(webcontrol).value.length > charcount )
    {
        alert('Maximum Limit Ended');
        
        return false;
    }
    
    return true;
}

/*************************************************/	



/*************************************************/	
function getConfirm()
{
	return confirm("Are you sure to delete?");
}

function DenyDelete(text)
{
	alert(text);
	return false;
}

//*************************************************
// Open Popup window
//*************************************************
function openWindow(pageURL, pageHeight, pageWidth) {

	
	if (navigator.userAgent.indexOf("MSIE") != -1){
		var a = new Array();
		a[0] = window;
		var dlgOptions = "dialogHeight: " + pageHeight + "px; dialogWidth: " + pageWidth + "px ; center: Yes; edge: Sunken; help: No; resizable: No; scroll: Yes; status: No;";
		window.open(pageURL, a, dlgOptions);
	}else{
		var topPos = (screen.height - pageHeight.substring(0,pageHeight.length-2)) / 2;
		var leftPos = (screen.width - pageWidth.substring(0,pageWidth.length-2)) / 2;
		var windowOptions = "height=" + pageHeight + ",width=" + pageWidth + ",directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,modal=yes,top=" + topPos + ",left=" + leftPos;
		window.open(pageURL,"window",windowOptions);
	}
	return false;
};

function openNormalWindow(pageURL, pageHeight, pageWidth) {

	if (navigator.userAgent.indexOf("MSIE") != -1)
	{
	    var topPos = 50;
		var leftPos = 100;
		
		var windowOptions = "height=" + pageHeight + ",width=" + pageWidth + ",directories=no,location=no,menubar=yes,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=no,modal=no,top=" + topPos + ",left=" + leftPos;
		window.open(pageURL,"window",windowOptions);
	}
	else
	{
		var topPos = (screen.height - pageHeight.substring(0,pageHeight.length-2)) / 2;
		var leftPos = (screen.width - pageWidth.substring(0,pageWidth.length-2)) / 2;
		
		var windowOptions = "height=" + pageHeight + ",width=" + pageWidth + ",directories=no,location=no,menubar=yes,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=no,modal=no,top=" + topPos + ",left=" + leftPos;
		window.open(pageURL,"window",windowOptions);
	}
	return false;
};


function Anthem_PreCallBack(  ) 
{
    var loading = document.createElement("div");
    loading.id = "loading";
   /* loading.style.color = "black";
    loading.style.backgroundColor = "#FFF999";
    loading.style.paddingLeft = "10px";
    loading.style.paddingRight = "10px";
    loading.style.position = "absolute";
    loading.style.right = "10px";
    loading.style.top = "10px";
    loading.style.zIndex = "9999";
    loading.style.borderwidth = "1px";
    loading.style.bordercolor= "#EDE672";
    loading.style.width= "100px";
    loading.style.height= "20px";
    loading.style.height= "20px";
    */
   
    loading.className = "loadingdiv";
    
    //loading.style.font="arial";EDE672
    
    
   /* var html = "<table cellpadding= 5px cellspacing= 5px border=0px><tr><td>Working...<tr><td>";
    html += "<tr><td><img src='../images/loading.gif' + "/></td></tr></table>";
    loading.innerHTML = html;
    
    loading.innerHTML = "Working on your request...";
    */
    document.body.appendChild(loading);
}
function Anthem_PostCallBack() 
{
   	var loading = document.getElementById("loading");
	document.body.removeChild(loading);
}


function doKeypress(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }
}
// Cancel default behavior
function doBeforePaste(control){
    maxLength = control.attributes["maxLength"].value;
     if(maxLength)
     {
          event.returnValue = false;
     }
}
// Cancel default behavior and create a new paste routine
function doPaste(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}



//News Rotator
////////////////////////////////////////////////////////////////////////

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

////////////////////////////////////////////////////////////////////////