// JavaScript Document


function flashScreen(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
	

	
} 	

function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
	
}

function getRid() {

setTimeout("flashRem();",1000)

}

function flashRem() {
					 
document.getElementById('flash').style.display='none';

}


function changeDiv(div) {

document.getElementById('mainDiv').innerHTML=document.getElementById(div).innerHTML;

}


function checkDiv(div) {

if (document.getElementById(div).style.display=='none')

document.getElementById(div).style.display='block'


else

document.getElementById(div).style.display='none'

}


function checkDiv2(div) {
document.getElementById('careersDiv').style.display='none'
document.getElementById('aboutSpan').style.visibility='hidden'
document.getElementById('pricesSpan').style.visibility='hidden'
document.getElementById('aboutk2Span').style.visibility='hidden'
document.getElementById('timesSpan').style.visibility='hidden'
document.getElementById('directionsSpan').style.visibility='hidden'
document.getElementById('testimonialsSpan').style.visibility='hidden'
document.getElementById('contactSpan').style.visibility='hidden'
//document.getElementById('collectionsSpan').style.visibility='hidden'
//document.getElementById('promosSpan').style.visibility='hidden'
document.getElementById('careersSpan').style.visibility='hidden'
document.getElementById('bookSpan').style.visibility='hidden'
document.getElementById('k2beautySpan').style.visibility='hidden'


if (document.getElementById(div).style.visibility=='hidden')

document.getElementById(div).style.visibility='visible'


else

document.getElementById(div).style.visibility='hidden'

}


function changeDiv3(div) {
	
document.getElementById('bookingformhair').innerHTML=document.getElementById(div).innerHTML;

	
	
	
}


function cvSubmit() {

document.getElementById('btn').style.color='#999999';
document.getElementById('btn').value='Please wait...';
document.getElementById('loadinggif').style.visibility='visible';

}


function addEmail() {

document.getElementById('atmlbtn').style.color='#999999';
document.getElementById('atmlbtn').value='Please wait...';
document.getElementById('atmlloadinggif').style.visibility='visible';

}


function appDisabled1() {

document.getElementById('dis_no_label').style.display='block';
document.getElementById('dis_no_div').style.display='block';

}

function appDisabled2() {

document.getElementById('dis_no_div').style.display='none';
document.getElementById('dis_no_label').style.display='none';

}



function checkCVUpload() {



if (!document.getElementById('cv_dec').checked)
{

alert('You must agree to the terms and conditions of application before you can proceed');
return false;

}
}

function checkAppForm() {



if (!document.getElementById('app_dec').checked)
{

alert('You must agree to the terms and conditions of application before you can proceed');
return false;

}

var str = document.getElementById('app_email').value;
var at="@";
var dot=".";
var lat=str.indexOf(at);
var lstr=str.length;
var ldot=str.indexOf(dot);


if (str.indexOf(at)==-1){
	alert('Please enter a valid email address');
	return false;
	}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	alert('Please enter a valid email address');
	return false;
	}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	alert('Please enter a valid email address');
    return false
	}

if (str.indexOf(at,(lat+1))!=-1){
	alert('Please enter a valid email address');
    return false
	}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	alert('Please enter a valid email address');
	return false
	}

if (str.indexOf(" ")!=-1){
	alert('Please enter a valid email address');
	return false
	}
	
var radiossex = document.getElementsByName('app_sex');
	
if ((!radiossex[0].checked) && (!radiossex[1].checked)) {
	alert('Please select your sex: Male or Female');
	return false
	
}
	
var radiosdisabled = document.getElementsByName('app_disabled');
	
if ((!radiosdisabled[0].checked) && (!radiosdisabled[1].checked)) {
	alert('Please select where you are disabled');
	return false
	
}


else

return true;

}





function createTarget(t){

window.open("", t, "width=450,height=150");
return true;

}


function createAppForm(t){

window.open("", t, "width=450,height=150");
return true;

}


function createBookingForm(t){

window.open("", t, "width=450,height=150");
return true;

}


function addToMList(t){

window.open("", t, "width=450,height=150");
return true;

}


function addFML(t){

window.open("", t, "width=450,height=150");
return true;

}


function contactUs(t){

window.open("", t, "width=450,height=150");
return true;

}



function checkBookingForm() {



if (!document.getElementById('book_dec').checked)
{

alert('You must agree to the terms and conditions of application before you can proceed');
return false;

}

var str = document.getElementById('book_email').value;
var str2 = document.getElementById('book_name').value;
var str3 = document.getElementById('book_phone').value;

var at="@";
var dot=".";
var lat=str.indexOf(at);
var lstr=str.length;
var ldot=str.indexOf(dot);


if (str.indexOf(at)==-1){
	alert('Please enter a valid email address');
	return false;
	}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	alert('Please enter a valid email address');
	return false;
	}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	alert('Please enter a valid email address');
    return false
	}

