﻿function DIV_onmouseover(cid)
{
var z=document.getElementById(cid);
z.className="MenuHover";
}
function DIV_onmouseout(cid) 
{
var z=document.getElementById(cid);
z.className="MenuBlur";
}

var myWidth = 0, myHeight = 0,TopScroll=0,BottomScroll=0, myselvalue=0; 
function NepaliSocietyPartialDiv(url,title)
{
CheckElements();
document.getElementById("CancelButton").style.display='none';
document.getElementById("OkButton").style.display='inline';
document.getElementById("OkButton").value='Ok';
document.getElementById("AlertText").innerHTML='Loading ..... .. '; 
document.getElementById("AlertHeaderDiv").innerHTML = "<img src=\"/resources/icons/win_close_icon.gif\" style=\"float:right;cursor:pointer;\" onclick=\"ClickCancel();\">";
if(title!=null)
{document.getElementById("AlertHeaderDiv").innerHTML +="<b>"+title+"</b>";}
else
{
document.getElementById("AlertHeaderDiv").innerHTML +="<b>NepaliSociety Alert</b>";
}
WindowSize();
document.getElementById("ContentDivContainer").style.left= (myWidth/2)-125 + "px";
document.getElementById("ContentDivContainer").style.top = TopScroll + (myHeight/2)-60 + "px";
document.getElementById("NepaliSocietyAlertBox").style.display ='block'; 
document.getElementById("TransparentDivContainer").style.top = TopScroll; 
document.getElementById("OkButton").style.display='none';
PartialPageUpdate('/pages/searchlist.aspx?as=4&q=d','AlertContentDiv');
}

function NepaliSocietyCustomPartialDiv(url,title,height,width)
{
CheckElements();
document.getElementById("CancelButton").style.display='none';
document.getElementById("AlertText").innerHTML='Loading ..... .. '; 
document.getElementById("AlertHeaderDiv").innerHTML = "<img src=\"/resources/icons/win_close_icon.gif\" style=\"float:right;cursor:pointer;\" onclick=\"ClickCancelErase();\">";
if(title!=null)
{document.getElementById("AlertHeaderDiv").innerHTML +="<b>"+title+"</b>";}
else
{
document.getElementById("AlertHeaderDiv").innerHTML +="<b>NepaliSociety Alert</b>";
}
WindowSize();
document.getElementById("ContentDivContainer").style.left= (myWidth/2)-(width/2) + "px";
document.getElementById("ContentDivContainer").style.top = TopScroll + (myHeight/2)-(height/2) + "px";
document.getElementById("AlertHeaderDiv").style.width=width + 'px';
document.getElementById("AlertContentDiv").style.height=height + 'px';
document.getElementById("AlertContentDiv").style.width=width + 'px';
document.getElementById("NepaliSocietyAlertBox").style.display ='block'; 
document.getElementById("TransparentDivContainer").style.top = TopScroll; 
document.getElementById("OkButton").style.display='none';
PartialPageUpdate(url,'AlertContentDiv');
}

