// JavaScript Document

Language_Variable=readCookie('LocationCookie');

/*fucntions for my tayyar static bg change begin */
/*functions for coockie for the mytayyar bg color begin */
var expdate = new Date();expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365));
var Item = new Array();
////////////////////////////////////////////////
function setCookie (name,value,expires) {
  if (!expires) expires = new Date();
document.cookie = name + "=" +escape(value)+";expires=" + expires.toGMTString() + ";path=/";
}
////////////////////////////////////////////////
function getCookie (name){
var dcookie = document.cookie;
var cname = name + "=";
var clen = dcookie.length;
var cbegin = 0;
 while (cbegin < clen) {
  var vbegin = cbegin + cname.length;
   if (dcookie.substring(cbegin,vbegin) == cname) {
      var vend = dcookie.indexOf(";",vbegin);
  if (vend == -1) vend = clen;
          return unescape(dcookie.substring(vbegin,vend));
        }
    cbegin = dcookie.indexOf(" ",cbegin)+1;
    if (cbegin == 0) break;
    }
return null;
}
////////////////////////////////////////////////
function setCookieArray(name){
    this.length = setCookieArray.arguments.length - 1;
        for (var i = 0; i < this.length; i++) {
        data = setCookieArray.arguments[i + 1]
        setCookie (name + i, data, expdate);
        }
    }
////////////////////////////////////////////////
function getCookieArray(name){
    var i = 0;
        while (getCookie(name + i) != null) {
        this[i + 1] = getCookie(name + i);
        i++; this.length = i;
        }
    }
/*functions for coockie for the mytayyar bg color end */
function changebgcolor(sectionid,bgColor){
	document.getElementById(sectionid).style.backgroundColor=bgColor;
	document.cookie = 'MyDefaultColor='+bgColor+'; expires=Thu, 2 Aug 2101 20:47:11 UTC; path=/'
}		
function myBgColor(){
Item=readCookie('MyDefaultColor');


if (Item)
	{
	
	document.getElementById('rightsection').style.backgroundColor=Item;
	}
	
	

	
	
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
/*fucntions for my tayyar static bg change end */
		/*functions for the ajax*/
		
var request;
function createRequest() {
  try {
    request = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        request = false;
      }
    }
  }
}

// JavaScript Document

Language_Variable=readCookie('LocationCookie');
if (Language_Variable==null)
	Language_Variable = 'en-US';
	
/*fucntions for my tayyar static bg change begin */
/*functions for coockie for the mytayyar bg color begin */
var expdate = new Date();expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365));
var Item = new Array();
////////////////////////////////////////////////
function setCookie (name,value,expires) {
  if (!expires) expires = new Date();
document.cookie = name + "=" +escape(value)+";expires=" + expires.toGMTString() + ";path=/";
}
////////////////////////////////////////////////
function getCookie (name){
var dcookie = document.cookie;
var cname = name + "=";
var clen = dcookie.length;
var cbegin = 0;
 while (cbegin < clen) {
  var vbegin = cbegin + cname.length;
   if (dcookie.substring(cbegin,vbegin) == cname) {
      var vend = dcookie.indexOf(";",vbegin);
  if (vend == -1) vend = clen;
          return unescape(dcookie.substring(vbegin,vend));
        }
    cbegin = dcookie.indexOf(" ",cbegin)+1;
    if (cbegin == 0) break;
    }
return null;
}
////////////////////////////////////////////////
function setCookieArray(name){
    this.length = setCookieArray.arguments.length - 1;
        for (var i = 0; i < this.length; i++) {
        data = setCookieArray.arguments[i + 1]
        setCookie (name + i, data, expdate);
        }
    }
////////////////////////////////////////////////
function getCookieArray(name){
    var i = 0;
        while (getCookie(name + i) != null) {
        this[i + 1] = getCookie(name + i);
        i++; this.length = i;
        }
    }
/*functions for coockie for the mytayyar bg color end */
function changebgcolor(sectionid,bgColor){
	document.getElementById(sectionid).style.backgroundColor=bgColor;
	document.cookie = 'MyDefaultColor='+bgColor+'; expires=Thu, 2 Aug 2101 20:47:11 UTC; path=/'
}		
function myBgColor(){
Item=readCookie('MyDefaultColor');


if (Item)
	{
	
	document.getElementById('rightsection').style.backgroundColor=Item;
	}	
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
/*fucntions for my tayyar static bg change end */
		/*functions for the ajax*/
		
var request;
function createRequest() {
  try {
    request = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        request = false;
      }
    }
  }
}

	/*End functions for the ajax*/
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}



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];}
}



