﻿// JScript File
var secondvalue = 100;
var id;
var secondid;
var thirdid;
var num = 1;

function pageWidth() {
  return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
  }

// calculate the current window height //
function pageHeight() {
  return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}

// calculate the current window vertical offset //
function topPosition() {
  return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

// calculate the position starting at the left of the window //
function leftPosition() {
  return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}


function doFade(){

if(secondvalue > 0){
secondvalue = secondvalue - 5;
var doc = document.getElementById('NewsPanel');
doc.style.opacity = (secondvalue / 100);
doc.style.filter = 'alpha(opacity=' + secondvalue + ')';
id = window.setTimeout("doFade()", 100);
} else {
//var doc = document.getElementById('NewsPanel');
clearTimeout(id);
clearTimeout(thirdid);
//doc.style.visibility = 'hidden';
changeNews();
}

}

function startFade(){
thirdid = setTimeout("doFade()",18000);
}

function reverseFade(){
//var doc = document.getElementById('NewsPanel');
//doc.style.visibility = 'visible';

//doc.style.opacity = (75 / 100);
//doc.style.filter = 'alpha(opacity=' + 75 + ')';
realReverseFade();
}

function realReverseFade(){
if(secondvalue < 100){
secondvalue = secondvalue + 5;
var doc = document.getElementById('NewsPanel');
doc.style.opacity = (secondvalue / 100);
doc.style.filter = 'alpha(opacity=' + secondvalue + ')';
secondid = setTimeout('realReverseFade()', 100);
}else{
clearTimeout(secondid);
startFade();
}


}

function changeNews(){

if(num <= count){

var div1 = document.getElementById('NewsPanelHeader');
var div2 = document.getElementById('NewsPanelContents');
var div3 = document.getElementById('NewsPanelImage');
div1.innerText = newsHeaders[num];
div2.innerHTML = newsContents[num];
div3.src = newsImages[num].src;
reverseFade();
num = num + 1;

} else {

num = 0;
var div1 = document.getElementById('NewsPanelHeader');
var div2 = document.getElementById('NewsPanelContents');
var div3 = document.getElementById('NewsPanelImage');
div1.innerText = newsHeaders[num];
div2.innerHTML = newsContents[num];
div3.src = newsImages[num].src;
reverseFade();
num = num + 1;
}

}


function changeImage(member){

myButton = new Image;
myButton.src = "aboutusdropdownova.gif";
member.style.backgroundImage = "url('" + myButton.src + "')";

}

function changeImageBack(member){

member.style.backgroundImage = "none";

}

function aboutUsDropShow(){
var drop = document.getElementById('AboutUsDropDown');
if(drop.style.visibility == 'hidden'){
drop.style.visibility = 'visible';
} else if (drop.style.visibility == 'visible'){
drop.style.visibility = 'hidden';
}
}

function labDropShow(){
var drop = document.getElementById('LabDropDown');
if(drop.style.visibility == 'hidden'){
drop.style.visibility = 'visible';
} else if (drop.style.visibility == 'visible'){
drop.style.visibility = 'hidden';
}
}

function mouseover(ObjectItem){

if(ObjectItem.style.height == "132px"){
ObjectItem.style.border = "#006600 1px solid";
}

}

function mouseout(ObjectItem){

if(ObjectItem.style.height == "132px"){
ObjectItem.style.border = "#ffffff 1px solid";
}

}

function clickIretiTab(){

var iretitab = document.getElementById("IretiTab").style.height;
if(iretitab == "252px"){
hideIretiTab();
} else {
showIretiTab();
}

}

function showIretiTab(){

var iretitab = document.getElementById("IretiTab");
iretitab.style.height = "252px";
iretitab.style.border = "#AB743B 1px solid";
var ireticontents = document.getElementById("IretiTabContents");
ireticontents.innerHTML = "Ireti doesn't just pass for the average analyst, she is a practical one! A graduate of Psychology, University of Ibadan - Nigeria, she runs our marketing department.<br /><br />Iretiogo F. Ilori injects into the marketing department that balance between PASSION &amp; REALITY, which makes us wonder if she was born do it! Analytical, deep sense of reasoning and composed is how we describe her.<br /><br />Ireti is also presently on the board of several companies and currently the CEO of Goodly Pearls, a branding and design company.";

}

function hideIretiTab(){

var iretitab = document.getElementById("IretiTab");
iretitab.style.height = "132px";
iretitab.style.border = "#ffffff 1px solid";
var ireticontents = document.getElementById("IretiTabContents");
ireticontents.innerHTML = "";

}

function clickAyoTab(){

var ayotab = document.getElementById("AyoTab").style.height;
if(ayotab == "234px"){
hideAyoTab();
} else {
showAyoTab();
}

}

function showAyoTab(){

var ayotab = document.getElementById("AyoTab");
ayotab.style.height = "234px";
ayotab.style.border = "#AB743B 1px solid";
var ayocontents = document.getElementById("AyoTabContents");
ayocontents.innerHTML = "Rarely would you find a company's marketplace obsession headed by an engineer. A major in engineering and an excellent business thinker, Ogunlowo Ayoola can make any MBA holder green with envy!<br /><br />Currently our Chief Technology Officer, Ayo knows well how to grind our products/services into the market. He is also responsible for our Customer Service Framework.<br /><br />With Ayo, we know there is no way we won't keep listening to our customers or stop providing solutions they need.";

}

function hideAyoTab(){

var ayotab = document.getElementById("AyoTab");
ayotab.style.height = "132px";
ayotab.style.border = "#ffffff 1px solid";
var ayocontents = document.getElementById("AyoTabContents");
ayocontents.innerHTML = "";

}

function clickOriakuTab(){

var oriakuTab = document.getElementById("OriakuTab").style.height;
if(oriakuTab == "200px"){
hideOriakuTab();
} else {
showOriakuTab();
}

}

function showOriakuTab(){

var oriakuTab = document.getElementById("OriakuTab");
oriakuTab.style.height = "200px";
oriakuTab.style.border = "#AB743B 1px solid";
var oriakucontents = document.getElementById("OriakuTabContents");
oriakucontents.innerHTML = "Mobile Apps is serious business and we have got Oriaku Samuel on our team to prove that<br/><br/>Samuel, in charge of our mobile unit, is one brillant chap, that helps us stand out from the pack.<br/><br/>This is certainly one guy who you would love to have on your side in case of a war!";

}

function hideOriakuTab(){

var oriakutab = document.getElementById("OriakuTab");
oriakutab.style.height = "132px";
oriakutab.style.border = "#ffffff 1px solid";
var oriakucontents = document.getElementById("OriakuTabContents");
oriakucontents.innerHTML = "";

}

function clickReubenTab(){

var reubentab = document.getElementById("ReubenTab").style.height;
if(reubentab == "260px"){
hideReubenTab();
} else {
showReubenTab();
}

}

function showReubenTab(){

var reubentab = document.getElementById("ReubenTab");
reubentab.style.height = "260px";
reubentab.style.border = "#AB743B 1px solid";
var reubencontents = document.getElementById("ReubenTabContents");
reubencontents.innerHTML = "Responsible for the leadership, focus &amp; direction of the team, Sir Bezaleel Ashefor is no small catch! Having worked at a number of stealth companies, where he was responsible for breaking into and fixing their security systems, he set up tent with the Ephod train.<br /><br />He has eyes set on the software technology market, that his stare can actually be felt. Witty, desirous and extraordinary is what goes for Sir Bezaleel.<br /><br />Asked if he weren't into programming and business what would he do, he replied 'NASCAR or Formula 1, I'm a pretty damn good racer!'"
}

function hideReubenTab(){

var reubentab = document.getElementById("ReubenTab");
reubentab.style.height = "132px";
reubentab.style.border = "#ffffff 1px solid";
var reubencontents = document.getElementById("ReubenTabContents");
reubencontents.innerHTML = "";

}

function clickAyinlaTab(){

var ayinlatab = document.getElementById("AyinlaTab").style.height;
if(ayinlatab == "200px"){
hideAyinlaTab();
} else {
showAyinlaTab();
}

}

function showAyinlaTab(){

var ayinlatab = document.getElementById("AyinlaTab");
ayinlatab.style.height = "200px";
ayinlatab.style.border = "#AB743B 1px solid";
var ayinlacontents = document.getElementById("AyinlaTabContents");
ayinlacontents.innerHTML = "Ayinla Oluwaseye, a senior programmer, is not your average gamer; don't not attempt to take on him with a game controller!<br/><br/> Seye, brings coding methods and styles that makes even the veteran programmer green with envy. <br/><br/> He is almost a rock star at codes, err.. let's call him a Mountain Star! :)"
}

function hideAyinlaTab(){

var ayinlatab = document.getElementById("AyinlaTab");
ayinlatab.style.height = "132px";
ayinlatab.style.border = "#ffffff 1px solid";
var ayinlacontents = document.getElementById("AyinlaTabContents");
ayinlacontents.innerHTML = "";

}


function clickIsmailTab(){

var ismailtab = document.getElementById("IsmailTab").style.height;
if(ismailtab == "190px"){
hideIsmailTab();
} else {
showIsmailTab();
}

}

function showIsmailTab(){

var ismailtab = document.getElementById("IsmailTab");
ismailtab.style.height = "190px";
ismailtab.style.border = "#AB743B 1px solid";
var ismailcontents = document.getElementById("IsmailTabContents");
ismailcontents.innerHTML = "Ismail Oguntoyinbo to us is the equivalent of a rock star, adept at gasping coding knowledge and proficient with many programming languages, talking about coding-lingua. <br/><br/>A senior programmer at Ephod, he chunks in codes into our products creating and giving them life forms. <br/><br/>Err, Nickname: HOD"
}

function hideIsmailTab(){

var ismailtab = document.getElementById("IsmailTab");
ismailtab.style.height = "132px";
ismailtab.style.border = "#ffffff 1px solid";
var ismailcontents = document.getElementById("IsmailTabContents");
ismailcontents.innerHTML = "";

}

function clickBamiseTab(){

var bamisetab = document.getElementById("BamiseTab").style.height;
if(bamisetab == "240px"){
hideBamiseTab();
} else {
showBamiseTab();
}

}

function showBamiseTab(){

var bamisetab = document.getElementById("BamiseTab");
bamisetab.style.height = "240px";
bamisetab.style.border = "#AB743B 1px solid";
var bamisecontents = document.getElementById("BamiseTabContents");
bamisecontents.innerHTML = "We are glad to tell you that we have on our team, the only superwoman to have ever existed. Oyewale Bamise; an economics graduate of the University Of Ibadan; SuperBowl 2011 Finalist U.I; a business-bred action figure, is the brain solely in charge of our financial unit.<br/><br/>As a startup, Bamise is exactly the right force we need, constantly working and making sure we never see the red mark!<br/><br/>Also, in her spare time, did we mention that she saves the world?"
}

function hideBamiseTab(){

var bamisetab = document.getElementById("BamiseTab");
bamisetab.style.height = "132px";
bamisetab.style.border = "#ffffff 1px solid";
var bamisecontents = document.getElementById("BamiseTabContents");
bamisecontents.innerHTML = "";

}



function showCustomerCollectInfo(){
createDialog();
}

function createDialog(){
if(!document.getElementById("Dialog")){
var dialog = document.createElement('div');
var innerdialog = document.createElement('div');
var closebtn = document.createElement('img');
var header = document.createElement('div');
var contents = document.createElement('div');
var contentsII = document.createElement('div');
var button = document.createElement('div');
var loader = document.createElement('img');

loader.id = 'loader';
loader.src = 'load.gif';
loader.style.visibility = 'hidden';
loader.style.position = 'absolute';
loader.style.right = '130px';
loader.style.bottom = '20px';

button.id = "Button";
button.innerHTML = "<a href='#' style='cursor:pointer' id='ButtonLink' onclick='addCustomerDetails(1);'><img src='downloadbtn.png' border='0' style='border:#ffffff 1px solid'/></a>"

contents.id = "Contents";
contents.innerHTML = "<span id='NameText'>Your Name:</span>&nbsp;&nbsp;<input type='text' id='NameBox' style='width:200px;height:23px;padding-left:2px;font-weight:bold'/>";

contentsII.id = "ContentsII";
contentsII.innerHTML = "<span id='MailText'>Your E-mail:</span>&nbsp;&nbsp;<input type='text' id='MailBox' style='width:200px;height:23px;padding-left:2px;font-weight:bold' onkeyup='checkDetails();'/>";

closebtn.id = "CloseBtn";
closebtn.src = "closebtn.png";
closebtn.style.position = 'absolute';
closebtn.style.left = "488px";
closebtn.style.top = "-12px";
closebtn.style.cursor = "pointer";
closebtn.setAttribute('onclick','closeDialog();')
//closebtn.onclick = closeDialog();

header.id = "Header";
header.style.width = "470px";
header.style.height = "50px";
header.style.position = "absolute";
header.style.left = "10px";
header.style.top = "5px";
header.innerHTML = "<span>You are a step away from downloading your own ChattaBox! We just need a few details from you, we would use it only to provide product support for you and promise not to provide it to third-party guys. The download button doesn't become enabled until you enter your correct details! After download, transfer ChattaBox to your mobile phone.</span>";

dialog.id = "Dialog";
dialog.style.width = pageWidth() + 'px';
dialog.style.height = pageHeight() + 'px';
innerdialog.id = "InnerDialog";
var width = pageWidth();
var height = pageHeight();

var xPosition = (width / 2) - (500 / 2);
var yPosition = (height / 2) - (250 / 2);

innerdialog.style.width = '500px';
innerdialog.style.height = '250px';
innerdialog.style.left = xPosition + "px";
innerdialog.style.top = yPosition + "px";

innerdialog.appendChild(loader);
innerdialog.appendChild(button);
innerdialog.appendChild(closebtn);
innerdialog.appendChild(header);
innerdialog.appendChild(contents);
innerdialog.appendChild(contentsII);
document.body.appendChild(innerdialog);
document.body.appendChild(dialog);
} else {
var dialog = document.getElementById("Dialog");
dialog.style.visibility = "visible";
var innerdialog = document.getElementById("InnerDialog");
innerdialog.style.visibility = "visible";
document.getElementById('NameBox').value = "";
document.getElementById('MailBox').value = "";
document.getElementById('Header').innerHTML = "<span>You are a step away from downloading your own ChattaBox! We just need a few details from you, we would use it only to provide product support for you and promise not to provide it to third-party guys. The download button doesn't become enabled until you enter your correct details! After download, transfer ChattaBox to your mobile phone.</span>";
}
}

function closeDialog(){
var dialog = document.getElementById("Dialog");
dialog.style.visibility = "hidden";
var innerdialog = document.getElementById("InnerDialog");
innerdialog.style.visibility = "hidden";
var button = document.getElementById("Button");
button.style.visibility = "hidden";
}

function checkDetails(){
var namebox = document.getElementById("NameBox");
var mailbox = document.getElementById("MailBox");
var downloadbtn = document.getElementById("Button");
var emailchecker = mailbox.value.indexOf("@");
var dotchecker = mailbox.value.indexOf(".");

if (namebox.value.length == 0){
downloadbtn.style.visibility = "hidden";
} else if (mailbox.value.length == 0){
downloadbtn.style.visibility = "hidden";
} else if (emailchecker == -1){
downloadbtn.style.visibility = "hidden";
} else if (dotchecker == -1){
downloadbtn.style.visibility = "hidden";
} else {
downloadbtn.style.visibility = "visible";
}

}


function addCustomerDetails(argument){
var loader = document.getElementById('loader');
var name = document.getElementById('NameBox').value;
var mail = document.getElementById('MailBox').value;
loader.style.visibility = 'visible';
var letter = argument;
var div = document.getElementById('Header');
var XMLHttp = GetXMLHttpObject();
  XMLHttp.onreadystatechange=function (){
    if(XMLHttp.readyState==4){
        if(XMLHttp.status==200){
        var response = XMLHttp.responseText;   
        div.innerHTML = response;
        loader.style.visibility = 'hidden';
        location.href = "softwares/ChattaBox.jar";
        } else {
        div.innerHTML = "<span style='font-family:Georgia, Tahoma; font-size: 12px; font-weight:bold;'>Aw! Something didn't go right. Could you try again?<span>";
         loader.style.visibility = 'hidden';
        //Error Occured
        }
       } else {
    //Show Loading Image
    }
}
    var url = "ajaxer.aspx?ID="+letter+"&Name="+name+"&Mail="+mail+"&Product=ChattaBox v2.0.1";
    XMLHttp.open("GET", url, true);
    XMLHttp.send(null)
}

function GetXMLHttpObject(){
var XMLHttpII;
try{
//FireFox, Opera & Safari
XMLHttpII = new XMLHttpRequest();
} catch(e){
//I.E
    try{
    XMLHttpII = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e){
        try{
        XMLHttpII = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e){
        XMLHttpII = null;   
        }
}

}
return XMLHttpII;
}

function hideDialogBox(){
var div = document.getElementById("DialogBox");
div.style.visibility = "hidden";
}
