﻿var arCustmClsMsg=new Array()
{
        arCustmClsMsg.push("Userid/Password does not match.");
        arCustmClsMsg.push("Operation could not be completed.Please contact support if problem persists.");
        arCustmClsMsg.push("«P1» is «P2».");
        arCustmClsMsg.push("More than «p1» groups are not allowed by the system.");
        arCustmClsMsg.push("«p1» successfully «p2».");
        arCustmClsMsg.push("No «p1» found with matching criteria.");
        arCustmClsMsg.push("«p1» has already been «p2».");
        arCustmClsMsg.push("«p1» does not exist.");
        arCustmClsMsg.push("Your access has been blocked.Please contact your admin.");
        arCustmClsMsg.push("Domain does not match.Please contact your admin.");
        arCustmClsMsg.push("Please ask your admin to provide you with some roles.");
        arCustmClsMsg.push("New password cannot be same as old password.");
        arCustmClsMsg.push("Old password does not match the password supplied.");
        arCustmClsMsg.push("New password does not match the password supplied in confirm password box.");
        arCustmClsMsg.push("Domain does not exist.");
        arCustmClsMsg.push("Unable to reach domain. Please try after sometime.");
        arCustmClsMsg.push("Invalid Request.");
        arCustmClsMsg.push("Invalid Command.");
        arCustmClsMsg.push("Invalid User.");
        arCustmClsMsg.push("You don't have sufficient credits.");
        arCustmClsMsg.push("Exceed the topup size.");
        arCustmClsMsg.push("Due to some problem unable to proccess the request. Please try again later");
        arCustmClsMsg.push("Edit on two topups is not possible");
        arCustmClsMsg.push("Credit allocation has been «p1» successfully");
        arCustmClsMsg.push("No credits have been allocated to this user.");
        arCustmClsMsg.push("«p1» successfully.");
        arCustmClsMsg.push("«p1» already exists.");
        arCustmClsMsg.push("User has been blocked.");
        arCustmClsMsg.push("«p1» has been deleted.");
        arCustmClsMsg.push("Account has been expire.");
        arCustmClsMsg.push("Recipients in excess of 100000 are not allowed in a single upload.");
        arCustmClsMsg.push("File reading error.");
        arCustmClsMsg.push("User created successfully but mail could not be sent.Please inform the user manually and contact support if problem persists");
        arCustmClsMsg.push("For existing credit value rates can't be different.");
        arCustmClsMsg.push("You are currently not allowed to «p1» this «p2».");
        arCustmClsMsg.push("Sorry! you can't schedule this broadcast after your validity.");
        arCustmClsMsg.push("Sorry! Your account has been blocked by admin.");
        arCustmClsMsg.push("«p1» credits will be deducted when the user pushes one «p2» message. . Are You sure you want to proceed.");
        arCustmClsMsg.push("«p1» credits will be deducted when the user pushes one National message & «p2» credits will be deducted when the user sends one International Message. Are You sure you want to proceed.");
        arCustmClsMsg.push("A broadcast is already in progress.Please try after some time.");
        arCustmClsMsg.push("This message will be sent «P1» in number of sms.");
        arCustmClsMsg.push("Your mobile number already registered. Please choose another one.");
        arCustmClsMsg.push("please enter the correct verification code.");
        arCustmClsMsg.push("You will shortly receive the verification code as SMS on your mobile.");
        arCustmClsMsg.push("There is some connectivity issue. Please try after sometime. Inconvenience regretted.");
        arCustmClsMsg.push("Your registration is successful.");
        arCustmClsMsg.push("We could not find the USER ID Please check your entry to make sure you have spelled your ID correctly.");
        arCustmClsMsg.push("Message sent successfully.");
        arCustmClsMsg.push("There is some connectivity problem. Please try after some time.");
        arCustmClsMsg.push("Your current session has expired.Please re-login.");
        arCustmClsMsg.push("«p1» Credit revoked from «p2» successfully");
        arCustmClsMsg.push("We are facing temporary problems.Please try after some time and contact support if problem persists.");
        arCustmClsMsg.push("The alert has been saved");
        arCustmClsMsg.push("Please select the correct file format. Your file format does not match with the existing file.");
        arCustmClsMsg.push("The alert has been edited and saved successfully.");
        arCustmClsMsg.push("The alert is suspended and is saved successfully.");
        arCustmClsMsg.push("The time can only be greater than the current time.");
}

	var reqMode="";
	var flgLogin=false;
	var pageReqFrom="";
	function setLoginFlg()
	{
	    flgLogin=true;
	}
	function setPageReqFrom(pgReqFrom)
	{
	    pageReqFrom=pgReqFrom;
	}
	function ReSetLoginFlg()
	{
	    flgLogin=false;
	}
	function DoLogin()
	{   
	if(flgLogin== false)
	{
	    return false;
	}
	    var uid="",pwd="";
	    uid=document.getElementById("txtUid").value;
	    pwd=document.getElementById("txtPwd").value;
	    if(Alltrim(uid)=="")
        {
            alert("user id can't be left blank");
            return false;
        }
        if(uid.length<5||uid.length>14)
        {
            alert("User id should be between 5 to 14 characters only.");
            return false;
        }
        var CharCount;
        var AscVal;
        var SpecialAllowedChars="";
        for(CharCount=0;CharCount<uid.length;CharCount++)
        {
            if(SpecialAllowedChars.indexOf(uid.charAt(CharCount))>=0) continue;
            AscVal=uid.charCodeAt(CharCount);
            ErrorOccured=!(((AscVal>=48)&&(AscVal<=57))||((AscVal>=65)&&(AscVal<=90))||((AscVal>=97)&&(AscVal<=122)))
            if(ErrorOccured==true)
            {
                alert("User id contains certain illegal characters.");
                document.getElementById("txtUid").focus();
                return false;
            }
        }
        if(Alltrim(pwd)=="")
        {
            alert("Password can't be left blank");
            return false;
        }
        if(pwd.length<6||pwd.length>20)
        {
            alert("Password should be between 6 to 20 characters only.");
            return false;
        }
        var HasChar=false;
        var HasNumber=false;
        for(a=0;((a<pwd.length)&&((HasNumber==false)||(HasChar==false)));HasChar=(HasChar==false)?(((pwd.charCodeAt(a)>=65)&&(pwd.charCodeAt(a)<=90))||((pwd.charCodeAt(a)>=97)&&(pwd.charCodeAt(a)<=122)))?true:false:HasChar,HasNumber=(HasNumber==false)?((pwd.charCodeAt(a)>=48)&&(pwd.charCodeAt(a)<=57))? true:false:HasNumber, a++);
        ErrorOccured=((HasNumber==false)||(HasChar==false));
        if(ErrorOccured==true)
        {
                alert("Password must be alphanumeric.");
                document.getElementById("txtPwd").focus();
                return false;
        }
        
	}
	
	function HandleResponse(Response)
	{
	    if(reqMode!="L")
	    {
	        if(reqMode=="SS")
	        {
	            HandleResponseTestSMS(Response);
	        }
	        else
	        {
	            HandleResponse1(Response);
	        }
	        return false;
	    }
	    document.getElementById("signin_menu").style.visibility="visible";
	    if((Response=="-14")||(Response=="-15"))
	    {
            HideProgressbar("modalPage");
            ShowFlash(arCustmClsMsg[2],"");
	    }
	    else
	    {//alert(Response);
	        switch(Response)
	        {
	            case "-1"://UserId/Password Mismatch.
	                 HideProgressbar("modalPage");
	                 ShowFlash(arCustmClsMsg[0],"");
	                 break;
	            case "-2"://User Has Been Blocked.
	                HideProgressbar("modalPage");
	                ShowFlash(arCustmClsMsg[8],"");
	                break;
	            case "-4"://Domain Mismatch.
	                HideProgressbar("modalPage");
	                ShowFlash(arCustmClsMsg[9],"");
	                break;
	            
	            case "-6"://No Roles Assigned.
	                HideProgressbar("modalPage");
	                ShowFlash(arCustmClsMsg[10],"");
	                break;
	            case "-7"://New Password Same As Old Password.
	                HideProgressbar("modalPage");
	                ShowFlash(arCustmClsMsg[11],"");
	                break;
	            case "-8"://Old Password Mismatch While Changing Password.
	                HideProgressbar("modalPage");
	                ShowFlash(arCustmClsMsg[12],"");
	                break;
	             case "-9"://Domain Does Not Exist.
	                HideProgressbar("modalPage");
	                ShowFlash(arCustmClsMsg[14],"");
	                break;
	            case "-11"://Error at server side.
	                HideProgressbar("modalPage");
	                ShowFlash(arCustmClsMsg[15],"");
	                break;    
                 
	            case "-133"://Server Not Responding.
	                HideProgressbar("modalPage");
	                ShowFlash(arCustmClsMsg[15],"");
	                break;
	           
	            
	            default:
			Response="";
	                parent.location.href=Response;
	                break;
	        }
	    }
	}
	
