﻿function writeBanDiv()
{   
    var DivTitle = "Ban - " + _ownerUserName;
    var BanMsg = "Are you sure you want to ban BanUserName from your profile page?";
        BanMsg = BanMsg.replace("BanUserName", "<b>"+_ownerUserName+"</b>"); 
                
        aInnerHtml = ""+
        "<div class='posRel BGW' style='width:585px;height:50px;'>"+
            "<div class='posAbs F14 LH16 FB' style='top:10px;width:585px;left:10px;'></div>"+
            "<div class='posAbs' style='left:10px;top:10px;'>"+
                BanMsg + "<br>" +
            "</div>"+                                       
        "</div>"+
        "<div class='posRel' style='left:145px;top:20px;width:100px;height:20px;'>"+
            "<div class='posAbs F14 LH16 FB' style='top:10px;width:100px;left:10px;'>"+
                writeGreenButtonJS(100,"Ban","BanUser(2);") +                    
            "</div>"+
            "<div class='posAbs F14 LH16 FB' style='top:10px;width:250px;left:10px;'>"+
                writeGreenButtonJS(100,"Close","removeCustomAlert();")+
            "</div>"+ 
        "</div>";
        writeCustomAlert(DivTitle,aInnerHtml,"605","170","","");        
}       
function SetMyFriend(FriendUserId, MyFriendStatus, FriendUserName)    
{
    if(MyFriendStatus==0)
    {
        DivTitle = "Friend request";        
    	alertText = "The user has been added to your friend list";
    	InnerDivText = "Please send a friend request to  <b>" + FriendUserName + "<br>";
    	if(_myFriendFlag==1)    
    	{
    	    var today = new Date();
    	    InnerDivText = InnerDivText + 
                            "<div class='posAbs CCase' style='top:40px; left:5px;'>Security Code:</div>"+
                            "<div id='SecCodeDiv' class='posAbs' style='left:148px;top:40px;'><img src='/Functions/SecurityCode.asp?tc=28 28 28&bg=FF FF FF&clk="+today.getDay()+today.getMonth()+today.getFullYear()+today.getHours()+today.getMinutes()+today.getSeconds()+today.getMilliseconds()+"' alt='' style='width:86;height:21' /></div>"+                     
                            "<div class='posAbs CCase' style='top:70px; left:5px;'>Confirm Security Code:</div>"+
                            "<input class='posAbs Standard_white' style='top:70px; left:148px;' tabindex='25' type='Text' maxlength='8' name='SecCode' id='SecCode' onkeypress='return isNumber(event);' />"+                      
                            "<div class='posAbs ErrMsg' id='SecCode_Err' style='top:70px; left:318px;width:200px;'></div>";    	                    
    	}
    	BtnStr = writeBlackButtonJS(100,"Send","setFriend("+FriendUserId+","+MyFriendStatus+");")	               
    }
    else
    {
        DivTitle = "Remove friend"        
    	alertText = "The user is no longer on your friend list";
    	InnerDivText = "You asked to remove  <b>" + FriendUserName + "</b> from your friends list."
    	BtnStr = writeBlackButtonJS(100,"Remove friend","setFriend("+FriendUserId+",2);")
	}
	
	aInnerHtml = ""+
    "<div class='posRel BGW BOGL' style='width:585px;height:250px;'>"+
        "<div class='posAbs F14 LH16 FB' style='top:10px;width:585px;left:10px;'></div>"+
        "<div style='position:absolute;left:10px;top:35px;'>"+
            InnerDivText +
        "</div>"+                                       
    "</div>"+
    "<div class='posRel' style='left:145px;top:20px;width:100px;height:20px;'>"+
        "<div class='posAbs F14 LH16 FB' style='top:10px;width:100px;left:10px;'>"+
            BtnStr +	                    
        "</div>"+
        "<div class='posAbs F14 LH16 FB' style='top:10px;width:250px;left:10px;'>"+
            writeBlackButtonJS(100,"Close","removeCustomAlert();")+
        "</div>"+ 
    "</div>";
    
    createCustomAlert(DivTitle,aInnerHtml,"605","405","",""); 
}

function writeGeneralDiv(Title,Content,w,h,t)
{   (w=="")?dWidth="752":dWidth=w;
    (h=="")?dHeight="360":dHeight=h;
    if(Title!="" && Content!=""){
        writeCustomAlert(Title,Content,dWidth,dHeight,"","");
        if(t!="" || t!=0){
            setTimeout("removeCustomAlert();",t)
        }
    }
}
function writeTnxSMSDiv()
{
    DivTitle = "Your SMS alerts Settings"
    aInnerHtml=SetInnerDivContent(6);
    writeCustomAlert(DivTitle,aInnerHtml,"752","360","","");
    setTimeout("removeCustomAlert();",4000);
}
function writeTnxFlagDiv()
{   
    DivTitle = "Inappropriate content";
    aInnerHtml= ""+
    "<div class='posRel F16 LH17 C_GD FB' style='width:490px;height:200px; text-align:center'>"+
	    "<br><br>Thanks for your cooperation<br>"+
	    "<input type='button' class='posRel CursorP' style='top:15px;width:100px;' value='Close' title='Close' onclick='removeCustomAlert();'>"+        
    "</div>";
    
    writeCustomAlert(DivTitle,aInnerHtml,"505","305","","");
    setTimeout("removeCustomAlert();",4000);
}
function writeTnxSubDiv()
{
    var OwnerUserName = _SetOwnerUserName+"'s";
    var DivTitle = "Your subscription to UserName show";
        DivTitle = DivTitle.replace("UserName", OwnerUserName);  
        aInnerHtml=SetInnerDivContent(1);
        aInnerHtml= aInnerHtml.replace("SubscribeUserName",OwnerUserName);
        writeCustomAlert(DivTitle,aInnerHtml,"752","360","","");
        setTimeout("removeCustomAlert();",4000);
}