function NepaliSocietyCustomInputBox(AlertText,FunctionToHit,FalseCaseFunction,width,height,title)
{
    CheckElements();
    document.getElementById("AlertHeaderDiv").style.width=width;
    document.getElementById("AlertContentDiv").style.width=width;
    document.getElementById("AlertContentDiv").style.height="100%";
    document.getElementById("CancelButton").style.display='inline';
    document.getElementById("OkButton").style.display='inline';
    document.getElementById("OkButton").value='OK';
    document.getElementById("CancelButton").value='Cancel';
    document.getElementById("AlertText").innerHTML=AlertText + "<br>" + "<textarea id=CustomInputBox  />"; 
    /*  */
    
    document.getElementById("CustomInputBox").style.height=height;
    document.getElementById("CustomInputBox").style.width='95%';
    
    document.getElementById("AlertHeaderDiv").innerHTML = "<img src=\"/resources/icons/win_close_icon.gif\" style=\"float:right;cursor:pointer;\" onclick=\"ClickCancel();\">";
    if(title==null)
    {
    document.getElementById("AlertHeaderDiv").innerHTML +="<b>NepaliSociety Confirm</b>"; 
    }else
    {
    document.getElementById("AlertHeaderDiv").innerHTML +="<b>"+ title +"</b>"; 
    }
    try
    {
    WindowSize();    
    document.getElementById("ContentDivContainer").style.left= (myWidth/2)-125 + "px";
    document.getElementById("ContentDivContainer").style.top = TopScroll + (myHeight/2)-200 + "px";
    document.getElementById("NepaliSocietyAlertBox").style.display ='block'; 
    document.getElementById("TransparentDivContainer").style.top = TopScroll;             
    var param=FunctionToHit.split('(',')');    
    var test1=FunctionToHit.split('(');
    var fns=test1[0];
    var test2=test1[1].split(')');    
    var fntrue = new Function("term", "return " + fns + "(term)");        
    document.getElementById("OkButton").onclick= function (){
                                                             if(document.getElementById("CustomInputBox").value.length>0)
                                                             {
                                                             ClickOk();    
                                                             var inputtext=document.getElementById("CustomInputBox").value;                                                         
                                                             fntrue(inputtext);
                                                             }
                                                             }; 
    }
    catch(err)
    {
    
    }
    try
    {
        var test3=FalseCaseFunction.split('(');
        var test4=test3[1].split(')');            
        var fnfalse = new Function("term", "return " + FalseCaseFunction + "(term);");
        document.getElementById("CancelButton").onclick= function (){        
        ClickCancel();        
        } 
    }
    catch(err)
    {
        document.getElementById("CancelButton").onclick=ClickCancel;
    }
}

function NepaliSocietyAlert(AlertText,title)
{
        CheckElements();
        document.getElementById("CancelButton").style.display='none';
        document.getElementById("OkButton").style.display='inline';
        document.getElementById("OkButton").value='Ok';
        document.getElementById("AlertText").innerHTML=AlertText; 
        document.getElementById("AlertHeaderDiv").innerHTML = "<img src=\"/resources/icons/win_close_icon.gif\" style=\"float:right;cursor:pointer;\" onclick=\"ClickCancel();\">";
        if(title!=null)
        {
        document.getElementById("AlertHeaderDiv").innerHTML +="<b>"+title+"</b>";
        }
        else
        {document.getElementById("AlertHeaderDiv").innerHTML +="<b>NepaliSociety Alert</b>";
        }
        WindowSize();
        document.getElementById("ContentDivContainer").style.left= (myWidth/2)-125 + "px";
        document.getElementById("ContentDivContainer").style.top = TopScroll + (myHeight/2)-60 + "px";
        document.getElementById("NepaliSocietyAlertBox").style.display ='block'; 
        document.getElementById("TransparentDivContainer").style.top = TopScroll; 
        document.getElementById("OkButton").onclick=ClickOk;
}


function CheckElements()
{
        if(document.getElementById("NepaliSocietyAlertBox")==null)
        {
        DesignElements();
        } 
}

function NepaliSocietyConfirm(AlertText,FunctionToHit,FalseCaseFunction)
{
    CheckElements();
    document.getElementById("CancelButton").style.display='inline';
    document.getElementById("OkButton").style.display='inline';
    document.getElementById("OkButton").value='Yes';
    document.getElementById("CancelButton").value='No';
    document.getElementById("AlertText").innerHTML=AlertText; 
    document.getElementById("AlertHeaderDiv").innerHTML = "<img src=\"/resources/icons/win_close_icon.gif\" style=\"float:right;cursor:pointer;\" onclick=\"ClickCancel();\">";
    document.getElementById("AlertHeaderDiv").innerHTML +="<b>Confirm</b>"; 
    try
    {
    WindowSize();    
    document.getElementById("ContentDivContainer").style.left= (myWidth/2)-125 + "px";
    document.getElementById("ContentDivContainer").style.top = TopScroll + (myHeight/2)-60 + "px";
    document.getElementById("NepaliSocietyAlertBox").style.display ='block'; 
    document.getElementById("TransparentDivContainer").style.top = TopScroll;             
    var param=FunctionToHit.split('(',')');    
    var test1=FunctionToHit.split('(');
    var test2=test1[1].split(')');    
    var fntrue = new Function("term", "return " + FunctionToHit);        
    document.getElementById("OkButton").onclick= function (){
                                                             ClickOk();                                                             
                                                             fntrue(test2[0]);
                                                             }; 
    }
    catch(err)
    {
    
    }
    try
    {
        var test3=FalseCaseFunction.split('(');
        var test4=test3[1].split(')');            
        var fnfalse = new Function("term", "return " + FalseCaseFunction + "(term);");
        document.getElementById("CancelButton").onclick= function (){        
        ClickCancel();             
        } 
    }
    catch(err)
    {
        document.getElementById("CancelButton").onclick=ClickCancel;
    }

}

