﻿//---------------------------window.onload Functions -------------------------------------------
function pageinit(pageid) {
if (pageid == "home") {
homeStartList();
}
else {
startList();
//showHide();
}
if(!NiftyCheck())
    return;
}

//=============================== Load Footer content ===================================

function loadFooter()
{

document.write('<DIV id=btm3>\n');
document.write('<DIV id=footer><A href="http://www.sytelco.com/index.htm">home</A>|<A \n');
document.write('href="http://www.sytelco.com/sitemap.htm">sitemap</A>|<A \n');
document.write('href="http://www.sytelco.com/privacy.htm">privacy policy</A>|<A\n');
document.write('href="http://www.sytelco.com/terms-of-use.htm">terms of use</A>|<A\n');
document.write('href="http://www.sytelco.com/contact.htm">contact us</A>\n');
document.write('</DIV>\n');
document.write('</DIV>\n');
document.write('</DIV>\n');
document.write('</DIV>\n');
document.write('</DIV>\n');
document.write('</BODY>\n');

}

//---------------------------Navigation Menu Functions -----------------------------------------

function homeStartList() {
   if (document.all&&document.getElementById) {
       navRoot = document.getElementById("nav");
       for (i=0; i<navRoot.childNodes.length; i++) {
           node = navRoot.childNodes[i];
           if (node.nodeName=="LI") {
               node.onmouseover=function() {
                   this.className+=" over";
               }
               node.onmouseout=function() {
                   this.className=this.className.replace(" over", "");
               }
           }
       }
   }
   
}

//----------------------Level3
startList = function() {
   if (document.all&&document.getElementById) {
       navRoot = document.getElementById("nav2");
       for (i=0; i<navRoot.childNodes.length; i++) {
           node = navRoot.childNodes[i];
           if (node.nodeName=="LI") {
               node.onmouseover=function() {
                   this.className+=" over";
               }
               node.onmouseout=function() {
                   this.className=this.className.replace(" over", "");
               }
           }
       }
   }
}

//----------------------Show / Hide Div Only works in Mozilla - IE doesn't support innerHTML properly--------------

showHide = function(num,show) {

	var targetdiv = document.getElementById(id="lnkrighth"+num);
	var more = document.getElementById("more"+num);
	if(show==false){	
   		show=true;
    	if(targetdiv) targetdiv.style.display = "block";
    	var divhtml = "[<em><a href='javascript:showHide(" + num +"," + show + ")>close<\/a><\/em>]";
    	if(more) more.innerHTML = divhtml;
    }
   
  	else {
  	show=false;
    if(targetdiv) targetdiv.style.display = "none";
    if(more) more.innerHTML = "[<em><a href='javascript:showHide(" + num +"," + show + ")>more<\/a><\/em>]";

   }
   alert(divhtml + more.innerHTML);
  }
            
 //----------------------Show / Hide Div works in IE and Mozilla --------------
              
function setIdProperty( id, property, value )
{
        var styleObject = document.getElementById( id );
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            styleObject[ property ] = value;
        }
  
}

function swapDiv( num, expanding )
{
	if (expanding)
	{
		setIdProperty("lnkrighth"+num, "display", "none");
		setIdProperty("more"+num, "display", "none");
	}
	
	else
	{
		setIdProperty("lnkrighth"+num, "display", "block");
		setIdProperty("close"+num, "display", "block");
	}
}

function switchDiv( num, expanding )
{		
	if (expanding)
	{
		setIdProperty("lnkrighth"+num, "display", "block");
		setIdProperty("more"+num, "display", "none");
		setIdProperty("close"+num, "display", "block");
	}
	
	else
	{
		setIdProperty("lnkrighth"+num, "display", "none");
		setIdProperty("close"+num, "display", "none");
		setIdProperty("more"+num, "display", "block");
	}
}
//----------------------Navigation timer

//var obj = null;
//var t;

//function checkHover() {
//	if (obj)
//		obj.removeClass("  over");
//	}

//$(document).ready(function() {
													 
//	$('#nav li li li').hover(function() {
//		if (t)
//		  clearTimeout(t);
//		if (obj) {
//			obj.removeClass("  over");
//			obj = null;
//			} //if
//		$(this).addClass("  over");
//		}, function() {
//			obj = $(this);
//			t = setTimeout("checkHover()",1000);
//			});
	