function writeSubDiv()
{
    var SubscribeUserName = _SetOwnerUserName+"'s";
    var DivTitle = "Subscribe to UserName show";
        DivTitle = DivTitle.replace("UserName", SubscribeUserName);  
        aInnerHtml=SetInnerDivContent(0);
        writeCustomAlert(DivTitle,aInnerHtml,"752","360","","");
}
function writeUnSubDiv()
{
    var SubscribeUserName = _SetOwnerUserName+"'s";
    var DivTitle = "UnSubscribe from UserName show";
        DivTitle = DivTitle.replace("UserName", SubscribeUserName);  
        aInnerHtml=SetInnerDivContent(2);
        writeCustomAlert(DivTitle,aInnerHtml,"752","360","","");
}
function LogInDiv()
{
    DivTitle = "Login  <span class='FN LCase'>or</span> <a onclick='setSignIn();' title='join us' class='FN UnLine C_W CCase'>join us</a>" ;
	aInnerHtml=SetInnerDivContent(4);	
    _onDivCloseRefresh=true;  
    writeCustomAlert(DivTitle,aInnerHtml,"570","250","","");
}
function ForgotPswDiv()
{
    DivTitle = "Forgot password"
	aInnerHtml=SetInnerDivContent(5);	
    _onDivCloseRefresh=true;  
    writeCustomAlert(DivTitle,aInnerHtml,"600","220","","");
}

function JoinUsDiv()
{
    
    xmlPage = '/Ajax/SignIn_Div.asp';
    param= 'BackId=' + _StartDiv;
    objRegXml = CreateObjXML();
    objRegXml.open('POST', xmlPage ,true);
    objRegXml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    objRegXml.onreadystatechange = batchJoinUsDiv;
    objRegXml.send(param);
}

function batchJoinUsDiv()
{     if (objRegXml && objRegXml.readyState==4)
      {     if (objRegXml.responseXML)
            {  var Str = objRegXml.responseXML.getElementsByTagName("Str");
                   Str = Str[0].firstChild.data;                     
               var DivType = objRegXml.responseXML.getElementsByTagName("type");
               var _DivType = DivType[0].firstChild.data;               
               var divH = "490";
               if(_DivType==2){divH = "600";}
                   
               DivTitle = "join us"
               aInnerHtml= Str               
               writeCustomAlert(DivTitle,aInnerHtml,"760",divH,"","");   
               if(_DivType==2){ 
                    var ACPuzzleOptions = {theme:	    'custom',size:	    '300x150',lang:	'en'};
                    ACPuzzle.create(_SIGNIN_CAPTCHA_CKEY, 'adcopy-pixel-image', ACPuzzleOptions); 
               }           
               if (self.regScript) { // Already exists
                 return;
               }
               var head = document.getElementsByTagName("head")[0];
                   script = document.createElement('script');
                   script.id = 'regScript';
                   script.type = 'text/javascript';
                   script.src = IIS_SERVER_URL+"/include/signin.js";
                   head.appendChild(script);
                   script = document.createElement('script');
                   script.id = 'PassStrength';
                   script.type = 'text/javascript';
                   script.src = IIS_SERVER_URL+"/include/PassStrength.js";
                   head.appendChild(script); 
                    
            
                   
            }
      }
}

