/*                                                                              
* Tylie Jones Website        
* 09.01.10 - jvw - msv technology
*/

     
 
// ROLLOVER FUNCTIONS    image swap             
function rollover(element,image_on){ 
    var div = document.getElementById(element); 
    div.src = image_on;        
}    
function rollout(element,image_off){ 
    var div = document.getElementById(element); 
    div.src = image_off;        
}    

function rolloverHighlight(element,color, instance){ 
    var div = document.getElementById(element);   
    if (instance=='0'){     
            div.style.color = color;            
     }else if (instance=='1'){    
            div.style.backgroundColor = color;  
     }  
}    


function cursor_hand() {
document.body.style.cursor = 'pointer';
}           
function cursor_clear() {
document.body.style.cursor = 'default';
}

 
 
// OPEN POP-UP WINDOW
function open_window(URL,w, h, n, t,l,d,st,m,sc,r){   
    var win =window.open(URL, n,"toolbar="+t+",loaction="+l+",directories="+d+",status="+st+",menubar="+m+",scrollbars="+sc+",resizeable="+r+",width="+w+", height="+h+"");
    win.focus();
}

// RE-DIRECT USERS
function js_redirect(URL){
    window.location = URL;
}



//DROP-DOWN MENUS  - open & close MENUS
menuClick='off';   
function mopenClose(){    
    //alert(menuClick);       
    if(menuClick == null) menuClick = 'off';
    if(menuClick=='off'){
        menuClick = 'on';
    }else{
        menuClick = 'off';
    }
    /*
    alert(menuClick);
    menuitem = document.getElementById(id);
    if(menuitem != null){ 
        if(menuitem.style.visibility === 'hidden'){
            menuitem.style.visibility = 'visible';
        }else{
            menuitem.style.visibility = 'hidden';
        }
    }
    */
}             
function mopen(id){    
    validateLogInFormBkg();
    menuitem = document.getElementById(id);
    menuitem.style.visibility = 'visible';
    if(id=='m1'){
        var image = document.getElementById('partnerLogInButton');
        if(image != null){
            rollover('partnerLogInButton','images/display/buttons/partnerLogInOn.png');    
        }
    }
}  

function validateLogInFormBkg(){
    var username = document.getElementById('username');
    if(username !== null){
        if(username.value !== ''){
            username.style.backgroundImage ='';
        }  
    }                                                                                                       
    var password = document.getElementById('password');
    if(password !== null){
        if(password.value !== ''){                                                           
            password.style.backgroundImage ='';
        }  
    }        
}
   
function changeFormAction(){
    var form = document.getElementById('location');
    var location = document.getElementById('location').value;
    if(location == '1'){
        document.forms['logInFormForm'].action = 'http://66.104.241.105/website_aspera_login.asp';
    }else{         
        document.forms['logInFormForm'].action = '';   
    }
}        
function mclose(id){
    if(menuClick == null) menuClick = 'off';
    if(menuClick=='off'){
        menuitem = document.getElementById(id);
        if(menuitem) menuitem.style.visibility = 'hidden';
        if(id=='m1'){
            var image = document.getElementById('partnerLogInButton');
            if(image != null){
                rollover('partnerLogInButton','images/display/buttons/partnerLogIn.png');    
            }
        }
    }else{
        
    }
}   
 
function styleLogInForm(id,state,bkgImage){
    var input = document.getElementById(id);
    if(input !== null){      
        /*
        if(id=='username'){
            */
        if(state== 'on'){
            if(input.value == '')input.style.backgroundImage = '';
        }else{   
            if(input.value == '')input.style.backgroundImage = "url('"+bkgImage+"')";
        }
            /*
        }else if(id=='password'){  
            if(state== 'on'){
                if(input.value == '')input.style.backgroundImage = 'images/display/logInFormBkg'+id+'.png'
            }else{   
                if(input.value == '')input.style.backgroundImage = 'images/display/logInFormBkg'+id+'.png'
            }
            
        }
        */
    }
}           