function P7_Snap() { //v2.63 by PVII
 var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,pa='px',args=P7_Snap.arguments;a=parseInt(a);
 if(document.layers||window.opera){pa='';}for(k=0;k<(args.length);k+=4){
 if((g=MM_findObj(args[k]))!=null&&g.style.display!='none'){if((el=MM_findObj(args[k+1]))!=null){
 a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
 da="document.all['"+args[k]+"']";if(document.getElementById){
 d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
 d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
 }else if(document.all){d=da;}if(document.all||document.getElementById){while(tx==1){
 p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
 }else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);tw=x+ox+y+oy;
 if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
  ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);}else{
  w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
  x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+event.clientY;}}
 }else if(document.layers){x=g.x;y=g.y;q0=document.layers,dd="";for(var s=0;s<q0.length;s++){
  dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');
  break;}}}e=(document.layers)?el:el.style;xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
 if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
  xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);}
 e.left=xx+pa;e.top=yy+pa;}}}
}
	


	

	/* functions for the right tabs begin*/	
	
//Start For my Tayyar//
var dhtmlgoodies_slideSpeed = 13;	// Higher value	= faster
var dhtmlgoodies_timer		= 13;	// Lower value	= faster

var objectIdToSlideDown				= false;
var dhtmlgoodies_activeId			= false;
var dhtmlgoodies_slideInProgress	= false;

var currentInput					= null;	// Added by JBC on 2007-07-20 >> To disable slide up of active object when we mouseover its tab

function showHideContent(e, inputId)
{
	if (!inputId) {
		inputId	= this.id;
	}
	
	if (currentInput != inputId) {			// Added by JBC on 2007-07-20 >> To disable slide up of active object when we mouseover its tab
		if (dhtmlgoodies_slideInProgress) {
			return;
		}
		
		dhtmlgoodies_slideInProgress	= true;
		
		var numericId	= inputId.replace(/[^0-9]/g,'');
		var answerDiv	= document.getElementById('dhtmlgoodies_a' + numericId);
		
		objectIdToSlideDown	= false;
		
		if (!answerDiv.style.display || answerDiv.style.display == 'none') {
			if (dhtmlgoodies_activeId && dhtmlgoodies_activeId != numericId) {	
				//alert('Slide up panel');
				objectIdToSlideDown	= numericId;
				
				slideContent(dhtmlgoodies_activeId, (dhtmlgoodies_slideSpeed *- 1));
			} else {
				//alert('Slide down panel');
				answerDiv.style.display		= 'block';
				answerDiv.style.visibility	= 'visible';
				
				slideContent(numericId, dhtmlgoodies_slideSpeed);
			}
		} else {
			//alert('Slide up same panel');
			slideContent(numericId, (dhtmlgoodies_slideSpeed *- 1));
			dhtmlgoodies_activeId	= false;		
		}	
		
		currentInput	= inputId;			// Added by JBC on 2007-07-20 >> To disable slide up of active object when we mouseover its tab
	}
}

function slideContent(inputId,direction)
{
	var obj			= document.getElementById('dhtmlgoodies_a' + inputId);
	var contentObj	= document.getElementById('dhtmlgoodies_ac' + inputId);
	
	height	= obj.clientHeight;
	
	if (height == 0) {
		height	= obj.offsetHeight;
	}
	
	height	= height + direction;
	
	rerunFunction	= true;
	
	if (height > contentObj.offsetHeight) {
		height			= contentObj.offsetHeight;
		rerunFunction	= false;		
	}
	
	if (height <= 1) {
		height			= 1;
		rerunFunction	= false;		
	}
	
	obj.style.height	= height + 'px';
	
	var topPos	= height - contentObj.offsetHeight;
	
	if (topPos > 0) {
		topPos = 0;
	}
	
	contentObj.style.top	= topPos + 'px';

	if (rerunFunction) {
		setTimeout ('slideContent(' + inputId + ',' + direction + ')', dhtmlgoodies_timer);
	} else {
		initShowHideDivs(false);	// Added by JBC on 2007-07-23 >> to change icons' onMouseOver functionality
		
		if (height <= 1) {
		    //restoring the image
			//The images are named (ans + the id of the div)
		    var img	= 'image' + inputId;
			
			document.images[img].src	= "/tayyar/images/icon" + inputId + ".gif";
			
			obj.style.display	= 'none'; 
			
			if (objectIdToSlideDown && (objectIdToSlideDown != inputId)) {
				slideContent(objectIdToSlideDown, dhtmlgoodies_slideSpeed);	
			} else {
				dhtmlgoodies_slideInProgress	= false;
			}
		} else {
			dhtmlgoodies_activeId			= inputId;
			dhtmlgoodies_slideInProgress	= false;
		}
	}
}

