﻿  //This file may need altered to accomodate cookie domains
  //It replace the IFram with the following
  //<script src="http://www.gop.com/Remote/RightSide.aspx" language="javascript" id="scripthouse" type="text/javascript"></script>
  //It then injects another .aspx page via the script tag. ('AAA')
  
  
    var sURL =  window.location.href;//unescape(window.location.pathname);
    //var vURL = window.location.href;

    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }
    
    
    function login()
    {
         var uname = document.getElementById('txtFrmUsername').value;
         var pwd = document.getElementById('txtFrmPassword').value;

         //instantiate a call to check validity of credentials.

         var newSE = document.createElement("script");

         //newSE.src='http://localhost/MicroSites/authservice.axd?ua=' + uname + '&uz=' + pwd;
         //NEEDS TO BE TO THE SYSTEM PATH FOR THE SITE
         newSE.src=FilePath + 'AuthService.axd?ua=' + uname + '&uz=' + pwd;
         newSE.id='AAA';
         
         document.body.appendChild(newSE);
       
    }
    
    function processUser(input)
    {
        //Eval the JSON return
        var userObj = eval('(' + input + ')');
       // alert(userObj.status);
        
        if(userObj.status != 'BADUSER' && userObj.status != 'BADPASS')
        {
            //Set the cookie 
            //setCookie(name, value, expires, path, domain, secure)
            //May have to add secure or domain
            //Willl BE RNC2007 cookie name I think
           // setCookie('RNC2007', userObj.key, +30, '/', 'www.gop.com'); 
            setCookie('TkMaDj9101433', userObj.userguid, +30, '/', '.gop.com');          
         
            //Refresh the page
            //OR set the values and set the tabs....
            //window.location.replace(sURL);
            logoutRNC();
            
            window.location.href = sURL;
           
        }
        else
        {
            
            if(userObj.status == 'BADUSER')
            {
                alert('The Usernname you have provided is not valid');
            }
                          
            if(userObj.status == 'BADPASS')
            {
                alert('The Password you have provided is not valid');   
                document.getElementById('txtFrmPassword').value = "";
            }
           
        }

    }

    function getCookie(name) { 
        var sPos = document.cookie.indexOf(name + "="); 
        var len = sPos + name.length + 1; 
        if((!sPos) && (name != document.cookie.substring(0, name.length))){ 
            return null; 
        } 
        if(sPos == -1){ 
            return null; 
        } 
        var ePos = document.cookie.indexOf(';', len); 
        if(ePos == -1) ePos = document.cookie.length; 
        return unescape(document.cookie.substring(len, ePos)); 
    } 

    function setCookie(name, value, expires, path, domain, secure){ 
        var today = new Date(); 
        if(expires){ 
            expires = expires * 1000 * 3600 * 24; 
        } 
        document.cookie = name+'='+escape(value) + 
            ((expires) ? ';expires=' + new Date(today.getTime() + expires).toGMTString() : '') + 
            ((path) ? ';path=' + path : '') + 
            ((domain) ? ';domain=' + domain : '') + 
            ((secure) ? ';secure' : ''); 
    } 

    function deleteCookie(name, path, domain)
    { 
        if(getCookie(name)){ 
            setCookie(name, '', -30, path, domain); 
        } 
    } 


    function logout()
    {
     //Set/Check for all 3 browsers
     //Willl BE RNC2007 cookie name I think
     //setCookie('FreedomProject', userObj.key); 
     
     logoutRNC();
     
     
     
     setCookie('TkMaDj9101433', ''); 
     deleteCookie('TkMaDj9101433', '/', 'gop.com');
     deleteCookie('TkMaDj9101433', '/', '.gop.com');
     setCookie('TkMaDj9101433', null, -30); 
     setCookie('TkMaDj9101433', null, -30, '/', 'gop.com'); 
     setCookie('TkMaDj9101433',  null, -30, '/', '.gop.com');     
     //setCookie('TkMaDj9101433',  null, -30, '/', 'www.gop.com');    
     //alert(sURL);
     //alert(vURL);
     //window.location.replace(sURL);
     window.location.href = sURL;
     //window.location.href;
    }
    
    function logoutRNC()
    {
     setCookie('RNC2007', ''); 
     deleteCookie('RNC2007', '/', 'gop.com');
     deleteCookie('RNC2007', '/', '.gop.com');
     deleteCookie('RNC2007', '/', 'webdev.gop.com');
     deleteCookie('RNC2007', '/', 'webstaging.gop.com');
     setCookie('RNC2007', null, -30); 
     setCookie('RNC2007',  null, -30, '/', 'gop.com'); 
     setCookie('RNC2007',  null, -30, '/', '.gop.com');     
     setCookie('RNC2007',  null, -30, '/', 'oldgop.gop.com');     
     setCookie('RNC2007',  null, -30, '/', 'webdev.gop.com');     
     setCookie('RNC2007',  null, -30, '/', 'webstaging.gop.com');  
    }