//	});


//---------------------------Home Flash Ticker -----------------------------------------

function RunFlash3()
{
   document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="760" height="25" id="flash">\n');
   document.write('<param name="allowScriptAccess" value="sameDomain">\n');
   document.write('<param name="movie" value="Sytel07files/images/textscroller2.swf">\n');
   document.write('<param name="quality" value="high">\n');
   document.write('<embed src="Sytel07files/images/textscroller2.swf" quality="high" width="760" height="25" name="flash" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">\n');
   document.write('</object>\n');
}


//---------------------------Home Header Popups-----------------------------------------

function Pop(prod) {

	
		currentOpac('popup',0,500);
		currentOpac('popupcon',0,500);
				
	
			switch (prod) {
			
			case "ip":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','IP')", 500);
			break;
			
			case "cm":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','CM')", 500);
			break;
			
			case "bl":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','BL')", 500);
			break;
			
			case "pd":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','PD')", 500);
			break;
			
			case "ib":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','IB')", 500);
			break;
			
			case "ivr":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','IVR')", 500);
			break;
			
			case "tts":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','TTS')", 500);
			break;
			
			case "mt":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','MT')", 500);
			break;
			
			case "rp":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','RP')", 500);
			break;
		
			case "cr":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','CR')", 500);
			break;
			
			case "sc":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','SC')", 500);
			break;
			
			case "mon":
				setTimeout("loadXMLDoc('resources/popups/popup.xml','popup','MON')", 500);
			break;
		
			}
			
			setTimeout("currentOpac('popup',100,500)",1000);
			setTimeout("currentOpac('popupcon',100,500)",1000);
			
		}


function PopClose() {
	
			currentOpac('popup',0,500);
			currentOpac('popupcon',0,500);
}

//---------------------------Links Page Select Scripts-----------------------------------------


//write out possible destinations for DMA form. First must be blank so 'choose a territory' goes nowhere

var destArray = new Array(
		"",			
		"http://www.amda.org.ar",
		"http://www.adma.com.au",
		"http://www.dmvoe.at",
		"http://www.bdma.be",
		"http://www.abemd.org.br",
		"http://www.the-cma.org", 
		"http://www.fedma.org",
		"http://www.ssml-fdma.fi ",
		"http://www.fevad.com ",
		"http://www.ddv.de",
		"http://education.vsnl.com/dmassnindia/",
		"http://www.idma.ie",
		"http://www.jadma.org/e_page/index_e.shtml",
		"http://www.ammd.com.mx",
		"http://www.dmsa.nl",
		"http://www.dma.co.nz",
		"http://www.iol.ie/~ids/nidma.htm", 
		"http://www.smb.pl",
		"http://www.dma.org.za",
		"http://www.fecemd.org",
		"http://www.swedma.se",
		"http://www.dma.org.uk",
		"http://www.the-dma.org"
		);
		

swapDest = function() {
	if (document.getElementById) {
	var num = document.getElementById("country").selectedIndex;
		if (num!=0) {
			var whichDest = destArray[num];
			open(whichDest);
			}
		}
	}


//--------------------------------Fading and Blending-----------------------------------------------

function visibility (id) {

changeOpac(0,id);
document.getElementById(id).style.visibility = "visible" ;
}

function opacity(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++;
		}
	}
}

//change the opacity for different browsers
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 shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it invisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

//----------------------------------------------------------------------

var fade_started=0;
function fadeTransStart(id1, id2, t1)
	{
		if(fade_started==0)
		{
			fadeTrans(id1, id2, t1);
		}
	}
	
function fadeTrans(id1, id2, t1)
	{
		if(fade_started==0)
		{
			fade_started=1;
			opacity(id1,100,0,t1);
			setTimeout("fadeTrans('"+id1+"', '"+id2+"', "+t1+")",t1);
		}
		else
		{
			document.getElementById(id1).src = document.getElementById(id2).src;
			opacity(id1, 0, 100, t1);
			setTimeout("fadeTransComplete()",t1);
		}
	}
	
function fadeTransComplete()
	{
		fade_started=0;
	} 
	
// --------------Load Text to DIV ------------------------------------