function noShowHideContent(e, inputId)
{
	if (!inputId) {
		inputId	= this.id;
	}
	
	if (currentInput != inputId) {	
		var current_a	= currentInput.toString().split('dhtmlgoodies_q');
		var inputId_a	= inputId.toString().split('dhtmlgoodies_q');
		
		var img						= 'image' + current_a[1];
		
		var newImg	= document.getElementById(img).src.toString().split('on.');
		document.getElementById(img).src	= newImg[0] + '.' + newImg[1];
		
		var currObj		= document.getElementById('dhtmlgoodies_a' + current_a[1]);
		var obj			= document.getElementById('dhtmlgoodies_a' + inputId_a[1]);
		var contentObj	= document.getElementById('dhtmlgoodies_ac' + inputId_a[1]);
		
		obj.style.display			= '';
		obj.style.visibility		= 'visible';
		
		currObj.style.display		= 'none';
		currObj.style.visibility	= 'hidden';
		currentInput	= inputId;
	}
}

function initShowHideDivs(slidingEffect)
{
	var divs = document.getElementsByTagName('DIV');

	var divCounter = 0;
	
	if (slidingEffect) {
		for (var no = 0; no < divs.length; no++) {
			if (divs[no].className == 'dhtmlgoodies_question') {
				divs[no].onmouseover	= showHideContent;
				divs[no].id				= 'dhtmlgoodies_q' + divCounter;
				
				var answer				= document.getElementById('dhtmlgoodies_a' + divCounter);
				answer.id				= 'dhtmlgoodies_a' + divCounter;	
				answer.style.height		= '0px';
				
				contentDiv				= answer.getElementsByTagName('DIV')[0];
				contentDiv.className	= 'dhtmlgoodies_answer_content';
				contentDiv.id			= 'dhtmlgoodies_ac' + divCounter;
				
				divCounter++;
			}		
		}	
	} else {
		for (var no = 0; no < divs.length; no++) {
			if (divs[no].className == 'dhtmlgoodies_question') {
				divs[no].onmouseover	= noShowHideContent;
				divs[no].id				= 'dhtmlgoodies_q' + divCounter;
				
				var answer				= document.getElementById('dhtmlgoodies_a' + divCounter);
				answer.id				= 'dhtmlgoodies_a' + divCounter;
				answer.style.height		= 'auto';
				
				if (divs[no].id != currentInput) {
					answer.style.display	= 'none';
					answer.style.visibility	= 'hidden';
				}
				
				contentDiv				= answer.getElementsByTagName('DIV')[0];
				contentDiv.className	= 'dhtmlgoodies_answer_content';
				contentDiv.id			= 'dhtmlgoodies_ac' + divCounter;
				
				divCounter++;
			}		
		}	
	}
}
//end For my Tayyar//
function controlsTxt(txt){
	document.getElementById("controlTxt").innerHTML=txt;
}
function controlsTxt2(txt){
	document.getElementById("controlTxt2").innerHTML=txt;
}

