function bigpic()
{
var returnval;
returnval = "/images/" + parent.location.href.substr(parent.location.href.indexOf('?')+3,parent.location.href.length) + ".jpg";
document.getElementById("bigpic_l").src = returnval;
return returnval;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Comma separated list of images to rotate 


if (window.location.href == 'http://www.softtechsolutions.co.uk/index.php?page=webdesign') {var imgs = new Array('http://www.softtechsolutions.co.uk/images/www.jpg','http://www.softtechsolutions.co.uk/images/KraftyKiwiLogo.jpg','http://www.softtechsolutions.co.uk/images/marlealogo.gif','http://www.softtechsolutions.co.uk/images/equihealthlogo.gif');}
if (window.location.href == 'http://www.softtechsolutions.co.uk/index.php?page=bespoke') {var imgs = new Array('http://www.softtechsolutions.co.uk/images/Finetuning.jpg','http://www.softtechsolutions.co.uk/images/Success.jpg');}
if (window.location.href == 'http://www.softtechsolutions.co.uk/index.php?page=home') {var imgs = new Array('http://www.softtechsolutions.co.uk/images/1a.jpg','http://www.softtechsolutions.co.uk/images/2a.jpg','http://www.softtechsolutions.co.uk/images/3a.jpg');}
if (window.location.href == 'http://www.softtechsolutions.co.uk/') {var imgs = new Array('http://www.softtechsolutions.co.uk/images/1a.jpg','http://www.softtechsolutions.co.uk/images/2a.jpg','http://www.softtechsolutions.co.uk/images/3a.jpg');}

// delay in milliseconds between image swaps 1000 = 1 second 
var delay = 3000;
var counter = 0;

function preloadImgs(){
  for(var i=0;i<imgs.length;i++){
    MM_preloadImages(imgs[i]);
  }

}

function randomImages(){
  if(counter == (imgs.length)){
    counter = 0;
  }
  MM_swapImage('rotator', '', imgs[counter++]);
  setTimeout('randomImages()', delay);
}


function msieversion(){
      var ua = window.navigator.userAgent
      var msie = ua.indexOf ( "MSIE " )

      if ( msie > 0 )      // If Internet Explorer, return version number
         return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
      else                 // If another browser, return 0
         return 0

   }
// Enquiry form validation
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Michael Leigeber | http://www.leigeber.com/Licensed under: U.S. Copyright
 */


function checkPhone(str) 
{
	phoneRe = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/
	// This returns a string with everything but the digits removed. 
    if(!phoneRe.test(str)){
    	return false;
    }else{
    	return true;
    }
    
    
   //return str.replace (/[^\d]/g, “”); 

 /*
	var phone2 = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/; 
	if (str.match(phone2)) {
   		return true;
 	} else {
 		return false;
 	}
 	*/
}



// form validation function //
function validateEnquiry(form) {
  var name = form.realname.value;
  var email = form.email.value;
  var phone = form.telephone.value;
  var message = form.enquiry.value;
  
  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
  
  if(name == "") {
    //inlineMsg('name','You must enter your name.',2);
    alert('You must enter your name.');
    return false;
  }
  if(!name.match(nameRegex)) {
    //inlineMsg('name','You have entered an invalid name.',2);
    alert('You have entered an invalid name.');
    return false;
  }
  if(email == "") {
    //inlineMsg('email','<strong>Error</strong><br />You must enter your email.',2);
    alert('You must enter your email.');
    return false;
  }
  if(!email.match(emailRegex)) {
    //inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email.',2);
    alert('You have entered an invalid email.');
    return false;
  }
  
  //if(phone == "") {
  //  inlineMsg('gender','<strong>Error</strong><br />You must select your gender.',2);
  //  return false;
 // }
  
  //form.telephone.value = checkPhone(phone));
   
   if(phone != "") { 
     if(!checkPhone(phone)){
   	  alert('You have entered an invalid telephone number.');
   	  return false;
     } 
   }
  
  if(message == "") {
    //inlineMsg('message','You must enter a message.');
    alert('You must enter a message.');
    return false;
  }
  if(message.match(messageRegex)) {
    //inlineMsg('message','You have entered an invalid message.');
    alert('You have entered an invalid message.');
    return false;
  }
  return true;
}

/*
// START OF MESSAGE SCRIPT //

var MSGTIMER = 20;
var MSGSPEED = 5;
var MSGOFFSET = 3;
var MSGHIDE = 3;

// build out the divs, set attributes and call the fade function //
function inlineMsg(target,string,autohide) {
  var msg;
  var msgcontent;
  if(!document.getElementById('msg')) {
    msg = document.createElement('div');
    msg.id = 'msg';
    msgcontent = document.createElement('div');
    msgcontent.id = 'msgcontent';
    document.body.appendChild(msg);
    msg.appendChild(msgcontent);
    msg.style.filter = 'alpha(opacity=0)';
    msg.style.opacity = 0;
    msg.alpha = 0;
  } else {
    msg = document.getElementById('msg');
    msgcontent = document.getElementById('msgcontent');
  }
  msgcontent.innerHTML = string;
  msg.style.display = 'block';
  var msgheight = msg.offsetHeight;
  var targetdiv = document.getElementById(target);
  targetdiv.focus();
  var targetheight = targetdiv.offsetHeight;
  var targetwidth = targetdiv.offsetWidth;
  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
  msg.style.top = topposition + 'px';
  msg.style.left = leftposition + 'px';
  clearInterval(msg.timer);
  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);
  if(!autohide) {
    autohide = MSGHIDE;
  }
  window.setTimeout("hideMsg()", (autohide * 1000));
}

// hide the form alert //
function hideMsg(msg) {
  var msg = document.getElementById('msg');
  if(!msg.timer) {
    msg.timer = setInterval("fadeMsg(0)", MSGTIMER);
  }
}

// face the message box //
function fadeMsg(flag) {
  if(flag == null) {
    flag = 1;
  }
  var msg = document.getElementById('msg');
  var value;
  if(flag == 1) {
    value = msg.alpha + MSGSPEED;
  } else {
    value = msg.alpha - MSGSPEED;
  }
  msg.alpha = value;
  msg.style.opacity = (value / 100);
  msg.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(msg.timer);
    msg.timer = null;
  } else if(value <= 1) {
    msg.style.display = "none";
    clearInterval(msg.timer);
  }
}

// calculate the position of the element in relation to the left of the browser //
function leftPosition(target) {
  var left = 0;
  if(target.offsetParent) {
    while(1) {
      left += target.offsetLeft;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.x) {
    left += target.x;
  }
  return left;
}

// calculate the position of the element in relation to the top of the browser window //
function topPosition(target) {
  var top = 0;
  if(target.offsetParent) {
    while(1) {
      top += target.offsetTop;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.y) {
    top += target.y;
  }
  return top;
}

// preload the arrow //
if(document.images) {
  arrow = new Image(7,80);
  arrow.src = "msg_arrow.gif";
}

*/