function writeCustomAlert(divTitle,aInnerHtml,aWidth,aHeight,aBorderColor,aBgColor) 
{
    //clears the page refresh 
    if (_setPageRefresh)
        clearInterval(_winInterval); 
	// shortcut reference to the document object
	d = document;
    // if resize div keep the _onDivCloseRefresh into temp var
    var _temponDivCloseRefresh = _onDivCloseRefresh; 
    _onDivCloseRefresh = false;
    // if the modalContainer object already exists in the DOM, bail out.
	//if(d.getElementById("modalContainer")) return;
	if(d.getElementById("modalContainer")) removeCustomAlert();
	_onDivCloseRefresh = _temponDivCloseRefresh; 	
	// create the modalContainer div as a child of the BODY element
	fObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	fObj.id = "modalContainerOpacity";
	 // make sure its as tall as it needs to be to overlay all the content on the page
	//fObj.style.height = document.documentElement.scrollHeight + "px";
    fObj.style.height = d.body.scrollHeight + "px";
    
	// create the modalContainer div as a child of the BODY element
	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainer";
	 // make sure its as tall as it needs to be to overlay all the content on the page
	//mObj.style.height = document.documentElement.scrollHeight + "px";
	mObj.style.height = d.body.scrollHeight + "px";
    
	// create the DIV that will be the alert 
	alertObj = mObj.appendChild(d.createElement("div"));
	alertObj.id = "alertBox";
	// MSIE doesnt treat position:fixed correctly, so this compenDay_7es for positioning the alert
	//if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
	if(_AIMPlayer==1)
	{
	    if(d.all && !window.opera) alertObj.style.top = (d.body.scrollTop-40) + "px";
	}
	else
	{	    
	    if(d.all && !window.opera) alertObj.style.top = d.body.scrollTop + "px";
	}
	// center the alert box   
    aWidth=(aWidth=="")? 605: aWidth;
    aHeight=(aHeight=="")? 405: aHeight;
   	
    if (BrowserDetect.browser == "Chrome") {
        alertObj.style.top = (((document.body.scrollTop + document.body.clientHeight / 2) - (aHeight / 2)) - 45) + "px";
    }
    else {
        alertObj.style.top = (((document.body.scrollTop + document.body.clientHeight / 2) - (aHeight / 2)) - 45) + "px";
    }
   
	
	alertObj.style.left = (d.body.scrollWidth - aWidth)/2 + "px";    
    var Sel = d.getElementsByTagName("select");
    for(i=0;i<Sel.length;i++)
    {
        Sel[i].disabled=true;
    }    
    BasicAlertStr = 
    '<iframe id="iframeBox" style="position:absolute;display:none;" frameborder=0 scrolling=no marginwidth=0 src="" marginheight=0></iframe>'+
    '<div id="divAlertBorder" style="position:absolute;display:none;">' + 
        '<div id="divAlertBox">'+            
            '<div id="divAlertTitleBg" class="BGGR">'+
                '<div id="divAlertTitle" class="C_W FB FH14 F14 UCase BGGR HebTxt" style="Height:17px;"></div>'+
                '<div id="divAlertTitleClose"  class="BGGR CCase" onclick="removeCustomAlert();" title="Close">Close</div>'+
                '<div id="divAlertTitleCloseImg" class="xIcon" onclick="removeCustomAlert();" title="Close"></div>'+
            '</div>'+
            '<div id="divAlertContent">'+
                '<div id="DivBorderContent">'+
                    '<div id="DivBGContent">'+
                        '<div id="InnerContent"></div>'+
                    '</div>'+
                '</div>'+
            '</div>'+           
        '</div>'+    
    '</div>';

   $g("alertBox").innerHTML = BasicAlertStr;   
   var objBorder=$g("divAlertBorder");
   var objBox=$g("divAlertBox");
   var objTitleBg=$g("divAlertTitleBg");
   var objTitle=$g("divAlertTitle");  
   var objContent=$g("divAlertContent");  
   var objIframe=$g("iframeBox");   
   var objBorderContent=$g("DivBorderContent");  
   var objDivBGContent=$g("DivBGContent");  
   var objInnerContent =$g("InnerContent");  
     
   if(objBorder){
        with(objBorder.style){            
            display="block";
            width=(aWidth=="")? 605: aWidth;
            height=(aHeight=="")? 405: aHeight;            
            backgroundColor=(aBorderColor=="")?"#515151":aBorderColor;
        }
   }
   if(objBox){
        with(objBox.style){                        
            width=(aWidth-2);
            height=(aHeight-2);
            left="1px";
            top="1px";
            backgroundColor=(aBgColor=="")?"#EDEDED":aBgColor;
        }
   }
   
   if(objIframe){
        with(objIframe.style){
            width=aWidth;
            height=aHeight;
            display="block";
            backgroundColor="Black";
        }  
   }
   if(objTitleBg){
        objTitleBg.style.width=aWidth-12; 
        //if(!_ShowInnerDiv){
            //objTitleBg.style.display = "none";  
            with(objContent.style){          
            top = "30px";
            left = "5px";
            width = (aWidth-12);
            height = (aHeight-38);                                    
            }            
            //objContent.style.border = "solid 1px #FF0000";
        //}   
   }
   if(objBorderContent)
   {
        with(objBorderContent.style){          
            top = "31px";
            left = "6px";
            width=(aWidth-13);
            height=(aHeight-38);                       
            backgroundColor = "#D7D7D7";
        }           
   }
   if(objDivBGContent)
   {
        with(objDivBGContent.style){ 
            position = "relative";         
            top = "1px";
            left = "1px";
            width=(aWidth-15);
            height=(aHeight-40);                       
            backgroundColor = "#FFFFFF";
        }           
   }
   if(objInnerContent)
   {
        with(objInnerContent.style){
             position = "relative"; 
             left = "8px"; 
             top = "3px";
             width=(aWidth-30);
             height=(aHeight-50);
             //backgroundColor = "#FF0000";
        }
   }
   if(objTitle){
        objTitle.innerHTML=divTitle;
   }   
   if(objInnerContent){
        objInnerContent.innerHTML=aInnerHtml;      
   }
   _ShowInnerDiv = true;
}