function clearcontrolsTxt(){
	document.getElementById("controlTxt").innerHTML="";
	document.getElementById("controlTxt2").innerHTML="";
}
var PanelSlideOut3 = "";
var spanSlideOut = "";
function revelerCacherSousNav3(LienId,span){
	var LI = document.getElementById (LienId).parentNode;
	var Sub = document.getElementById (LienId+"_sub");
		if(Sub.style.display == "none"){
			document.getElementById (span).innerHTML="&minus;";
			document.getElementById (LienId).style.color="#707070";
			document.getElementById (span).style.color="#f78f04";
			Sub.style.display = "";
			if (PanelSlideOut3 != "") revelerCacherSousNav3(PanelSlideOut3,spanSlideOut);
			PanelSlideOut3 = LienId;
			spanSlideOut = span;
		}
		else
		{
			document.getElementById (span).innerHTML="+";
			document.getElementById (span).style.color="#f78f04";
			document.getElementById (LienId).style.color="#acacac";
			Sub.style.display = "none";
			PanelSlideOut3 = "";
		}
	}
	/* functions for the right tabs end*/
	
function	highlight(Main_ID, Sub_ID){
	if (document.getElementById(Main_ID))
	{
	
		document.getElementById(Main_ID).className='highlightclasson';
		document.getElementById(Main_ID).style.color='#ffffff';
		document.getElementById(Main_ID+"_image1").src='/Tayyar/images/'+Language_Variable+'/seperationbar_lefton.gif';
		document.getElementById(Main_ID+"_image2").src='/Tayyar/images/'+Language_Variable+'/seperationbar_righton.gif';
		
		
		MM_showHideLayers2('HideAll','','hide','item'+Main_ID+'on','','hide','SubMenu_'+Main_ID,'','show');P7_Snap('position_SubMenus','SubMenu_'+Main_ID,0,17);
		
		if (document.getElementById(Sub_ID)) {
			document.getElementById(Sub_ID).style.color='#ffffff';
		}
	}
}

/*functins added for the advanced search begin*/
var PanelSlideOut = "";
function revelerCacherSousNav5(LienId)
{
	var Sub = document.getElementById (LienId+"_sub");
    if(Sub.style.display == "none")
    {
		document.getElementById (LienId).style.color="#f77d10";
		Sub.style.display = "";
		if (PanelSlideOut != "") revelerCacherSousNav5(PanelSlideOut);
		PanelSlideOut = LienId;
	}
	else
	{
		document.getElementById (LienId).style.color="#6e6e6d";
		Sub.style.display = "none";
		PanelSlideOut = "";
	}
}
/*functins added for the advanced search end*/

/*fucntions audio video for reducing the load on the home page begin */
function setInnerHTML_video(id)
	{		
	
		document.getElementById(id).innerHTML = "<div id='player2'><a href='http://www.macromedia.com/go/getflashplayer'>Get the Flash Player</a> to see this player.</div>";		
		
		UFO.create(	FU1, "player2");
	}
	
function setInnerHTML_audio(id)
	{		
		document.getElementById(id).innerHTML = "<div id='player3'><a href='http://www.macromedia.com/go/getflashplayer'>Get the Flash Player</a> to see this player.</div>";		
		UFO.create(	FU2, "player3");
	}	