//videoOverlay  - open & close Videos
function vopen(id,t,w,h,f,ox,oy,d){    
                                                     
    var container = document.getElementById('container');   
    var videoplayer = document.getElementById('videoContainer');   
    var bkgOverlay = document.getElementById('videoOverlay');
    if(bkgOverlay) bkgOverlay.style.visibility = 'visible';      
    if(bkgOverlay) bkgOverlay.style.display = 'block';      
    var bkgOverlay1 = document.getElementById('videoOverlay1');
    if(bkgOverlay1) bkgOverlay1.style.visibility = 'visible';      
    if(bkgOverlay1) bkgOverlay1.style.display = 'block';   
    var logo = document.getElementById('tjaLogo');
    if(logo) logo.src = 'images/display/logos/tjaLogoWhite.png';
    var banner = document.getElementById('tjaBanner');
    if(banner) banner.src = 'images/display/logos/tjaBannerWhite.png';
       
    pauseSlideshow();
            
    /*
    var body = document.getElementById('HMTLbody');  
    if(body) body.style.backgroundColor = '363636';   
    /*if(bkgOverlay) bkgOverlay.style.display = 'block';      */
    /*
    
    // QUICKTIME VIDEO:    
    videoplayer.innerHTML = '<object width="'+w+'" height="'+h+'" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" style="background-color: #000000; padding: 0px;">'+
    '<param name="src" value="'+id+'" />'+ 
    '<param name="href" value="'+id+'" />'+ 
    '<param name="target" value="myself" />'+ 
    '<param name="controller" value="true" />'+ 
    '<param name="autoplay" value="true" />'+ 
    '<param name="scale" value="aspect" />'+         
    '<embed width="'+w+'" height="'+h+'" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"'+
    '    src="'+id+'" target="myself" controller="true" autoplay="true" scale="aspect" style="background-color: #000000; padding: 0px;"></embed>'+
    '</object>';   
    */
    /*
    // FLASH VIDEO:    
    videoplayer.innerHTML = '<table border="0" cellpadding="0" cellspacing="0"  id="embeddVideo" '+
    ' >'+
    '<tr>'+
    '<td valign="center" align="center" >'+
    '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" '+
    'width="'+w+'" height="'+h+'" id="flvPlayer_FlashFile" align="middle" >'+
    '<param name="allowScriptAccess" value="sameDomain" />'+
    '<param name="allowFullScreen" value="false" />'+
    '<param name="movie" value="flvPlayer_FlashFile.swf" />'+
    '<param name="quality" value="high" />'+
    '<param name="bgcolor" value="#000000" />'+     
    '<PARAM NAME="flashVars" VALUE="vfile='+id+'" />'+
    '<embed src="flvPlayer_FlashFile.swf" quality="high" bgcolor="#000000" width="'+w+'" height="'+h+'" '+
    'FlashVars="vfile='+id+'"  '+
    ' name="flvPlayer_FlashFile" align="middle" '+
    ' allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" '+
    ' pluginspage="http://www.adobe.com/go/getflashplayer" /> '+
    '</object>  '+
    '</td></tr>'+
    '</table>';  
     */
    //getVideoPlayer(id,t,w,h,f,o,d);  
    getVideoPlayer(id,t,w,h,f,ox,oy,d);
}             

function vclose(id){                                  
    var container = document.getElementById('container');   
    var videoplayer = document.getElementById('videoContainer');
    videoplayer.innerHTML = '';
    var bkgOverlay = document.getElementById('videoOverlay');
    if(bkgOverlay) bkgOverlay.style.visibility = 'hidden';                     
    if(bkgOverlay) bkgOverlay.style.diplay = 'none';      
    var bkgOverlay1 = document.getElementById('videoOverlay1');
    if(bkgOverlay1) bkgOverlay1.style.visibility = 'hidden';      
    if(bkgOverlay1) bkgOverlay1.style.display = 'none';
    var logo = document.getElementById('tjaLogo');
    if(logo) logo.src = 'images/display/logos/tjaLogo.png';
    var banner = document.getElementById('tjaBanner');
    if(banner) banner.src = 'images/display/logos/tjaBanner.png';
                                    
    resumeSlideshow();
    
    /*
    var body = document.getElementById('HMTLbody');      
    if(body) body.style.backgroundColor = 'ffffff';       
    /* if(bkgOverlay) bkgOverlay.style.display = 'none';        */
}               



