﻿// JScript File
var type = "IE";	//Variable used to hold the browser name
// Use a variable to reference the embedded SWF.
var flashVideoPlayer;
var flashPhotoPlayer;
var att = { data: "test.swf", width: "1024", height: "832" }; //for photoplayer creation

BrowserSniffer();

//detects the capabilities of the browser
function BrowserSniffer() {
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";		//Opera
	else if (document.all) type="IE";														//Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="NN";													//Netscape Communicator 4
	else if (!document.all && document.getElementById) type="MO";							//Mozila e.g. Netscape 6 upwards
	else type = "IE";		//I assume it will not get here
}

/* When the HTML page loads (via the onLoad event of the <body> tag) we have it call the initialize() function. */
function initialize() {	      
	/* Check if the browser is IE. If so, flashVideoPlayer is window.videoPlayer. Otherwise, it's            window.document.videoPlayer. The videoPlayer is the id assigned to <object> and <embed> tags. */
	var ie = navigator.appName.indexOf("Microsoft") != -1;
	flashVideoPlayer = (ie) ? window['PopupPlayer'] : document['PopupPlayer'];
	flashPhotoPlayer = (ie) ? window['photoplayer'] : document['photoplayer'];
}


/* When the user clicks the play button in the form, update the videoStatus textarea, and call the playVideo() function within the SWF, passing it the URL of the FLV file. */
function callFlashPlayVideo(file, title, width, height) {
    var x=width,y=height;			    
    var FO = {	movie:"videos/PopupPlayer.swf",width:x,height:y,majorversion:"7",build:"0",bgcolor:"#FFFFFF",allowfullscreen:"true",
		flashvars:"file="+file+"&image=preview.jpg&autostart=true" };
    if (type =="MO"|| type=="OP"){	   
        var tv= document.getElementById("PlayVideo");  
        tv.style.visibility = "visible";
    }
    document.getElementById("VideoTitle").innerHTML = title;     
	UFO.create(	FO, "player1");
}

function popupPlayVideo(playlist, title, width, height) {
    callFlashPlayVideo(playlist, title, width, height);
	$('#PlayVideo').modal();
	return false;
}

/* When the user clicks the play button in the form, update the videoStatus textarea, and call the playPhoto() function within the SWF, passing it the URL of the FLV file. */
function callFlashPlayPhoto(file, title, width, height) {
    var x = width, y = height, f = file;
    var FO = { movie: f, width: x, height: y, majorversion:"4.88",build:"0"};    
    if (type == "MO" || type == "OP") {
        var tv = document.getElementById("PlayPhoto");
        tv.style.visibility = "visible";
    }
    document.getElementById("PhotoTitle").innerHTML = title;     
    UFO.create(FO, "player2");
}

function popupPlayPhoto(file, title, width, height) {
    //callSWFObjectPlayPhoto(file, title, width, height);
    callFlashPlayPhoto(file, title, width, height);
    $('#PlayPhoto').modal();
    return false;
}

function callFlashPlayAlbum(file, title, width, height) {
    var x = width, y = height, f = file;
    var FO = { movie: f, width: x, height: y, majorversion: "4.88", build: "0" };
    if (type == "MO" || type == "OP") {
        var tv = document.getElementById("PlayAlbum");
        tv.style.visibility = "visible";
    }
    document.getElementById("AlbumTitle").innerHTML = title;
    UFO.create(FO, "player3");
}

function popupPlayAlbum(file, title, width, height) {
    callFlashPlayAlbum(file, title, width, height);
    $('#PlayAlbum').modal();
    return false;
}

function ValidateForm() {        
    var email = document.getElementById("XX-email");
    
    if (document.getElementById("XX-name").value.trim() == "") {
        alert("Please enter your name");
        return false;
    } else if (email.value.trim() == "") {
       alert("Please enter your email");
        return false;
    } else if (validate_email(email, "Not a valid e-mail address!") == false) {        
         email.focus(); 
         return false;         
    }else if (document.getElementById("Comments").value.trim() == "") {
        alert("Please enter comments");
        return false;
    }
    alert("Your message are being sent, we will be with you shortly. Thank you for your interest in our services.");
    return true;
}

function validate_email(field, alerttxt) {
    with (field) {
        apos = value.indexOf("@");
        dotpos = value.lastIndexOf(".");
        if (apos < 1 || dotpos - apos < 2)
        { alert(alerttxt); return false; }
        else { return true; }
    }
}

function showFlash() {
    document.getElementById("player2").style.visibility = "visible";    //display="block"
}

function hideFlash() {
    document.getElementById("player2").style.visibility = "hidden"; // visibility = "hidden";    //display="none"
}


function callSWFObjectPlayPhoto(file, title, width, height) {
    var x = width, y = height, f = file;
    var FO = { movie: f, width: x, height: y, majorversion: "4.88", build: "0" };
    if (type == "MO" || type == "OP") {
        var tv = document.getElementById("PlayPhoto");
        tv.style.visibility = "visible";
    }
    document.getElementById("PhotoTitle").innerHTML = title;
    att = { data: file, width: x, height: y };// set attribute for createSWF function of swfobject
    create();
}

/*
//beginning of swfobject functions

function create() {
    if (swfobject.hasFlashPlayerVersion("6")) {
        // check if SWF hasn't been removed, if this is the case, create a new alternative content container
        var c = document.getElementById("contentplayer"); //avoid name conflict with player2
        if (!c) {
            var d = document.createElement("div");
            d.setAttribute("id", "contentplayer");
            document.getElementById("PhotoContent").appendChild(d);
        }
        // create SWF
        // att is set from parent calling function
        var par = { menu: "false" };
        var id = "contentplayer";
        swfobject.createSWF(att, par, id);
    }
}
function remove() {
    swfobject.removeSWF("contentplayer");
}
function addHandlers() {
    var c = document.getElementById("create");
    if (c) {
        c.onclick = function() {
            create();
            return false;
        };
    }
    var r = document.getElementById("remove");
    if (r) {
        r.onclick = function() {
            remove();
            return false;
        };
    }
}
swfobject.addLoadEvent(addHandlers);

// end of swfobject functions

*/