function NepaliSocietyConfirmRedirect(AlertText,url,FalseCaseFunction)
{
        CheckElements();
        document.getElementById("CancelButton").style.display='inline';
        document.getElementById("OkButton").style.display='inline';
        document.getElementById("OkButton").value='Yes';
        document.getElementById("CancelButton").value='No';
        document.getElementById("AlertText").innerHTML=AlertText; 
        document.getElementById("AlertHeaderDiv").innerHTML="NepaliSociety Confirm"; 
        WindowSize();
        document.getElementById("ContentDivContainer").style.left= (myWidth/2)-125 + "px";
        document.getElementById("ContentDivContainer").style.top = TopScroll + (myHeight/2)-60 + "px";
        document.getElementById("NepaliSocietyAlertBox").style.display ='block'; 
        document.getElementById("TransparentDivContainer").style.top = TopScroll; 
        document.getElementById("OkButton").onclick= function(){window.open(url,"_top");}; 
        try{
        var param2=FalseCaseFunction.split('(',')');
        var fnfalse = new Function("term", "return " + FalseCaseFunction + "(term);");
        document.getElementById("CancelButton").onclick= function(){ClickCancel();fnfalse(param2[1]);}; 
        }catch(e)
        {
        document.getElementById("CancelButton").onclick=ClickCancel;
        }
}

function DesignElements()
{
        var NepaliSocietyAlertBoxe = document.createElement("div");
        NepaliSocietyAlertBoxe.setAttribute("id","NepaliSocietyAlertBox");
        NepaliSocietyAlertBoxe.style.display= 'none';

        var TransparentDivContainere = document.createElement("div");
        TransparentDivContainere.setAttribute("id","TransparentDivContainer");
        NepaliSocietyAlertBoxe.appendChild(TransparentDivContainere);

        var ContentDivContainere = document.createElement("div");
        ContentDivContainere.setAttribute("id","ContentDivContainer");
        ContentDivContainere.setAttribute("align","center");
        ContentDivContainere.setAttribute("valign","middle");

        NepaliSocietyAlertBoxe.appendChild(ContentDivContainere);

        var AlertHeaderDive = document.createElement("div");
        AlertHeaderDive.setAttribute("id","AlertHeaderDiv");
        ContentDivContainere.appendChild(AlertHeaderDive);

        var AlertContentDive = document.createElement("div");
        AlertContentDive.setAttribute("id","AlertContentDiv");
        ContentDivContainere.appendChild(AlertContentDive);

        var AlertTexte = document.createElement("div");
        AlertTexte.setAttribute("id","AlertText");
        AlertContentDive.appendChild(AlertTexte);

        var ButtonContainerDive = document.createElement("div");
        ButtonContainerDive.setAttribute("id","ButtonContainerDiv");
        ButtonContainerDive.innerHTML="<br><input id=\"OkButton\" class=\"ConfirmButtons\" type=\"button\" value=\"Ok\" />&nbsp;&nbsp;<input id=\"CancelButton\" class=\"ConfirmButtons\" type=\"button\" value=\"Cancel\" />";
        AlertContentDive.appendChild(ButtonContainerDive); 
        document.body.appendChild(NepaliSocietyAlertBoxe); 
}