var _rulesAdded = false;
var browser=navigator.appName.toUpperCase();
var version=navigator.appVersion.substr(0,3);
function OnDisplayModalWindow()
{
	//$('modalWindow').style.display = $('modalBackground').style.display = 'block';
	document.getElementById("modalWindow").style.display = document.getElementById("modalBackground").style.display = 'block';
	// Required To Disable Select Items In Microsoft Broswer Lower Than Version 7 Because Select Tags DO Not Get Hidden Under The Modal Layer By ThemSelves
	if((browser=="MICROSOFT INTERNET EXPLORER")&&(parseInt(version,10)<=4)) DisableAllSelects();

	OnWindowResize(); // Call Once To Center Everything

	if (window.attachEvent)		window.attachEvent('onresize', OnWindowResize);
	else if (window.addEventListener) window.addEventListener('resize', OnWindowResize, false);
	else window.onresize = OnWindowResize;
	if (document.all)	document.documentElement.onscroll = OnWindowResize;
}

function OnWindowResize()
{
	// This is Required For Browsers Which Do Not Support POsition:Fixed Like Microsodt Browsers Below Version 7.0
	var left = window.XMLHttpRequest == null ? document.documentElement.scrollLeft : 0;
	var top = window.XMLHttpRequest == null ? document.documentElement.scrollTop : 0;
	//var div = $('modalWindow');
	var div = document.getElementById('modalWindow');
	div.style.left = Math.max((left + (GetWindowWidth() - div.offsetWidth) / 2), 0) + 'px';
	div.style.top = Math.max((top + (GetWindowHeight() - div.offsetHeight) / 2), 0) + 'px';
}