function ahah(url, target) {
  document.getElementById(target).innerHTML = '';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function load(name, div) {
	ahah(name,div);
	return false;
}

// --------------Load XML to DIV ------------------------------------

var xmlhttp

function loadXMLDoc(url,div,item) 
{
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=function() { onResponse(url,div,item);};
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function checkReadyState(obj)
{
  if(obj.readyState == 4)
  {
    if(obj.status == 200)
    {
      return true;
    }
    else
    {
      alert("Problem retrieving XML data");
    }
  }
}

function onResponse(url,div,item) 
{ 
  if(checkReadyState(xmlhttp))
  {
  var txt
  var response = xmlhttp.responseXML.documentElement;
  x=response.getElementsByTagName("FLASHITEM")
  for (i=0;i<x.length;i++)
    {
    xx=x[i].getElementsByTagName(item)

      {
      try
        {
        txt= xx[0].firstChild.data
        }
      catch (er)
        {
        txt="No such item"
        }
      }
    }
  document.getElementById(div).innerHTML=txt
  }
}


//-------------------------------Round Corners-------------------------------------------------


function NiftyCheck(){
if(!document.getElementById || !document.createElement)
    return(false);
isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
if(Array.prototype.push==null){Array.prototype.push=function(){
      this[this.length]=arguments[0]; return(this.length);}}
return(true);
}

function Rounded(selector,wich,bk,color,opt){
var i,prefixt,prefixb,cn="r",ecolor="",edges=false,eclass="",b=false,t=false;
if(color=="transparent"){
    cn=cn+"x";
    ecolor=bk;
    bk="transparent";
    }
else if(opt && opt.indexOf("border")>=0){
    var optar=opt.split(" ");
    for(i=0;i<optar.length;i++)
        if(optar[i].indexOf("#")>=0) ecolor=optar[i];
    if(ecolor=="") ecolor="#666";
    cn+="e";
    edges=true;
    }
else if(opt && opt.indexOf("smooth")>=0){
    cn+="a";
    ecolor=Mix(bk,color);
    }
if(opt && opt.indexOf("small")>=0) cn+="s";
prefixt=cn;
prefixb=cn;
if(wich.indexOf("all")>=0){t=true;b=true}
else if(wich.indexOf("top")>=0) t="true";
else if(wich.indexOf("tl")>=0){
    t="true";
    if(wich.indexOf("tr")<0) prefixt+="l";
    }
else if(wich.indexOf("tr")>=0){
    t="true";
    prefixt+="r";
    }
if(wich.indexOf("bottom")>=0) b=true;
else if(wich.indexOf("bl")>=0){
    b="true";
    if(wich.indexOf("br")<0) prefixb+="l";
    }
else if(wich.indexOf("br")>=0){
    b="true";
    prefixb+="r";
    }
var v=getElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    if(edges) AddBorder(v[i],ecolor);
    if(t) AddTop(v[i],bk,color,ecolor,prefixt);
    if(b) AddBottom(v[i],bk,color,ecolor,prefixb);
    }
}

function AddBorder(el,bc){
var i;
if(!el.passed){
    if(el.childNodes.length==1 && el.childNodes[0].nodeType==3){
        var t=el.firstChild.nodeValue;
        el.removeChild(el.lastChild);
        var d=CreateEl("span");
        d.style.display="block";
        d.appendChild(document.createTextNode(t));
        el.appendChild(d);
        }
    for(i=0;i<el.childNodes.length;i++){
        if(el.childNodes[i].nodeType==1){
            el.childNodes[i].style.borderLeft="1px solid "+bc;
            el.childNodes[i].style.borderRight="1px solid "+bc;
            }
        }
    }
el.passed=true;
}
    
function AddTop(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingTop=0;
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateEl(x){
if(isXHTML) return(document.createElementNS('http://www.w3.org/1999/xhtml',x));
else return(document.createElement(x));
}

function getElementsBySelector(selector){
var i,selid="",selclass="",tag=selector,f,s=[],objlist=[];

if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    f=document.getElementById(fs[1]);
    if(f) return(f.getElementsByTagName(s[1]));
    return(objlist);
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    f=document.getElementById(selid);
    if(f) objlist.push(f);
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className.indexOf(selclass)>=0){
        objlist.push(v[i]);
        }
    }
return(objlist);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    }
return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16));
}