function SetInnerDivContent(item)
{
    var InnerDivHtm = "";
    
    switch (item){
        case 0: // subscribe div 
            InnerDivHtm = '' +    
            '<div class="SubMainDiv">'+        
                '<div class="SubTitle1">What kind of alerts would you like to receive about this show?</div>'+                
                '<div class="SubCheck1">'+
                    '<input type="checkbox" onclick="Alerts_SetUserAlerts(0,1);" id="StartRemind" name="StartRemind" value="'+_SetMyProgId+'" checked/> When show starts'+
                '</div>'+
                '<div class="SubCheck2">'+
                    '<input type="checkbox" onclick="Alerts_SetUserAlerts(0,2);" id="RemindBef" name="RemindBef" value="'+_SetMyProgId+'" /> 5 Mins before show starts'+
                '</div>'+
                '<div class="SubCheck3">'+
                    '<input type="checkbox" onclick="Alerts_SetUserAlerts(0,3);" id="RemindVod" name="RemindVod" value="'+_SetMyProgId+'" checked/> New VOD alert'+
                '</div>'+                            
                '<div class="SubTitle2">Where would you like to receive them?</div>'+            
                '<div class="SubCheck4">'+
                    '<input type="checkbox" onclick="Alerts_SetUserAlerts(0,4);" name="ByMobile" id="ByMobile" checked/> My cellphone '+
                '</div>'+
                '<div class="SubCheck5">'+
                    '<input type="checkbox" onclick="Alerts_SetUserAlerts(0,5);" name="ByEmail" id="ByEmail" checked/> My email'+
                '</div>'+                
                '<div class="SubBtn1">'+
                    writeGreenButtonJS(120,"Subscribe","SetMyProgramHP("+_SetMyProgId+","+_SetMyStatus+","+_SetMyUserId+");")+
                '</div>'+
                '<div class="SubBtn2">'+
                    writeGreenButtonJS(120,"Close","removeCustomAlert();")+
                '</div>'+
            '</div>';
            break;
          
        case 1: // Thanks - subscribe div 
            InnerDivHtm = '' +  
            '<center><div class="posRel FB" style="top:10px;height:20px;">You are now subscribed to SubscribeUserName Show</div></center>';
            break;
        case 2: // UnSubscribe - subscribe div
            InnerDivHtm = '' +  
            '<div class="posRel">'+
                '<div class="posAbs" style="top:140px;left:300px;">'+
                    writeGreenButtonJS(120,"UnSubscribe","User_UnSubscribe("+_SetMyProgId+");") +
                '</div>'+               
                '<div class="posAbs" style="top:140px;left:500px;">'+
                    writeGreenButtonJS(120,"Close","removeCustomAlert();") +
                '</div>'+
            '</div>';
            break;
            
        case 3://SMS_Activation
            InnerDivHtm = '' +  
            '<div class="posRel">'+
                '<div class="posAbs FB" style="top:10px;left:10px;">'+
                    'We have just sent you a sms message with a code, please enter the code below:'+
                '</div>'+
                '<div class="posAbs" style="top:45px;left:10px;">'+
                    'Confirmation code: '+                
                    '<input type="text" name="SMS_ActiveKey" id="SMS_ActiveKey" style="width:100px;" maxlength="10" />'+
                '</div>'+                
                '<!--div class="posAbs" style="top:90px;left:10px;">'+
                    '<a onclick=alert("ask Daniel") class="UnLine" title="I did not get the message! Why?">I did not get the message! Why?</a>'+
                '</div-->'+                
                '<div class="posAbs" style="top:140px;left:300px;">'+
                    writeGreenButtonJS(120,"Confirm","Sms_ConfirmKey();")+
                '</div>'+
                '<div class="posAbs" style="top:140px;left:500px;">'+
                    writeGreenButtonJS(120,"Close","removeCustomAlert();") +
                '</div>'+
            '</div>';
             break;
       
        case 4: //Login
     
            switch (ContentLangID)
            {
                case "1":                    
                    InputLeft = 100;
                    LinkLeft = InputLeft + 160;
                    break;
                case "2":                     
                    InputLeft = 120;               
                    LinkLeft = InputLeft + 160;
                    break;  
                default:                    
                    InputLeft = 100;
                    LinkLeft = InputLeft + 150;
                    break;
            }
            
            InnerDivHtm = '' +               
            '<div class="posRel">'+
                '<div class="posAbs F12 FB C_GD" style="left:5px; top:5px;">You must be logged in to use this feature</div>'+
                '<div class="posAbs F12 FB C_GD" style="left:5px; top:50px;">Username:</div>'+
                '<div class="posAbs" style="left:120px; top:50px;">'+
                    '<input type="Text" tabindex="10" name="divUserName" id="divUserName" onkeypress="return isEnglish(event) || isNumber(event) || isSigns(event,1,this.value);" alt="Enter Username" title="Enter Username" value="Enter Username" onfocus="claerMe(this);" autocomplete="on" class="Standard_white" style="width:195px; height:20px;" />'+
                '</div>'+
                '<div class="posAbs F12 FB C_GD" style="left:5px; top:80px;">Password:</div>'+
                '<div class="posAbs" style="left:120px; top:80px;">'+
                    '<input type="Password" tabindex="11" name="divUserPsw" id="divUserPsw" onkeypress="CheckForEnterDiv(event,16)" value="" alt="Enter Password" title="Enter Password" onfocus=ChangeBackPass("divUserPsw"); autocomplete="on" class="Standard_white" style="width:195px; height:20px;" />'+
                    '<a onclick="ForgotPswDiv();" class="posAbs UnLine CursorP F9 LH10 C_GD" style="top:5px; left:210px; width:100px;" tabindex="3" title="Forgot your password?">Forgot your password?</a>'+
                '</div>'+
                '<div id="divLoginErr" class="posAbs F11 FB" style="left:120px; top:100px; color:#ed1c24;"></div>'+
                '<div class="posAbs F10 C_GD" style="left:5px; top:120px;">NEW USER? <a class="UnLine CursorP" onclick="setSignIn();" title="join us">join us!</a></div>'+
                '<div class="posAbs" style="left:300px; top:170px;">'+
                    writeGreenButtonJS(91,'GO!','Login(16);')+
                '</div>'+
                '<div class="posAbs" style="right:20px; top:20px;">'+
                    '<img src="'+IMG_SERVER_URL+'logInDiv!.jpg" title="" alt="" width="80" height="100" />'+
                '</div>'+
            '</div>';
             break;
        case 5: //forgot Psw
            switch (ContentLangID)
            {
                case "1":                    
                    InputLeft = 220;
                    LinkLeft = InputLeft + 150;
                    break;
                case "2":                     
                    InputLeft = 340;               
                    LinkLeft = InputLeft + 120;
                    break;  
                default:                    
                    InputLeft = 220;
                    LinkLeft = InputLeft + 150;
                    break;
            }
            InnerDivHtm = '' +  
            '<div class="posRel >'+                  
               '<div class="posAbs" style="left:10px; top:10px;">'+
                    'Please enter the e-mail you gave during your registration. The username and password will be sent to your e-mail shortly:'+
               '</div>'+
               '<div class="posAbs" style="left:10px; top:50px;">'+
                   '<input type="text" class="posAbs" style="width:300px;" tabindex="2" name="divAlertEmail" id="divAlertEmail" value=""  onkeypress="return isEnglishAndSigns4Emails(event) || isNumber(event)" autocomplete="on">'+
               '</div>'+
                '<div class="posAbs" style="top:50px;left:320px;width:100px;height:20px;">'+	
                    writeGreenButtonJS(100,'Send','sendForgotPwd()')+		           	               
                '</div>'+
                '<div id="divLoginErr" class="posAbs F12 FB LH14 C_R" style="top:80px; left:10; width:585px;"></div>'+
                '<div class="posAbs F16 LH17 FB C_GD" style="top:120px;left:10">NEW USER?</div>'+
                '<div class="posAbs" style="left:'+InputLeft+'px; top:120px;">'+
                    writeGreenButtonJS(100,'SIGN UP HERE','JoinUsDiv();')+
                '</div>'+
                '<div class="posAbs BGW BOGL" style="left:'+LinkLeft+'px; top:120px;">'+
                    writeGreenButtonJS(100,'Back','LogInDiv();')+
                '</div>' + 
            '</div>';  
            break; 
        case 6: //Sms - thank you
            InnerDivHtm = '' +  
            '<center><div class="posRel FB" style="top:10px;height:20px;">Thank you for activating your SMS account</div></center>';            
            break; 
    }
    return InnerDivHtm;        
}