if (str.indexOf(at,(lat+1))!=-1){
	alert('Please enter a valid email address');
    return false
	}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	alert('Please enter a valid email address');
	return false
	}

if (str.indexOf(" ")!=-1){
	alert('Please enter a valid email address');
	return false
	}
	
if (str2==''){
	alert('Please enter a valid name');
	return false
	}

if (str3==''){
	alert('Please enter a valid phone number');
	return false
	}

else

return true;

}


function checkFML() {

if (document.getElementById('fml_name').value == '')
{

alert('Please enter your name');
return false;

}

if (document.getElementById('fml_address').value == '')
{

alert('Please enter your address');
return false;

}

if (document.getElementById('fml_email').value == '')
{

alert('Please enter your email address');
return false;

}

var str = document.getElementById('fml_email').value;
var at="@";
var dot=".";
var lat=str.indexOf(at);
var lstr=str.length;
var ldot=str.indexOf(dot);

if (str.indexOf(at)==-1){
	alert('Please enter a valid email address');
	return false;
	}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	alert('Please enter a valid email address');
	return false;
	}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	alert('Please enter a valid email address');
    return false
	}

if (str.indexOf(at,(lat+1))!=-1){
	alert('Please enter a valid email address');
    return false
	}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	alert('Please enter a valid email address');
	return false
	}

if (str.indexOf(" ")!=-1){
	alert('Please enter a valid email address');
	return false
	}


else

return true;

}


function getDirections() {
	
	if (document.getElementById('dir_shrewsbury').checked == true) {
	
	var dir1 = document.getElementById('directions_input').value;
	var dir2 = "http://www.multimap.com/directions/?qs_1=" + dir1 + "&countryCode_1=GB&qs_2=SY11PL&countryCode_2=GB&mode=driving&optimizeFor=time&mapData=916";
	
	window.open(dir2);
	
	}
	
	else if (document.getElementById('dir_newtown').checked == true) {
	
	var dir1 = document.getElementById('directions_input').value;
	var dir2 = "http://www.multimap.com/directions/?qs_1=" + dir1 + "&countryCode_1=GB&qs_2=SY162QZ&countryCode_2=GB&mode=driving&optimizeFor=time&mapData=916";
	
	window.open(dir2);
	
	}
		
	
}


function googleMap(map) {
	
	window.open(map,'name','height=485,width=550,top=50,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	return false;
		
}



function openCal(cal){

document.getElementById('calendar_box').style.display="block";
document.getElementById('calendar_box').innerHTML=document.getElementById(cal).innerHTML;

}

function closeIt(){

document.getElementById('calendar_box').style.display="none";

}

var timerCal = 0;

function closeCal(){

timerCal = setTimeout("closeIt();",1000)

}

function addDate1(dat1) {

document.getElementById('book_day').value=dat1;


}

function addDate2(dat2) {

document.getElementById('book_month').value=dat2;


}

function addDate3(dat3) {

document.getElementById('book_year').value=dat3;


}


function openTC(tc) {
	
	window.open("pages/"+tc+"_tc.html",'name','height=485,width=450,top=50,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	return false;
	
}



function changeCal(cal1,cal2) {


	d1 = new Date();   
	m1 = d1.getMonth();
	cy1 = new Date();   
	cy = cy1.getFullYear();
	
	
if ((cal2 == m1))
{
 	document.getElementById('calendar_box').innerHTML=document.getElementById('cal_now').innerHTML;
}


if ((cal2 == (m1 + 1))  || (cal1 == (cy + 1) && (cal2 == (m1 - 11))  ))
{
 	document.getElementById('calendar_box').innerHTML=document.getElementById('cal_plus1').innerHTML;
}


if ((cal2 == (m1 + 2)) || (cal1 == (cy + 1) && (cal2 == (m1 - 10))  ))
{
 	document.getElementById('calendar_box').innerHTML=document.getElementById('cal_plus2').innerHTML;
}


if ((cal2 == (m1 + 3)) || (cal1 == (cy + 1) && (cal2 == (m1 - 9))  ))
{
 	document.getElementById('calendar_box').innerHTML=document.getElementById('cal_plus3').innerHTML;
}


}


function rollOverImg(elmnt,img2) {
		
	document.getElementById(elmnt).src=img2;
		
}




function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
}




