function doMouseOvr(obj,color){
	if(obj){
		obj.bgColor=color;
	}
}
function doMouseOut(obj,color){
	if(obj){
		obj.bgColor=color;
	}
}

function setAction(a1, a2, a3) {
  window.document.frm_main.a1.value = a1;
  window.document.frm_main.a2.value = a2;
  window.document.frm_main.a3.value = a3;
  window.document.frm_main.submit(true);
}

function setAction(a1,a2,a3){
if(document.getElementById('a1')){document.getElementById('a1').value = a1};
if(document.getElementById('a2')){document.getElementById('a2').value = a2};
if(document.getElementById('a3')){document.getElementById('a3').value = a3};
//alert(a1 + ' ' + a2 + ' ' + a3);
window.document.frm_main.submit(true);
}

function returnInt(val){
if(val==true){return 1;}else{return 0;}
}

function confDelete(){
if(confirm('Are you sure you wish to delete this record?')){return true;}
}

var dialogArguments;
function uploadForm(field) {

  dialogArguments1 = field;
  var posY, posX;
  posY = 0; posX = 0;

  posY = (screen.availHeight / 2);
  posX = (screen.availWidth / 2) - (250 / 2);

  nw=window.open('uploadFile.php','ss','toolbar=no; top='+posX+'; left='+posX+'; width=250px; height=240px');
  nw.focus;
}

function setDate(sControl,sObj){
var dtsep="/";
	var dd = document.getElementById(sObj+'dayfld').value;
    var mm = document.getElementById(sObj+'monthfld').value;
    var yy = document.getElementById(sObj+'yearfld').value;
    //var hh = document.getElementById('hourfld').value;
    //var nn = document.getElementById('minutefld').value;
    //var ss = document.getElementById('secondfld').value;

    theDate = yy + dtsep + mm + dtsep + dd; //+ ' ' + hh + tmsep + nn + tmsep + ss
    document.getElementById(sControl).value = theDate;
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft+6;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function posit(mnu,lyr) {
          if (document.getElementById(lyr)) {
      		  document.getElementById(lyr).style.left  = findPosX(document.getElementById(mnu));
      		  document.getElementById(lyr).style.top   = findPosY(document.getElementById(mnu))+14;
     }
}

function hideall() {
        for (i=0; i<100; i++) {
          if (document.getElementById('lyr'+i)) {
      		  document.getElementById('lyr'+i).style.display  = 'none';
          }
     }
}
function showone(lyr) {
	hideall();
  	document.getElementById(lyr).style.display  = 'block';
}
function mouseOvr(Obj){
	if(Obj){
		Obj.style.background = '#ee0406';
	}
}

function mouseOut(Obj){
	if(Obj){
		Obj.style.background = '#941001';
	}
}
function mmouseOvr(Obj){
	if(Obj){
		Obj.style.background = '#ee0406';
	}
}

function mmouseOut(Obj){
	if(Obj){
		Obj.style.background = '#CC0406';
	}
}
var agt = navigator.userAgent.toLowerCase();
function checkBrowserType() {
  var browserType = '';

  if ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) &&
      (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)) {
    browserType = 'NN';
  } else if ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) {
    browserType = 'IE';
  } else if (agt.indexOf("opera") != -1) {
    browserType = 'OPERA';
  } else {
    browserType = '??';
  }
  return browserType;
}

function showhide(strObject,img){
	if(document.getElementById(strObject)){
		if(document.getElementById(strObject).style.display=='none'){
			document.getElementById(strObject).style.display='block';
			document.getElementById(img).src='./images/expand.gif';
		}else{
			if(checkBrowserType()!="NN"){
			document.getElementById(strObject).style.display='none';
			document.getElementById(img).src='./images/collapse.gif';
			}
		}
	}else{
		return false;
	}
}
function mOvr(Obj){
	if(Obj){
		Obj.style.background = '#F2F9FF';
	}
}

function mOut(Obj){
	if(Obj){
		Obj.style.background = '#FFFFFF';
	}
}

var secs
var timerID = null
var timerRunning = false
var delay = 1000
var myObj='';
function InitializeTimer(obj){
    // Set the length of the timer, in seconds
    secs = 1;
    if(myObj==''){myObj=obj;}
    StopTheClock();
    StartTheTimer();

}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}