function SkipStep(item)
{
    aInnerHtml = SetInnerDivContent(item);	
    if(aInnerHtml!=""){    	        
        writeCustomAlert("Your SMS alerts Settings",aInnerHtml,"","","","");
    }
    
}

function SetMobileDetails()
{
    var CountryId = 256;
    //$g("Mobile_Country").value;
    var NetworkPrefix = $g("MobileNetworkPrefix").value;
    if(NetworkPrefix=="")
    {
        alert("You must enter a valid cell phone number ")       
        $g("MobileNetworkPrefix").focus();     
        return;
    }
    var PhoneNumber = $g("MobilePhoneNumber").value;
    if(PhoneNumber=="")
    {
        alert("You must enter a valid cell phone number ")
        $g("MobilePhoneNumber").focus(); 
        return;
    }
    var SmsAmount = $g("MaxWeeklySmsAmount").value;    
    
    var Day_1 = 0; 
    var Day_2 = 0; 
    var Day_3 = 0; 
    var Day_4 = 0;    
    var Day_5 = 0;
    var Day_6 = 0 ;
    var Day_7 = 0;    
    var FromHour = $g("FromHour").value;
    var ToHour = $g("ToHour").value;
    
    if(parseInt(FromHour)>=parseInt(ToHour))
    {
        alert("Oops! Please choose a start time that is earlier than your finish time.");
        $g("FromHour").focus(); 
        return;
    }
    if ($g("Day_1").checked) Day_1 = 1;
    if ($g("Day_2").checked) Day_2 = 1;
    if ($g("Day_3").checked) Day_3 = 1;
    if ($g("Day_4").checked) Day_4 = 1;
    if ($g("Day_5").checked) Day_5 = 1;
    if ($g("Day_6").checked) Day_6 = 1;
    if ($g("Day_7").checked) Day_7 = 1;
    NoDays = true;
    for(d=1;d<=7;d++)
    {
        if(eval("Day_"+d) == 1)
        {
            NoDays = false;
            break; 
        }
    }
    if (NoDays)
    {
        alert("You must choose at least 1 day to receive SMS messages");
        return;
    }
    url = "/Ajax/SMS_SetUserDetails.asp";
    str = "CountryId="+CountryId+"&NetworkPrefix="+NetworkPrefix+"&PhoneNumber="+PhoneNumber+"&SmsAmount="+SmsAmount+"&Sun="+Day_1+"&Mon="+Day_2+"&Tue="+Day_3+"&Wed="+Day_4+"&Thu="+Day_5+"&Fri="+Day_6+"&Sat="+Day_7+"&FromHour="+FromHour+"&ToHour="+ToHour;
    objSMSXML = CreateObjXML();
    objSMSXML.open("POST", url ,true); 
    objSMSXML.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    objSMSXML.onreadystatechange = batchSmsUserDetails;
    objSMSXML.send(str);
    
}

function batchSmsUserDetails()
{
    if (objSMSXML && objSMSXML.readyState==4)
	{
        if (objSMSXML.responseXML)
		{
	        var ErrCode = objSMSXML.responseXML.getElementsByTagName("ErrCode");
            ErrCode = ErrCode[0].firstChild.data;            
            if(ErrCode==2)
            {   
                 aInnerHtml = SetInnerDivContent(3);
                 awidth = 752
                 aheight = 250	
                 writeCustomAlert("Your SMS alerts Settings",aInnerHtml,awidth,aheight,"","");
            }
            else
            {   
                if (_MobileSubscribe==0)
                {   
                    DivTitle = "Your SMS alerts Settings"
                    DivContent = "<center><div class='posRel FB' style='top:10px;height:20px;'>Thank you for updating your SMS details!</div></center>";
                    writeGeneralDiv(DivTitle,DivContent,"752","360",4000)
                    
                }
                else
                {
                    aInnerHtml = SetInnerDivContent(1);	
                    awidth = 752
                    aheight = 350
                    writeCustomAlert("Your SMS alerts Settings",aInnerHtml,awidth,aheight,"","");
                }
            }
		}
    }     
}

