
function break_out_of_frame() 
{ 
	if (top.location != location) { 
		top.location.href = document.location.href ;
	}
}

function RedirectTo(url){
	document.location = url;
}

function Get(id)
{
	return document.getElementById(id);
}

function findPosX(obj)
{
	var curleft = 0;
	if(obj){
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
	}
	return curleft;
}
function findPosY(obj)
{
	var curtop = 0;
	if(obj){
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop = obj.y;
	}
	return curtop;
}
/*
function findPosY(obj)
{
	var curtop = 0;
	while (obj)
	{
		curtop += obj.offsetTop
		obj = obj.offsetParent;
	}
	return curtop;
}
*/
function Max(n,m)
{
	return n>m?n:m;
}
function Min(n,m)
{
	return n<m?n:m;
}

function UpperCase(s)
{
	return s.toUpperCase()
}

function WriteDebugInfo(info, writeToId){
	if(isDebug)
		Get(writeToId).innerHTML = info;
}

function GetClickEvent(){
	var myEvent;
	if(document.all)
		myEvent = window.event.button;
	else
		myEvent = 1;
		
	return myEvent;
}

function SetRemoteMultiple(querystring,actionIndex){
	//var startDt = new Date();
	//var startMili = startDt.getTime();
	//var maxTime = 5000;
	//var curDt;
	//var timeSpent = 0;
	//while(IsProcessing == 1 && timeSpent < maxTime){
	//	curDt = new Date();
	//	timeSpent = curDt.getTime() - startDt.getTime();
	//}
	if(!isProcessing[actionIndex])
		isProcessing[actionIndex] = 0;
		
	if(isProcessing[actionIndex] == 0){
		isProcessing[actionIndex] = 1;
		setTimeout('isProcessing["'+actionIndex+'"]=0', 30000);
		callToServerMultiple("remote.aspx?" + querystring + "&actionIndex=" +actionIndex,actionIndex);		
		return true;
	}else
	return false;
}

function ReSizePod(key,actionId,podid,newWidth,region,order,podcd,mappingcd,podusernocd){
	//callToServer("remote.aspx?key="+key+"&parameters=" + actionId + "|" + podid + "|" + newWidth + "|" + region + "|" + order + "|" + podcd + "|" + mappingcd + "|" + podusernocd); 
	var encUno = Get('EncUno');
	SetRemote("remote.aspx?encUno=" + encUno.value +"&key="+key+"&parameters=" + actionId + "|" + podid + "|" + newWidth + "|" + region + "|" + order + "|" + podcd + "|" + mappingcd + "|" + podusernocd, key)
	
}


/*var IsProcessing = new Array(5);
for(x=0;x<5;x++)
{
IsProcessing[x] = 0;
}
*/

function GetInnerDivContent(wholetext){
	var text = TrimString(wholetext);
	if(text.toLowerCase().indexOf("<div") > -1 && text.toLowerCase().lastIndexOf("</div>") > -1){
		var start = text.toLowerCase().indexOf("<div");
		text = text.substring(start,text.length);
		idx = text.indexOf(">")+1;
		text = text.substring(idx,text.length);	
		var end = text.toLowerCase().lastIndexOf("</div>"); 
		//text = text.substring(0,text.length-6);		
		text = text.substring(0,end);		
		return text;
	}	
	return wholetext;
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function GetInnerDivContentForBYOP(wholetext){
	if(wholetext.toLowerCase().indexOf("<div") == 0){
		idx = wholetext.indexOf(">")+1;
		wholetext = wholetext.substring(idx,wholetext.length);
		wholetext = wholetext.substring(0,wholetext.length-6);
	}
	return wholetext;
}

function Event(ev)
{
	return (ev) ? ev : ((window.event) ? event : null);
}
function pNm(r,i)
{
	var srk = Get("SUPER_RANDOM_KEY");
	if (srk)
		return "pod"+r+"_"+i+"_"+srk.value;
	return "pod"+r+"_"+i+"_";
}

function DestroyDiv(el)
{
	if(!el)
		return;
		
	el.style.visibility = 'hidden';				
	el.style.left = '-1000px';				
	el.style.top  = '-1000px';				
	el.innerHTML  = '';
}

function MoveEl(el,cx,cy,ox)
{
	el.style.left=(ox)+(cx-x)+'px';
	el.style.top=(cy + document.body.scrollTop) + 'px';
}

function stopper(){
	Get('temp');
}