//Check flash Version
function get_flashVersion(){  
    var flashVersion = 0;
    var arr = navigator.plugins;
    for(var i=0;i<arr.length;i++){                                         
        var str = arr[i].description; 
        var patt1 = /flash/gi;
        var flashinstalled = str.match(patt1);
        if(flashinstalled != null) {
            //alert(arr[i].version);
            var flashVer = arr[i].version;
            if(flashVer != null){
                flashVerArrr = flashVer.split('.');
                var flashVersion = flashVerArrr[0];
            }else{              
                var flashVersion = 0;
            }                                  
            //alert (flashVersion);
        }     
    }
    return flashVersion;
}                                     
                  
//Check quicktime Version
function get_qtVersion(){  
    var qtVersion = 0;
    var arr = navigator.plugins;
    for(var i=0;i<arr.length;i++){                                         
        var str = arr[i].description; 
        var patt1 = /quicktime/gi;
        var qtinstalled = str.match(patt1);
        if(qtinstalled != null) {
            //alert(arr[i].version);
            var qtVer = arr[i].version;
            qtVerArrr = qtVer.split('.');
            var qtVersion = qtVerArrr[0];
            //alert (qtVersion);
        }     
    }
    return qtVersion;
}                                     
          
                      
//ie detect plugin ('flash' or 'quicktime')       
function detectPlugin(type) {
    var isInstalled = false; 
    var version = null;  
    if(type=='flash'){      
        if (window.ActiveXObject) {  
            var control = null;  
            try {  
                control = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');  
            } catch (e) {  
                return;  
            }  
            if (control) {  
                isInstalled = true;  
                version = control.GetVariable('$version').substring(4);  
                version = version.split(',');  
                version = parseFloat(version[0] + '.' + version[1]);  
            }  
        } else {  
            // Check navigator.plugins for "Shockwave Flash"  
            var flash_version = get_flashVersion();
            if(flash_version > 0){ 
                isInstalled = true;  
            }
        }  
    }else if(type=='quicktime'){     
        if (window.ActiveXObject) {  
            var control = null;  
            try {  
                control = new ActiveXObject('QuickTime.QuickTime');  
            } catch (e) {  
                // Do nothing  
            }  
            if (control) {  
                // In case QuickTimeCheckObject.QuickTimeCheck does not exist  
                isInstalled = true;  
            }  
            try {  
                // This generates a user prompt in Internet Explorer 7  
                control = new ActiveXObject('QuickTimeCheckObject.QuickTimeCheck');  
            } catch (e) {  
                return;  
            }  
            if (control) {  
                // In case QuickTime.QuickTime does not exist  
                isInstalled = true;  
                // Get version  
                version = control.QuickTimeVersion.toString(16); // Convert to hex  
                version = version.substring(0, 1) + '.' + version.substring(1, 3);  
                version = parseFloat(version);  
            }  
        } else {  
            // Check navigator.plugins for "QuickTime Plug-in"  
            var qt_version = get_qtVersion();
            if(qt_version > 0){ 
                isInstalled = true;  
            }
        }        
    } else{
        // do nothing    
    }     
                        
    return isInstalled;
} // detectPlugin


  

//getPlayer
function getVideoPlayer(v,t,w,h,f,ox,oy,dir){
    if( dir == null){
        var dir = 'videos/';
    } 
    if((navigator.userAgent.match(/chrome/i)) || (navigator.userAgent.match(/safari/i)) ) {   
        var PluginType = 'flash';
    }else{             
        //var flashVersion = get_flashVersion();
        //var PluginType = 'none';
                          
        var flashInstalled = detectPlugin('flash');   
        if(flashInstalled == true){
            var PluginType = 'flash';    
        }else{              
            var qtInstalled = detectPlugin('quicktime'); 
            if(qtInstalled == true){
                var PluginType = 'quicktime';
            }else{      
                var PluginType = 'none';
            }              
        }
    }
    
        /*
          */
    //var PluginType = 'flash';
    //alert (PluginType);
                             
    var URL = 'includes/modules/ajax/videoPlayer.php?v='+v+'&t='+t+'&w='+w+'&h='+h+'&f='+PluginType+'&ox='+ox+'&oy='+oy+'&d='+dir;
    //alert(URL); 
    
      
    var AjaxResponse = $.ajax({
        url: URL,
        async: false
    }).responseText;     
    
    //var AjaxResponse=ajaxFunction(URL);              
            
    var videoplayer = document.getElementById('videoContainer');
    videoplayer.innerHTML = AjaxResponse;

}


     
