﻿// preload images
var load1=new Image();	//pre-load images
load1.src="images/sendOn.gif";
var load2=new Image();
load2.src = "images/sendOff.gif";
var load3=new Image();	//pre-load images
load3.src="images/confirmOn.gif";
var load4=new Image();
load4.src = "images/confirmOff.gif";

// general function to get URL parameters
function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}

// open the window spec file - for carDetails.asp	
function openWin(fileN, wid, hei) {
    var source = "../" + fileN + '.html';
    win = window.open(source, fileN, "top=0, left=0, width=" + wid + ", height=" + hei + ", status=no, resizable=no, scrollbars=auto")
}

function alertErr(val) 
{
    if (val == 1) {
        alert('El número quehas introducido no es correcto.');
    } 
    if (val == 2) {
        alert('Inserta el codigo');
    }
    if (val == 3) {
        alert('Inserta el codigo');
    }
     
}

function openVideo()
{
    var win;
	win = window.open("http://www.coachinginteractive.com/TheWork/ShowVideo.asp?V_ID=0", "videoDemo", "top=0, left=0, width=500, height=400, status=no, resizable, scrollbars=no");
	window.focus;
}



function displayForm()
{
    if (document.getElementById("part2Form").style.display == 'none')
    {
        document.getElementById("part2Form").style.display = 'inline';
        document.getElementById("confirmBtn").style.display = 'none';
    }
}


// check mobile phone
function checkForm() {
    var msg = '';


    if (document.getElementById("mobile").value == '') {
        alert('Por favor inserte su número de móvil');
        return false;
    }

    if (isNaN(document.getElementById("mobile").value)) {
        alert('Inserte solo números!');
        return false;
    }
    
    

    return true;
}


// check pin code
function checkPin() {
    var msg = '';


    if (document.getElementById("mobile").value == '') {
        document.getElementById("baloonText").innerHTML = 'Inserta el codigo';
        document.getElementById("baloon").style.display = 'inline';
        return false;
    }

    return true;
}


// display the movie of trade if thankYouC.html
function displayMovie()
{
    document.getElementById('imgGraphC').style.display = 'none';
    document.getElementById('movieTrade').style.display = 'inline';
}

// display the movie of trade if thankYouC.html
function displayMovieSmall()
{
    document.getElementById('imgGraphD').style.display = 'none';
    document.getElementById('movieTradeS').style.display = 'inline';
}

// hide the movie of trade if thankYouC.html
function hideMovie()
{
    document.getElementById('imgGraphC').style.display = 'inline';
    document.getElementById('movieTrade').style.display = 'none';
}

// add to favorites
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
