function ot2ShowImgSwap( strId, intSwap ) {
	// assumes 2 images: image.gif and image_over.gif
	var imgObj = document.getElementById( strId );
	var strTemp = imgObj.src;
	var intStrLength = strTemp.length;
	var intChop, strEnd; 
	
	if ( intSwap ) {
		if (strTemp.indexOf('_over.gif') == -1) {
			intChop = intStrLength - 4;	
			strEnd = '_over.gif';
		}
	} else {
		if (strTemp.indexOf('_over.gif') > -1) {	
			intChop = intStrLength - 9;	
			strEnd = '.gif';
		}
	}
	
	if (typeof(intChop) != "undefined") {
		strTemp = strTemp.substring( 0, intChop );
	}
	
	if (typeof(strEnd) != "undefined") {
		imgObj.src = strTemp + strEnd;
	}	
}


function ot2ImgSwap( strId, intSwap ) {
	ot2ShowImgSwap( strId, intSwap );
}
var ot2AnimationValue = 10;
var ot2AnimationInterval = 40;

		function ot2PipeContainer()
		{
			this.ot2CollapseNodeID = 0;		
			this.ot2ExpandNodeID = 0;
			this.ot2PipeLineModuleMaxRowHeight = 78;
			this.ot2PipeLineModuleMinRowHeight = 24;
			this.ot2CollapsedRowHeight = 34;
			this.ot2ExpandedRowHeight = 68;
			this.tzImageObjbArr = new Array();		
			this.heightAdjustObjbArr = new Array();
			this.containerArr = new Array();
			this.idArr = new Array();
			this.idExpansionStatus = new Array();
			this.numIds = 0;
			this.dataUrl = '';
			this.refreshRate = 1000;
			this.objName = '';
			this.iframeObj = false;
			this.domParserAX = false;
			this.parseHandler = new Function();
			
		}
		function ot2PipeContainer_setObjName(objName)
		{
			this.objName = objName;
		}
		ot2PipeContainer.prototype.setObjName = ot2PipeContainer_setObjName;
		
		function ot2PipeContainer_setParsingFunction(func)
		{
			this.parseHandler = func;
		}
		ot2PipeContainer.prototype.setParsingFunction = ot2PipeContainer_setParsingFunction;

		function ot2PipeContainer_setRefreshRate(time) // in seconds
		{
			this.refreshRate = time*1000;		
		}
		ot2PipeContainer.prototype.setRefreshRate = ot2PipeContainer_setRefreshRate;
		
		function ot2PipeContainer_addContainer(id,height)
		{
			if (document.getElementById(id)) {
				document.getElementById(id).style.height = "24px";
			}
			this.idArr[this.idArr.length] = id;
			this.containerArr[this.containerArr.length] = document.getElementById(id);
			this.heightAdjustObjbArr[this.heightAdjustObjbArr.length] = document.getElementById( id );

			this.tzImageObjbArr[this.tzImageObjbArr.length] = document.getElementById(id +'Image');			
			
			this.idExpansionStatus[this.idExpansionStatus.length] = false;
			this.numIds++;
			if (height) {
				this.ot2PipeLineModuleMaxRowHeight = height;
				this.ot2ExpandedRowHeight = this.ot2PipeLineModuleMaxRowHeight;				
			}
		}
		ot2PipeContainer.prototype.addContainer = ot2PipeContainer_addContainer;

		function ot2PipeContainer_zipNode(id)
		{
			for(var i=0;i<this.numIds;i++)
			{

				if(id==this.idArr[i])
				{
					if(this.idExpansionStatus[i])
					{
						this.privateCollapseNode( i );
					}
					else
					{
						this.privateExpandNode( i );
					}
				}else
				{
					if(this.idExpansionStatus[i])
					{
						this.privateCollapseNode( i );
					}
				}
			}
		}
		ot2PipeContainer.prototype.zipNode = ot2PipeContainer_zipNode;
			var ot2ClassValue = '';

		function ot2PipeContainer_ot2CollapseNode(which) {
			if (this.ot2ExpandedRowHeight > this.ot2PipeLineModuleMinRowHeight ) {
				document.getElementById(which.id).style.height = this.ot2ExpandedRowHeight;	
			} else {
				document.getElementById(which.id).style.height = this.ot2PipeLineModuleMinRowHeight;			
				window.clearInterval(this.ot2CollapseNodeID);
				this.ot2CollapseNodeID = 0;
				this.ot2ExpandedRowHeight = this.ot2PipeLineModuleMaxRowHeight;
				if(document.getElementById(which.id+'Image') && document.getElementById(which.id+'Image').lowsrc) {
					document.getElementById(which.id+'Image').src = 'http://statik.ototurk.com/imgDiv/1.gif';
				}
			}
				this.ot2ExpandedRowHeight = this.ot2ExpandedRowHeight-ot2AnimationValue;

		}