function OnHideModalWindow()
{
    document.getElementById("modalWindow").style.display = document.getElementById("modalBackground").style.display = 'none';
	//$('modalWindow').style.display = $('modalBackground').style.display = 'none';
	// special IE-only processing for windowed elements, like select
	if((browser=="MICROSOFT INTERNET EXPLORER")&&(parseInt(version,10)<=4))
	{
			ReEnableAllSelects();
	}

	if (window.detachEvent)
		window.detachEvent('onresize', OnWindowResize);
	else if (window.removeEventListener)
		window.removeEventListener('resize', OnWindowResize, false);
	else
		window.onresize = null;
}

function ReEnableAllSelects()
{
	var selects = document.getElementsByTagName('select');
	for (var i = 0; i < selects.length; i++)
	{
		selects[i].disabled=false;
	}
}

function DisableAllSelects()
{
	var i;
	var selects = document.getElementsByTagName('select');
    for(i=0;i<selects.length;selects[i].disabled=true,i++);
}

function GetWindowWidth()
{
	var width =
		document.documentElement && document.documentElement.clientWidth ||
		document.body && document.body.clientWidth ||
		document.body && document.body.parentNode && document.body.parentNode.clientWidth ||
		0;
	return width;
}

function GetWindowHeight()
{
    var height =
		document.documentElement && document.documentElement.clientHeight ||
		document.body && document.body.clientHeight ||
  		document.body && document.body.parentNode && document.body.parentNode.clientHeight ||
  		0;
    //var height="2.5em";
  	return height;
}

function $(id)
{
	return document.getElementById(id);
}