function changeTopTabs(d,e)
{
    if(d=='left')
    {
        document.getElementById("topTabLS"+e).className='rtTabLeftSelect';
        document.getElementById("topTabLS"+e).onclick=function () {};
        document.getElementById("topTabLS"+e).onmouseover=function () {this.style.backgroundColor='#EEEEEE'};
        document.getElementById("topTabLS"+e).onmouseout=function () {this.style.backgroundColor='';this.style.cursor=''};
        document.getElementById("topTabRnS"+e).className='rtTabRightNoSelect';
        document.getElementById("topTabRnS"+e).onclick=function () {changeTopTabs('right',e);};
        document.getElementById("topTabRnS"+e).onmouseover=function () {this.style.cursor='pointer'};
        document.getElementById("topTabRnS"+e).onmouseout=function () {this.style.backgroundColor='';this.style.cursor=''};
        document.getElementById("topContentLeft"+e).style.display = 'block';
        document.getElementById("topContentRight"+e).style.display = 'none';
    }
    else
    {
        document.getElementById("topTabRnS"+e).className='rtTabRightSelect';
        document.getElementById("topTabRnS"+e).onclick=function () {};
        document.getElementById("topTabRnS"+e).onmouseover=function () {this.style.backgroundColor='#EEEEEE';};
        document.getElementById("topTabRnS"+e).onmouseout=function () {this.style.backgroundColor='';this.style.cursor='';};
        document.getElementById("topTabLS"+e).className='rtTabLeftNoSelect';
        document.getElementById("topTabLS"+e).onclick=function () {changeTopTabs('left',e);};
        document.getElementById("topTabLS"+e).onmouseover=function () {this.style.cursor='pointer';};
        document.getElementById("topTabLS"+e).onmouseout=function () {this.style.backgroundColor='';this.style.cursor='';};
        document.getElementById("topContentLeft"+e).style.display = 'none';
        document.getElementById("topContentRight"+e).style.display = 'block';

    }
}
function changeBtTabs(d,e)
{
    if(d=='left')
    {
        document.getElementById("btTabLS"+e).className='rtTabLeftSelect';
        document.getElementById("btTabLS"+e).onclick=function () {};
        document.getElementById("btTabLS"+e).onmouseover=function () {this.style.backgroundColor='#EEEEEE'};
        document.getElementById("btTabLS"+e).onmouseout=function () {this.style.backgroundColor='';this.style.cursor=''};
        document.getElementById("btTabRnS"+e).className='rtTabRightNoSelect';
        document.getElementById("btTabRnS"+e).onclick=function () {changeBtTabs('right',e);};
        document.getElementById("btTabRnS"+e).onmouseover=function () {this.style.cursor='pointer'};
        document.getElementById("btTabRnS"+e).onmouseout=function () {this.style.backgroundColor='';this.style.cursor=''};
        document.getElementById("btContentLeft"+e).style.display = 'block';
        document.getElementById("btContentRight"+e).style.display = 'none';
    }
    else
    {
        document.getElementById("btTabRnS"+e).className='rtTabRightSelect';
        document.getElementById("btTabRnS"+e).onclick=function () {};
        document.getElementById("btTabRnS"+e).onmouseover=function () {this.style.backgroundColor='#EEEEEE';};
        document.getElementById("btTabRnS"+e).onmouseout=function () {this.style.backgroundColor='';this.style.cursor='';};
        document.getElementById("btTabLS"+e).className='rtTabLeftNoSelect';
        document.getElementById("btTabLS"+e).onclick=function () {changeBtTabs('left',e);};
        document.getElementById("btTabLS"+e).onmouseover=function () {this.style.cursor='pointer';};
        document.getElementById("btTabLS"+e).onmouseout=function () {this.style.backgroundColor='';this.style.cursor='';};
        document.getElementById("btContentLeft"+e).style.display = 'none';
        document.getElementById("btContentRight"+e).style.display = 'block';

    }
}
function redirect(handle)
{
	var temp = 'http://mysitehandle.gop.com/GroupPage.aspx';
	temp = temp.replace("mysitehandle",handle);
	document.location=temp;
}
function Login()
{
  login();
}
function showFlash()
{            
var filePath = FilePath;
	if(window.location.protocol=="https:")
		filePath = "https://secure.gop.com/";
	else
		filePath = "http://oldgop.gop.com/";
    AC_FL_RunContent( 'codebase','https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','244','height','26','src',filePath +'flash/rnc_W20sm','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie',filePath+'Flash/rnc_W20sm','FlashVars','twoohXML='+filePath+'images/twoohXML2.xml' );
}