function Sms_ConfirmKey()
{
    ActiveKey = $g("SMS_ActiveKey").value;
    if(ActiveKey=="")
    {
        alert("The confirmation code you have entered is invalid ")   
        $g("SMS_ActiveKey").focus();     
        return;
    }
    
    url = "/Ajax/SMS_Active.asp";        
    str = "ActiveKey="+ActiveKey;
    objSMSXML = CreateObjXML();
    objSMSXML.open("POST", url ,true); 
    objSMSXML.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    objSMSXML.onreadystatechange = batchSms_ConfirmKey;
    objSMSXML.send(str);
}
function batchSms_ConfirmKey()
{
if (objSMSXML && objSMSXML.readyState==4)
	{
        if (objSMSXML.responseXML)
		{
		    var ErrCode = objSMSXML.responseXML.getElementsByTagName("ErrCode");
                ErrCode = ErrCode[0].firstChild.data;
                if(ErrCode ==1)
                {
                    writeTnxSMSDiv();                  
                }
                else
                {
                    alert("The confirmation code you have entered is invalid ")                    
                    $g("SMS_ActiveKey").value = "";                    
                    $g("SMS_ActiveKey").focus();                    
                    return;
                }
        }
    }     
}

function My_GetUserSubscriptions(p)
{
    var SearchTerm = "";    
    if($g("mysubSearch")){
        SearchTerm = $g("mysubSearch").value;    
    }
    url = "/Ajax/My_GetUserSubscriptions.asp";        
    str = "P="+p+"&S="+SearchTerm;
    objUserSubXML = CreateObjXML();
    objUserSubXML.open("POST", url ,true); 
    objUserSubXML.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    objUserSubXML.onreadystatechange = batchMy_GetUserSubscriptions;
    objUserSubXML.send(str);
}
function batchMy_GetUserSubscriptions()
{
    if (objUserSubXML && objUserSubXML.readyState==4)
	{
        if (objUserSubXML.responseXML)
		{
		    var Str = objUserSubXML.responseXML.getElementsByTagName("Str");
                aInnerHtml = Str[0].firstChild.data;                 
                awidth = 752
                aheight = 470	
                writeCustomAlert("Your Subscriptions",aInnerHtml,awidth,aheight,"","");
        }
    } 
}

function Alerts_SetUserAlerts(ShowId,Obj)
{
    var BR=0;
    var SR=0;
    var RV=0;
    var ByM=0;
    var ByE=0;
    var ByT=0;
    var ByA=0;
    var iAction = 0;
    if(ShowId!=0){
        var StartRemind = $g("StartRemind_"+ShowId);
        var RemindBef = $g("RemindBef_"+ShowId);
        var RemindVod = $g("RemindVod_"+ShowId);
    
        var ByMobile = $g("ByMobile_"+ShowId);
        var ByEmail = $g("ByEmail_"+ShowId);
    }
    else{
        var StartRemind = $g("StartRemind");
        var RemindBef = $g("RemindBef");
        var RemindVod = $g("RemindVod");
    
        var ByMobile = $g("ByMobile");
        var ByEmail = $g("ByEmail");
    }
    
    if(Obj==1)
    {
        SR = 1;   
        ByE = 1;     
        if(StartRemind.checked)
        { 
            iAction = 1;
            ByEmail.checked = true;
        } 
        else
        {
            ByM=1;
            ByMobile.checked = false;
            if((!RemindVod.checked)&&(!RemindBef.checked)) ByEmail.checked = false;
        }   
    }
    else if(Obj==2)
    {
        BR = 1;
        ByE = 1;
        if(RemindBef.checked)        
        { 
            iAction = 1;
            ByEmail.checked = true;
        } 
        else
        {
            if((!RemindVod.checked)&&(!StartRemind.checked)) ByEmail.checked = false; 
        } 
    }
    else if(Obj==3)
    {
        RV = 1;
        ByE = 1;
        if (RemindVod.checked)      
        { 
            iAction = 1;
            ByEmail.checked = true;
        } 
        else
        {
            if((!RemindBef.checked)&&(!StartRemind.checked)) ByEmail.checked = false; 
        } 
    }
    else if(Obj==4)
    {
        ByM=1;
        SR=1;
        if(ByMobile.checked)
        {
            iAction = 1;
            StartRemind.checked = true;
        }
        else
        {
            if(!ByEmail.checked) StartRemind.checked = false;
        }
    }
    else if(Obj==5)
    {
        ByE=1;  
        SR=1;
        RV=1;
        if(ByEmail.checked)
        { 
            iAction = 1;  
            StartRemind.checked = true; 
            RemindVod.checked = true; 
        }
        else
        {
            BR=1;
            if(!ByMobile.checked) StartRemind.checked = false;
            RemindVod.checked = false;
            RemindBef.checked = false;
        }
    }        
    if(ShowId==0) return;
    
    url = "/Ajax/My_SetUserSubscribe.asp";
    str = "ShowId="+ShowId+"&SR="+SR+"&BR="+BR+"&RV="+RV+"&ByM="+ByM+"&ByE="+ByE+"&ByT="+ByT+"&ByA="+ByA+"&action="+iAction;
    objUserSubXML = CreateObjXML();
    objUserSubXML.open("POST", url ,true); 
    objUserSubXML.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    objUserSubXML.onreadystatechange = batchMy_SetUserSubscriptions;
    objUserSubXML.send(str);  
}
function batchMy_SetUserSubscriptions()
{
    if (objUserSubXML && objUserSubXML.readyState==4)
	{
        if (objUserSubXML.responseXML)
		{   
            var ShowId = objUserSubXML.responseXML.getElementsByTagName("ShowId");
                ShowId = ShowId[0].firstChild.data;
            var Action = objUserSubXML.responseXML.getElementsByTagName("Action")
                Action = Action[0].firstChild.data;    
            var ByMobile = objUserSubXML.responseXML.getElementsByTagName("ByMobile")
                ByMobile = ByMobile[0].firstChild.data;    
           var MobileActive = objUserSubXML.responseXML.getElementsByTagName("MobileActive")
                MobileActive = MobileActive[0].firstChild.data;                    
           if(ByMobile=="1" && Action == "1" && MobileActive=="0")
                getSmsUserDetailsDiv()
           
        }
    }
}