/*fucntions audio video for reducing the load on the home page end */
function IfEnter(e)
{
 var str = document.Form1.search.value;
 if (e.keyCode == 13) 
 {
  if (str.length < 4 || str.length > 255)
  {
 alert(searchMessage);
 document.Form1.search.focus();
 document.Form1.search.select();
 return (false);
  }
else
{
 window.location = "/tayyar/search.htm?Module=Web?_searchterm="  + str;
 return false;}
}
}
function imagespreload(){

MM_preloadImages('/Tayyar/images/'+Language_Variable+'/seperationbar_lefton.gif','/Tayyar/images/'+Language_Variable+'/seperationbar_righton.gif','/Tayyar/images/'+Language_Variable+'/lefttitleimgtestsml.gif','/Tayyar/images/'+Language_Variable+'/lefttitleimgtestsml.gif','/Tayyar/images/'+Language_Variable+'/lefttitleimgsmlon.gif','/Tayyar/images/'+Language_Variable+'/lefttitleimgsml.gif','/Tayyar/images/'+Language_Variable+'/lefttitleimgtest.gif','/Tayyar/images/'+Language_Variable+'/lefttitleimgtest.gif','/Tayyar/images/'+Language_Variable+'/lefttitleimgon.gif','/Tayyar/images/'+Language_Variable+'/lefttitleimg.gif')

}
/*function added by rony for the menu problem begin */
function MM_showHideLayers2() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers2.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}
/*function added by rony for the menu problem end */
function IfEnterEshoppingSearch(e, thatsMe)
{
	var str = thatsMe.value;
	if (e.keyCode == 13) 
	{
		if (str.length < 4 || str.length > 255)
		{
			alert(searchMessage);
			thatsMe.focus();
			thatsMe.select();
			return (false);
		}
		else
		{
			window.location = "/Tayyar/EShopping/Search.htm?_searchterm="  + str + "&_start=20&_length=60&currp=1&_chtype=";
			return false;
		}
	}
}
function writeRSSLink (title, url, lang, international)
{
	var rssUrl = url + '?lang=' + getCookie(lang) + '&international=' + getCookie(international)
	//alert ("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"" + title + "\" href=\"" + rssUrl + "\">");
	document.write ("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"" + title + "\" href=\"" + rssUrl + "\">");
}
function minus(LienId){
	var Sub = document.getElementById (LienId+"_sub");
	if(Sub.style.display == ""){
		Sub.style.display = "none";
	}
}
function plus(LienId){
	var Sub = document.getElementById (LienId+"_sub");
	if(Sub.style.display == "none"){
		Sub.style.display = "";
	}
}
function OpenNewsRSS(url,lang, international)
{
	window.open(url + '?lang=' + getCookie(lang) + '&international=' + getCookie(international));
}
function NextNews()
{
	if(document.getElementById('news'+(CurrentNews+1)))
	{
		var countDivs = 0;
		for (i = 1; i <= MaxNews; i++)
		{
			if(document.getElementById('news'+i))
			{
				document.getElementById('news'+i).style.display = "none";
				countDivs++;
			}
		}
		var upperLimit = CurrentNews + numOfVisibleDivs;
		for (; CurrentNews < upperLimit; CurrentNews++)
		{
			if(document.getElementById('news'+(CurrentNews+1)))
			{
				document.getElementById('news'+(CurrentNews+1)).style.display = "";
			}
		}
	}
	
	if (CurrentNews >= countDivs)
		CurrentNews = 0;
}

isRunDIV	= false;

function RunDIV()
{
	document.getElementById ('stop').src='/Tayyar/images/en-US/stop.jpg';
	document.getElementById ('play').src='/Tayyar/images/en-US/playoff.jpg';
	if (!isRunDIV)
	{
		showtime	= setInterval("NextNews()", 23000);
		isRunDIV	= true;
	}
}

function StopDIV()
{			
	document.getElementById ('stop').src='/Tayyar/images/en-US/stopoff.jpg';
	document.getElementById ('play').src='/Tayyar/images/en-US/play.jpg';
	clearInterval(showtime);
	isRunDIV	= false;
}
function advSearch(mod)
{
	if (document.getElementById('txtSearchBox').value.length < 4 || document.getElementById('txtSearchBox').value.length > 255) {alert (searchMessage);} else {window.location= '/tayyar/search.htm?Module=' + mod + '&_searchterm='  + document.getElementById('txtSearchBox').value;}
}
// protal homepage scrolling news functions
var identifier = 0;
var timeoutChar		= 80;
var tickrtTime		= 4000;
var theWidgetOne	= "_";
var theWidgetTwo	= "-";
var theWidgetNone	= "";
var theLeadString	= "&nbsp;";

var msgTexts		= new Array();
var msgTimes		= new Array();
var msgAgencys		= new Array();
var direction		= new Array();
var links			= new Array();

function directionflipp(direction)
{
	document.getElementById('direction').style.direction	= direction;
}

function setTiArrays(id, tText, tTime, tAgency, dir, url)
{ 
	msgTexts[id]	= tText; 
	msgTimes[id]	= tTime; 
	msgAgencys[id]	= tAgency; 
	direction[id]	= dir;
	links[id]		= url;
}

function initTicker()
{
	theCurrentStory		= 0;
	theCurrentLength	= 0;	
	
	if (document.getElementById) {	
		theAnchorObject	= document.getElementById("tickerAnchor");
		runTic();   		
	} else {
		document.write("<style>.tickerDiv{display:none;}.ticko{border:0px; padding:0px;}</style>");
		return true;
	}
}