function ClickOk()
{
        document.getElementById("NepaliSocietyAlertBox").style.display ='none'; 
}
function ClickCancel()
{
        document.getElementById("NepaliSocietyAlertBox").style.display ='none';
}
function ClickCancelErase()
{
        var NepaliSocietyAlertBoxe= document.getElementById("NepaliSocietyAlertBox");
        document.body.removeChild(NepaliSocietyAlertBoxe); 
}
function WindowSize() 
{ 
        if( typeof( window.innerWidth ) == 'number' ) {
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
        }
        else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
        {
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
        }
        else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
        {
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
        } 

        if( typeof( window.pageYOffset ) == 'number' ) 
        {
        TopScroll = window.pageYOffset; 
        }
        else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        TopScroll = document.body.scrollTop; 
        }
        else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
        { 
        TopScroll = document.documentElement.scrollTop; 
        }
}

function PartialPageUpdate(url,displaydiv)
{
        var xmlhttp=null;
        if (window.XMLHttpRequest)
        {
        xmlhttp=new XMLHttpRequest();
        }
        else if (window.ActiveXObject)
        {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (xmlhttp!=null)
        { 
        xmlhttp.onreadystatechange = function()
        { 
        if(xmlhttp.readyState == 4)
        {
        if(xmlhttp.status == 200) 
        {
        var response=xmlhttp.responseText;
        if(response.length>0)
        {
        document.getElementById(displaydiv).innerHTML=response;
        } 

        }
        }
        }
        xmlhttp.open("GET",url,true);
        xmlhttp.send(null);
        }
}

function SilentFunctionUpdate(url)
{
        var xmlhttp=null;
        if (window.XMLHttpRequest)
        {
        xmlhttp=new XMLHttpRequest();
        }
        else if (window.ActiveXObject)
        {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (xmlhttp!=null)
        { 
        xmlhttp.onreadystatechange = function()
        { 
        if(xmlhttp.readyState == 4)
        {
        if(xmlhttp.status == 200) 
        {
        var response=xmlhttp.responseText;
        if(response.length>0)
        {
        NepaliSocietyAlert(response,'Information');
        } 

        }
        }
        }
        xmlhttp.open("GET",url,true);
        xmlhttp.send(null);
        }
}


function PartialPageUpdateSync(url,displaydiv,funct)
{
var fnfunct = new Function("term", "return " + funct + "(term);");
var xmlhttp=null;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{ 
xmlhttp.onreadystatechange = function()
{ 
if(xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200) 
{
var response=xmlhttp.responseText;
if(response.length>0)
{
document.getElementById(displaydiv).innerHTML=response;
fnfunct();
}
}
}
}
xmlhttp.open("GET",url,false);
xmlhttp.send(null);
}
}

 
function SilentASyncUpdate(url)
{
var xmlhttp=null;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{ 
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
}
function SilentASyncUpdatePost(url,formsend)
{
var xmlhttp=null;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var today = new Date();
url=url + '&nocache=' + today.valueOf();
if (xmlhttp!=null)
{ 
xmlhttp.open("Post",url,true);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send(formsend);
}
}

function SilentSyncUpdatePost(url,formsend)
{
var xmlhttp=null;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var today = new Date();
url=url + '&nocache=' + today.valueOf();
if (xmlhttp!=null)
{ 
xmlhttp.open("Post",url,false);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send(formsend);
}
}

function follow()
{
NepaliSocietyConfirm("do you want to click yes or no?","NepaliSocietyAlert('Wow Worked.. you click ok.')","NepaliSocietyAlert('hmmm.. guess you clicked No..')");
}

function ChangeLang(lang)
{
createCookie('Lang',lang,40);    
window.top.location="http://www.nepalisociety.com/communityportal/Society_Page.aspx?i=10&g=0";
    //window.top.location.reload();
    
}
////////////////////////////////////////
function createCookie(name,value,days) 
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+escape(value)+expires+"; path=/;";
	// + baseDomainString()
;
}

function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
	}
	return null;
}

function eraseCookie(name) 
{
	createCookie(name,"",-1);
}


function baseDomainString(){
  e = document.domain.split(/\./);
  if(e.length > 1) {
    return("domain=" + e[e.length-2] + "." +  e[e.length-1]) + ";"  ;
  }else{
    return("");
  }
}