function My_SetUserUnSubscribe(ShowId,P)
{
    url = "/Ajax/My_SetUserUnSubscribe.asp";
    str = "ShowId="+ShowId+"&P="+P;    
    objUserSubXML = CreateObjXML();
    objUserSubXML.open("POST", url ,true); 
    objUserSubXML.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    objUserSubXML.onreadystatechange = batchMy_SetUserUnSubscribe;
    objUserSubXML.send(str);  
}

function batchMy_SetUserUnSubscribe()
{
    if (objUserSubXML && objUserSubXML.readyState==4)
	{
        if (objUserSubXML.responseXML)
		{              
            var Page = objUserSubXML.responseXML.getElementsByTagName("Page");
                Page = Page[0].firstChild.data;     
                My_GetUserSubscriptions(Page);
        }
    }
}
function getSmsUserDetailsDiv()
{
    url = "/Ajax/SMS_UserDetailsDiv.asp";
    str = "null";
    objSMSXML = CreateObjXML();
    objSMSXML.open("POST", url ,true); 
    objSMSXML.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    objSMSXML.onreadystatechange = batchSMSUserDetailsDiv;
    objSMSXML.send(str);
}

function batchSMSUserDetailsDiv()
{
    if (objSMSXML && objSMSXML.readyState==4)
	{
        if (objSMSXML.responseXML)
		{ 
		    var SMSUserDiv = objSMSXML.responseXML.getElementsByTagName("Str");
		        aInnerHtml = SMSUserDiv[0].firstChild.data;
		        writeCustomAlert("Your SMS alerts Settings",aInnerHtml,"752","320","","")
		}
    } 
}

function User_UnSubscribe(ShowId)
{
    url = "/Ajax/My_SetUserUnSubscribe.asp";
    str = "ShowId="+ShowId;    
    objUserSubXML = CreateObjXML();
    objUserSubXML.open("POST", url ,true); 
    objUserSubXML.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    objUserSubXML.onreadystatechange = batchUser_UnSubscribe;
    objUserSubXML.send(str);  
}