function StartTheTimer(obj){
    if (secs==0)
    {
        StopTheClock();
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:

        for(i=0;i<100;i++){
	if(document.getElementById('S_'+i)){

			document.getElementById('S_'+i).style.display='none';

	}
}
        myObj='';
    }
    else
    {
        //self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}


function show(id){
obj=document.getElementById('S_' + id);
pobj=document.getElementById('M_' + id);
obj.style.top=findPosY(pobj)+26;
obj.style.left=findPosX(pobj)-7;

for(i=0;i<100;i++){
	if(document.getElementById('S_'+i)){
		if('S_'+i!='S_'+id){
			if('S'+i!=specialid){
				//document.getElementById('S_'+i).style.display='none';
			}
		}
	}
}

obj.style.display='block';
}
var specialid
function show2(id){
	specialid='S_' + id;
obj=document.getElementById('S_' + id);
pobj=document.getElementById('M_' + id);
//obj.style.top=20;
obj.style.left=parseInt(pobj.style.width)-1;

for(i=0;i<100;i++){
	if(document.getElementById('S_'+i)){
		if('S_'+i!='S_'+id){
			document.getElementById('S_'+i).style.display='none';
		}
	}
}
obj.style.display='block';
}
function hide(){
for(i=0;i<100;i++){
	if(document.getElementById('S_'+i)){
		//alert('S_'+i);
		document.getElementById('S_'+i).style.display='none';
		//document.getElementById('S_11').style.display='none';
	}
}
}

function hide2(obj){
	document.getElementById(obj).style.display='none';
}

function image() { };
function randombanner(){

   image = new image();
   number = 0;
   // imageArray
   image[number++] = "<img id='thephoto' src='images/home_photos1.jpg' >"
   image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
   image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
   image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
   image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
   image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
   image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
   image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
   image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
   image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
   image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
      image[number++] = "<img id='thephoto' src='images/main"+number+".jpg' >"
   
   increment = Math.floor(Math.random() * number);
   document.write (image[increment]);
   initImage();

}
function initImage() {
  imageId = 'thephoto';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}
function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;

  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";

  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;

  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;

  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}
function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}
function check(val){
	document.getElementById('card').value=val;
}
function checkcardForm(){
	if(document.getElementById('card')){
		if(document.getElementById('card').value==''){
			alert('You have not selected a card type.');
			return false;
		}
	}
	if(document.getElementById('company')){
		if(document.getElementById('company').value==''){
			document.getElementById('company').value='NA';
			//alert('You have not entered a company name. Enter "NA" if it doesn`t apply.');
			//return false;
		}
	}
	if(document.getElementById('contact')){
		if(document.getElementById('contact').value==''){
			alert('You have not entered a contact name.');
			return false;
		}
	}
	if(document.getElementById('postal')){
		if(document.getElementById('postal').value==''){
			document.getElementById('postal').value='Unspecified';
			//alert('You have not entered a postal address.');
			//return false;
		}
	}
	if(document.getElementById('address')){
		if(document.getElementById('address').value==''){
			document.getElementById('address').value='Unspecified';
			//alert('You have not entered a physical address.');
			//return false;
		}
	}
	if(document.getElementById('tel')){
		if(document.getElementById('tel').value==''){
			alert('You have not entered a telephone number.');
			return false;
		}
	}
	if(document.getElementById('fax')){
		if(document.getElementById('fax').value==''){
			document.getElementById('fax').value='Unspecified';
			return false;
		}
	}
	if(document.getElementById('email')){
		if(document.getElementById('email').value==''){
			alert('You have not entered an email address.');
			return false;
		}
	}
	/*if(document.getElementById('promo')){
		if(document.getElementById('promo').value==''){
			return false;
		}
	}*/
	if(document.getElementById('issue')){
		if(document.getElementById('issue').value==''){
			alert('You have not supplied names for the cards you are requesting.');
			return false;
		}
	}
	if(document.getElementById('terms')){
		if(document.getElementById('terms').checked==false){
			alert('You must have read and agree to the terms and conditions before applying for a card!');
			return false;
		}
	}
	return true;
}

function checkEditor(){
	return true;
}

function affectForm(checked){
	document.getElementById('ccompanyname').disabled=checked;
	document.getElementById('ccompanyvat').disabled=checked;
	document.getElementById('ccompanyadmincontact').disabled=checked;
	document.getElementById('ccompanyadminemail').disabled=checked;
	document.getElementById('ccompanyadmincell').disabled=checked;
	document.getElementById('ccompanytel').disabled=checked;
	document.getElementById('ccompanyfax').disabled=checked;
	document.getElementById('cwebsite').disabled=checked;
	document.getElementById('cpostal').disabled=checked;
	document.getElementById('caddress').disabled=checked;
}