ot2PipeContainer.prototype.ot2CollapseNode = ot2PipeContainer_ot2CollapseNode;	
			
		function ot2PipeContainer_privateCollapseNode(item)
		{
		
		if (this.ot2CollapseNodeID == 0) {
			this.ot2CollapseNodeID = window.setInterval(this.objName+".ot2CollapseNode("+this.objName+".heightAdjustObjbArr["+item+"])",ot2AnimationInterval);

			this.idExpansionStatus[item]=false;
		
			ot2ClassValue=eval(this.objName+".containerArr[ "+item+" ].className.replace(new RegExp(\"ot2PipelineExpanded\"), \"ot2PipelineCollapsed\")");
			
			ot2ClassValue=ot2ClassValue.replace(new RegExp(" ot2Over"), "");			
			
			window.setTimeout(this.objName+".containerArr[ "+item+" ].className='"+ot2ClassValue+"';",500);


		}
		}	
		ot2PipeContainer.prototype.privateCollapseNode = ot2PipeContainer_privateCollapseNode;			

function ot2PipeContainer_ot2ExpandNode(which) {
	if (this.ot2CollapsedRowHeight <= this.ot2PipeLineModuleMaxRowHeight) {
		document.getElementById(which.id).style.height = this.ot2CollapsedRowHeight;
	} else {
		document.getElementById(which.id).style.height = this.ot2PipeLineModuleMaxRowHeight;
		window.clearInterval(this.ot2ExpandNodeID);
		this.ot2ExpandNodeID = 0;
		this.ot2CollapsedRowHeight = this.ot2PipeLineModuleMinRowHeight;
	}

	this.ot2CollapsedRowHeight = this.ot2CollapsedRowHeight+ot2AnimationValue;
}
ot2PipeContainer.prototype.ot2ExpandNode = ot2PipeContainer_ot2ExpandNode;

		function ot2PipeContainer_privateExpandNode(item)
		{
			var realId = this.idArr[item]+'Image';
			if(document.getElementById(realId))
			{
				if (document.getElementById(realId).lowsrc){
					document.getElementById(realId).src = document.getElementById(realId).lowsrc;
				}
			}
			if (this.ot2ExpandNodeID == 0) {
			this.ot2ExpandNodeID = window.setInterval(this.objName+".ot2ExpandNode("+this.objName+".heightAdjustObjbArr["+item+"])",ot2AnimationInterval);
			this.idExpansionStatus[item] = true;


			this.containerArr[ item ].className =  this.containerArr[ item ].className.replace(new RegExp(" ot2Over"), "");
			this.containerArr[ item ].className =  this.containerArr[ item ].className.replace(new RegExp("ot2PipelineCollapsed"), "ot2PipelineExpanded");
//			window.setTimeout(this.objName+".idExpansionStatus["+item+"]=true;",500);
			}
		}	
		ot2PipeContainer.prototype.privateExpandNode = ot2PipeContainer_privateExpandNode;			


		

function OT2_changeBackground(which, val) {
	switch (val) {
		case 1:
			which.className += " ot2Over";
			break;
		case 0:
			which.className=which.className.replace(new RegExp(" ot2Over\\b"), "");
			break;
	}

}
		
function OT2_initVideoModules(){
	var oto2VidContainers = document.getElementById("ot2Oto2videoModule").getElementsByTagName("div");
	for (var i=0; i<oto2VidContainers.length; i++){
		var oto2VidContainer = oto2VidContainers[i];
			if(oto2VidContainer.id.substr(0,11) == "oto2VidCntr") {
				oto2VidContainer.onmouseover = function () {OT2_changeBackground(this,1); return false;}
				oto2VidContainer.onmouseout = function () {OT2_changeBackground(this,0); return false;}	
			}
			if(oto2VidContainer.id.substr(0,21) == "ot2oto2VidHeadlineBar") {
				oto2VidContainer.id = oto2VidContainer.id.replace(new RegExp("ot2oto2VidHeadlineBar"), "");
				oto2VidContainer.onclick = function () {oto2VidCntr.zipNode("oto2VidCntr"+this.id); return false;}
			}	
	}
	var oto2VidMPContainers = document.getElementById("ot2Oto2videoMPModule").getElementsByTagName("div");
	for (var i=0; i<oto2VidMPContainers.length; i++){
		var oto2VidMPContainer = oto2VidMPContainers[i];
			if(oto2VidMPContainer.id.substr(0,13) == "oto2VidMPCntr") {
				oto2VidMPContainer.onmouseover = function () {OT2_changeBackground(this,1); return false;}
				oto2VidMPContainer.onmouseout = function () {OT2_changeBackground(this,0); return false;}	
			}
			if(oto2VidMPContainer.id.substr(0,23) == "ot2oto2VidMPHeadlineBar") {
				oto2VidMPContainer.id = oto2VidMPContainer.id.replace(new RegExp("ot2oto2VidMPHeadlineBar"), "");
				oto2VidMPContainer.onclick = function () {oto2VidMPCntr.zipNode("oto2VidMPCntr"+this.id); return false;}
			}	
	}
}		
function OT2_flipModule(show,hide) {
	if (document.getElementById) {
		document.getElementById(hide).style.display = "none";
		document.getElementById(show).style.display = "block";
	}
}