//CODE done by Usability IDC 
//This File is used ini DSF_ADmin_Edit Theme.html 

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;
//For dragging the Object
function colorpickerddInit(e,lyrMain,layerSub)
{
	try
	{
		topDog=isIE ? "BODY" : "HTML";
		whichDog=document.getElementById(lyrMain); 
		hotDog=isIE ? event.srcElement : e.target;  
		while (hotDog.id!=layerSub&&hotDog.tagName!=topDog)
		{
			hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
		}  
		if (hotDog.id==layerSub)
		{
			offsetx=isIE ? event.clientX : e.clientX;
			offsety=isIE ? event.clientY : e.clientY;
			nowX=parseInt(whichDog.style.left);
			nowY=parseInt(whichDog.style.top);
			
			ddEnabled=true;
			document.onmousemove=dd;
		}
	}
	
	catch(e)
	{
		alert(e.description);
	}
}
//Positioning the Object dragged.
function colorpickerdd(e)
{
	try
	{
		if (!ddEnabled) return;
		whichDog.style.left=isIE ? nowX+event.clientX - offsetx : (nowX + e.clientX - offsetx) + "px"; 
		whichDog.style.top=isIE ? nowY+event.clientY - offsety : (nowY + e.clientY - offsety) + "px";
		return false;  
	}
	catch(e)
	{
		alert(e.description);
	}
}

function colorpickercancel(objId,iframeid)
{
	var lay=document.getElementById(objId);
	var iframeObj = document.getElementById(iframeid);
	lay.style.visibility = 'hidden';
	iframeObj.style.visibility = 'hidden';
}
//Function to display the layer on click of the button,
//Need to pass the layerId as a parameter to the function
function colorpickershow(layerId,iframeid,cntrlId,txtBxId,rfVal)
{
	try
	{
	    if(rfVal != null)
	    {
	        document.getElementById("hidVal").value = rfVal;
	    }
	    document.getElementById("hidCntrlId").value = txtBxId;
	    document.getElementById("imgid").value = cntrlId;
		if(document.getElementById("hidLayID") != null)
		{
			if(document.getElementById("hidLayID").value != '')
			{
				document.getElementById(document.getElementById("hidLayID").value).style.visibility='hidden';
			}
			document.getElementById("hidLayID").value=layerId;
		}
		
		//var iframeid = "iframe1";
		var iframeStyleObj = document.getElementById(iframeid).style;
		var temp = new Array();
		temp = getSize();//Get the size of the browser window
		var layerObj = document.getElementById(layerId);
		var layerStyleObj = document.getElementById(layerId).style;
		var layerW = layerObj.offsetWidth;
		var layerH = layerObj.offsetHeight;
		//alert("Layer Height & width" +layerObj.offsetHeight + "......" + layerObj.offsetWidth);
		iframeStyleObj.width = parseInt(layerW);
		iframeStyleObj.height = parseInt(layerH); 
		//alert("Layer Height & width" +iframeStyleObj.height + "......" + iframeStyleObj.width);
		var scrollXY = new Array();
		scrollXY = getScrollXY();
		layerStyleObj.top = parseInt((temp[1]/2)- (parseInt(layerH)/2) + parseInt(scrollXY[1])) + "px";
		layerStyleObj.left = parseInt((temp[0]/2)- (parseInt(layerW)/2) + parseInt(scrollXY[0])) + "px";
		iframeStyleObj.left = parseInt((temp[0]/2)- (parseInt(layerW)/2) + parseInt(scrollXY[0])) + "px";
		iframeStyleObj.top = parseInt((temp[1]/2)- (parseInt(layerH)/2) + parseInt(scrollXY[1])) + "px";
		if(document.getElementById('popUpCoOrdinatesLeft') != null)
		{
		   document.getElementById('popUpCoOrdinatesLeft').value =  layerStyleObj.left ;
		}
		if(document.getElementById('popUpCoOrdinatesTop') != null)
		{
		   document.getElementById('popUpCoOrdinatesTop').value =  layerStyleObj.top ;
		}
		
		layerStyleObj.visibility = 'visible';
		iframeStyleObj.visibility = 'visible';
	
		return true;
	}
	catch(e)
	{
		alert(e.description);
	}
}
//Function to obtain the Height & Width of the Browser window.
function colorpickergetSize() 
{
	try
	{
		var myWidth = 0, myHeight = 0;
		if(typeof(window.innerWidth) == 'number') 
		{
		//MoZilla & Safari
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		}
		else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
		{
		//IE 6+ in 
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		}
		else if(document.body && (document.body.clientWidth || document.body.clientHeight)) 
		{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		}
		//Returns Height & Width
		return [myWidth, myHeight];
	}
	catch(e)
	{
		alert(e.description);
	}
}
// determine height for <div> element
function colorpickergetHeight(divObj)
{
	try
	{
		var divHeight = 0;
		if(divObj.offsetHeight)
		{
			divHeight = divObj.offsetHeight;
		}
		else if(divObj.style.pixelHeight)
		{
			divHeight = divObj.style.pixelHeight; 
		}
		return divHeight;
	}
	catch(e)
	{
		alert(e.description);
	}
}

//To get the Scroll Height & Width
function colorpickergetScrollXY() 
{
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) 
  {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } 
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
  {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } 
  else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
  {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function update(objId,iframeId)
{
    var lay=document.getElementById(objId);
    var lay1=document.getElementById(iframeId);
    if(document.getElementById("hidVal").value!="")
    {
        var val=document.getElementById(document.getElementById("hidVal").value);
    }
    //alert(lay);
    //alert(lay.visibility);
    document.getElementById(document.getElementById("hidCntrlId").value).value = document.getElementById("txtfontcolor").value;

    var x = document.getElementById("imgid").value;
    document.getElementById(x).style.backgroundColor=document.getElementById("txtfontcolor").value;
	lay.style.visibility='hidden';
	lay1.style.visibility='hidden';
    if(val!=null)
    {
        val.style.cssText="";
        val.style.display='none';
        val.style.accelerator=true;
    }	
}
function colorpickercancel(objId,iframeId)
{
	var lay=document.getElementById(objId);
	var lay1=document.getElementById(iframeId);
	lay.style.visibility='hidden';
	lay1.style.visibility='hidden';
}

function color_is_(cvalue) 
{
    if(cvalue != 0)
	{
        //	 alert(cvalue);
	    var txt=document.getElementById("txtfontcolor");
	    txt.value = cvalue;
	    document.getElementById("hidCol").value = txt.value;
     }
}

document.onmouseup=Function("ddEnabled=false");