function batchUser_UnSubscribe()
{
    if (objUserSubXML && objUserSubXML.readyState==4)
	{
        if (objUserSubXML.responseXML)
		{    
		    ChangeSubscribeDiv();
            removeCustomAlert();
        }
    }
}
function setFriend(FriendUserId,MyFriendStatus)
{           
    xmlPage = "/Ajax/My_SetFriend.asp";
    var SecCode = "";
    if($g("SecCode")) SecCode = $g("SecCode").value;
    parm = "FriendUserId="+FriendUserId+"&Status="+MyFriendStatus+"&SecCode="+SecCode;    
    FriendsObjXml = CreateObjXML();
    FriendsObjXml.open("POST", xmlPage ,true); 
    FriendsObjXml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    FriendsObjXml.onreadystatechange = rsSetFriend;
    FriendsObjXml.send(parm);     
}
function rsSetFriend()
{   
    if (FriendsObjXml && FriendsObjXml.readyState==4)
	{
        if (FriendsObjXml.responseXML)
	    {   
		    var FriendUserIdObj = FriendsObjXml.responseXML.getElementsByTagName("FriendUserId");                
                _FriendUserId = parseInt(FriendUserIdObj[0].firstChild.data); 
            var StatusObj = FriendsObjXml.responseXML.getElementsByTagName("Status");                
                _Status = StatusObj[0].firstChild.data;
            var ErrCodeObj = FriendsObjXml.responseXML.getElementsByTagName("ErrCode");                
                _ErrCode = parseInt(ErrCodeObj[0].firstChild.data);
            var FriendStatusObj = FriendsObjXml.responseXML.getElementsByTagName("FriendStatus");                
                _FriendStatus = parseInt(FriendStatusObj[0].firstChild.data);
            var MyFriendFlag = FriendsObjXml.responseXML.getElementsByTagName("MyFriendFlag");
                _myFriendFlag = parseInt(MyFriendFlag[0].firstChild.data);
                
            if(_ErrCode==12)
            {
                var today = new Date();
                $g("SecCode_Err").innerHTML = "The Security Code number you entered does not match the Security Code number";
                $g("SecCodeDiv").innerHTML = "<img src='/Functions/SecurityCode.asp?tc=28 28 28&bg=FF FF FF&clk="+today.getDay()+today.getMonth()+today.getFullYear()+today.getHours()+today.getMinutes()+today.getSeconds()+today.getMilliseconds()+"' alt='' style='width:86;height:21' /></div>";     
                setTimeout('if ($g("SecCode_Err") != null){$g("SecCode_Err").innerHTML="";}',2000);                
            }
            else
            {
                removeCustomAlert();
                MyFriendDivObj = $g("myFriendDiv_"+_FriendUserId);
                MyFriendDivNotObj = $g("FriendDivNotification");
                MyFriendBtnObj = $g("FriendBtn");
                
                if(MyFriendDivObj || MyFriendBtnObj)
                {   
                    if(_FriendStatus==0)
                    {   
                        if(MyFriendBtnObj){
                            MyFriendBtnObj.onclick = function(){SetMyFriend(_FriendUserId,0,_ownerUserName)}
                            MyFriendBtnObj.title = "Add a friend";
                            MyFriendBtnObj.innerHTML = "Add a friend";
                            
                        }
                        HtmlStr = "<a onclick='SetMyFriend("+_FriendUserId+",0,\""+_ownerUserName+"\")' id='SetMyProgram' class='F12 FB userLinkColor UnLine CursorP' title='Add a friend'>Add a friend</a>";	                
                    }
                    else if (_FriendStatus==1)
                    {    
                        if(MyFriendBtnObj){
                            MyFriendBtnObj.onclick = function(){SetMyFriend(_FriendUserId,1,_ownerUserName)}
                            MyFriendBtnObj.title = "Remove friend";
                            MyFriendBtnObj.innerHTML = "Remove friend";
                        }                
                        HtmlStr = "<a onclick='SetMyFriend("+_FriendUserId+",1,\""+_ownerUserName+"\")' id='SetMyProgram' class='F12 FB userLinkColor UnLine CursorP' title='Remove from friends list'>Remove from friends list</a>";	                
                    }
                    else if (_FriendStatus==2)
                    {   
                        if(MyFriendBtnObj){
                            MyFriendBtnObj.onclick = function(){};
                            MyFriendBtnObj.href = "/"+UserName+"/Friends/Pending/0/0/0/";
                            MyFriendBtnObj.title = "Pending";
                            MyFriendBtnObj.innerHTML = "Pending";
                        }                   
                        HtmlStr = "<a href='/UserFriends.asp?UserName="+UserName+"&Friendstype=2' id='SetMyFriend' class='F12 FB userLinkColor UnLine CursorP' title='Pending'>Pending</a>"
                    }
                    else if (_FriendStatus==3)
                    {   
                        if(MyFriendBtnObj){  
                            MyFriendBtnObj.onmouseout = function(){};  
                            MyFriendBtnObj.onmouseover= function(){};                              
                            MyFriendBtnObj.onclick = function(){return;};
                            MyFriendBtnObj.title = "";
                            MyFriendBtnObj.className = "C_GLL CursorD";
                            MyFriendBtnObj.innerHTML = "Add a friend";//"Waiting";
                            
                        }   
                        HtmlStr = "<span class='F12 FB'>Waiting</span>"
                    }
                    if(MyFriendDivObj)
                        MyFriendDivObj.innerHTML = HtmlStr;                        
                    
                }            
                else if(MyFriendDivNotObj)
                {   
                    var str = 'Waiting';                
                    HtmlStr = writeBlackButtonJS(143,str.toUpperCase(),'return;');
                    MyFriendDivNotObj.innerHTML = HtmlStr
                }
                else
                {
                    window.location.reload();
                }
            }
        }
    }    
}

function BanUser(BanStatus)
{   
    xmlPage = "/Ajax/Users_SetBanUser.asp";    
    parm = "banUserId="+_ownerUserId+"&Status="+BanStatus;    
    BanObjXml = CreateObjXML();
    BanObjXml.open("POST", xmlPage ,true); 
    BanObjXml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    BanObjXml.onreadystatechange = rsSetBan;
    BanObjXml.send(parm);     
}

function rsSetBan()
{   
    if (BanObjXml && BanObjXml.readyState==4)
	{
        if (BanObjXml.responseXML)
	    {   
	        var ErrorCode = BanObjXml.responseXML.getElementsByTagName("ErrorCode");                
                ErrorCode = parseInt(ErrorCode[0].firstChild.data); 
            var BanStatus = BanObjXml.responseXML.getElementsByTagName("BanStatus");
                BanStatus = parseInt(BanStatus[0].firstChild.data); 
            BanUserDivObj = $g("BanUserDiv");
            BanUserBtnObj = $g("BanUserBtn");
            if(BanUserDivObj){
                if(BanStatus==2){   
                    removeCustomAlert();             
                    BanHtmlStr= "<a class='F12 FB userLinkColor UnLine CursorP' onclick='BanUser(3);' title='Unban'>Unban</a>";
                }else if(BanStatus==3){
                    BanHtmlStr = "<a class='F12 FB userLinkColor UnLine CursorP' onclick='writeBanDiv();' title='Ban'>Ban</a>";
                }  
                BanUserDivObj.innerHTML = '<br />'+BanHtmlStr;
            }
            
            if(BanUserBtnObj)
            {
                if(BanStatus==2){   
                    removeCustomAlert();  
                    BanUserBtnObj.onclick = function(){BanUser(3)};
                    BanUserBtnObj.innerHTML = "Unban";
                    BanUserBtnObj.title = "Unban";
                }else if(BanStatus==3){
                    BanUserBtnObj.onclick = function(){writeBanDiv()};
                    BanUserBtnObj.innerHTML = "Ban";
                    BanUserBtnObj.title = "Ban";                    
                } 
            }
            BanDivNotObj = $g("BanNotification") 
            if(BanDivNotObj){
                if(BanStatus==2){
                    var str = 'Unban ' + _ownerUserName;
                    HtmlStr = writeBlackButtonJS(143,str.toUpperCase(),'BanUser(3);');                    
                }else if(BanStatus==3){
                    var str = 'Ban '+ _ownerUserName;
                    HtmlStr = writeBlackButtonJS(143,str.toUpperCase(),'BanUser(2);');
                }
                BanDivNotObj.innerHTML = HtmlStr;
            }
	    }
	}
}