function runTic()
{
	if (msgTexts.length == 0) return;
	var timeSet;  
	
	if (theCurrentLength == 0) {
		directionflipp(direction[theCurrentStory]);
		
		theStorySummary	= msgTexts[theCurrentStory].replace(/&quot;/g,'"');
		
		if (msgAgencys[theCurrentStory]) {
			theStorySummary	+= '... (' + msgAgencys[theCurrentStory].replace(/&quot;/g,'"') + ')';	
		}
		
		theAnchorObject.href	= links[theCurrentStory];
	}
	
	theAnchorObject.innerHTML	= "<b>" + msgTimes[theCurrentStory] + "</b>&nbsp;" + theStorySummary.substring(0,theCurrentLength) + whatWidget();
	
	if (theCurrentLength != theStorySummary.length) {
		theCurrentLength++;
		timeSet = timeoutChar;
	} else {
		theCurrentLength = 0;
		timeSet = tickrtTime;
		
		if (theCurrentStory == (theItemCount - 1)) {
			theCurrentStory	= 0;
		} else {
			theCurrentStory++;
		}
	}
	
	setTimeout("runTic()", timeSet);
}

function whatWidget()
{
	if (theCurrentLength == theStorySummary.length) {
		return theWidgetNone;
	}
	
	if ((theCurrentLength % 2) == 1) {
		return theWidgetOne;
	} else {
		return theWidgetTwo;
	}
}
function AddTimeOffset(originalHours, originalMinutes, addedHours, addedMinutes, addedSign)
{
	if (addedSign.toLowerCase() == 'false')
	{
		var resultingMinutes = (originalMinutes + addedMinutes ) % 60;
		var resultingHours = (((originalMinutes + addedMinutes ) / 60) >= 1) ? 1 : 0;
		resultingHours = (originalHours + addedHours + resultingHours) % 24;
		var resultingTime = ((10 > resultingHours)? '0' + resultingHours : resultingHours) + ':' + ((10 > resultingMinutes) ? '0' + resultingMinutes : resultingMinutes);
		return resultingTime;
	}
	else
	{
		if (addedMinutes > originalMinutes)
		{
			originalMinutes = originalMinutes + 60;
			originalHours--;
		}
		var resultingMinutes = (originalMinutes - addedMinutes ) % 60;
		if (addedHours > originalHours)
		{
			originalHours = originalHours + 24;
		}
		var resultingHours = (originalHours - addedHours) % 24;
		var resultingTime = ((10 > resultingHours)? '0' + resultingHours : resultingHours) + ':' + ((10 > resultingMinutes) ? '0' + resultingMinutes : resultingMinutes);
		return resultingTime;
	}
}

function ShowHideBanner(Id)
{
	if (document.getElementById("Banner_" + Id))
	{
		if (document.getElementById("Banner_" + Id).style.display == "none")
		{
			document.getElementById("Banner_" + Id).style.display = "block";
			if (document.getElementById("Banner" + Id))
			{
				document.getElementById("Banner" + Id).style.display = "block";
			}
		}
		else
		{
			document.getElementById("Banner_" + Id).style.display = "none";
			
			if (document.getElementById("Banner" + Id))
			{
				document.getElementById("Banner" + Id).style.display = "none";
			}
		}
	}
}

function Trim(InputString)
{
    // Removes leading and trailing spaces from the passed string. Also removes
    // consecutive spaces and replaces it with one space. If something besides
    // a string is passed in (null, custom object, etc.) then return the input.
    if (typeof InputString != "string")
    {
        return InputString;
    }
    
    var retValue = InputString;
    var ch = retValue.substring(0, 1);
    
    while (ch == " ")
    { // Check for spaces at the beginning of the string
        retValue = retValue.substring(1, retValue.length);
        ch = retValue.substring(0, 1);
    }
    
    ch = retValue.substring(retValue.length-1, retValue.length);
    
    while (ch == " ")
    { // Check for spaces at the end of the string
        retValue = retValue.substring(0, retValue.length - 1);
        ch = retValue.substring(retValue.length - 1, retValue.length);
    }
    
    while (retValue.indexOf("  ") != -1)
    { // Note that there are two spaces in the string - look for multiple spaces within the string
        retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
    }
    
    return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function RemoveLink()
{
    var tags = document.getElementsByTagName("A");
    for (var i = tags.length - 1; i >= 0; i--)
    {
        if (tags[i].href == "http://www.alexa.com/data/details/main?url=http://www.tayyar.org")
        {
            tags[i].parentNode.innerHTML = "";
            break;
        }
    }
}