var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height, eventObj){
var docX  = screen.availWidth - (296+25)  , docY = 10 ;

if( typeof( eventObj.pageX ) == 'number' ){ docX = eventObj.pageX+20; docY = eventObj.pageY;  }
else { 
	docX = eventObj.x + 10;
		//eventObj.clientX+ (document.documentElement.scrollLeft ?	  document.documentElement.scrollLeft : document.body.scrollLeft) +20;  
	docY =eventObj.clientY -10 + window.document.body.scrollTop ;  //eventObj.y ; //eventObj.clientY;  
	}

//return evt.clientX + (document.documentElement.scrollLeft ?	  document.documentElement.scrollLeft : document.body.scrollLeft);
height= 150;
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
//	alert(docX+"-"+docY);
docX = ((docX+ width ) <= 635) ? docX : (docX-width-20) ;
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
//document.getElementById("dwindow").style.left="30px"
//document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("dwindow").style.left=docX +"px";
document.getElementById("dwindow").style.top= docY + "px";//ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url;
}


//window.moveTo(screen.availWidth- (browseWidth+10), 0 );

}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
if(window.frames["cframe"] ) window.frames["cframe"].document.frmVideo.VIDEO.controls.stop();
document.getElementById("dwindow").style.display="none";
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}

/////////////  ADD On 29-DEC-2009 for Audio File
	var element;
	var divPlayer_Pop;
	var offsetxPlay;
	var offsetyPlay;
	var playerForm = "<div id=\"divPlayer_Pop\" name=\"divPlayer_Pop\" style=\"position:absolute;font-family: verdana;  font-size: 11px;  color: #000000;  margin: 5px;  padding: 5px;  height: auto;  width: auto; text-align: left;  border:1 px solid #000000;  background-color: #FFFFFF;top: 0px; left:0px;width:300px; visibility:hidden;\">";
	playerForm +="<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"302\" style=\"border-style: solid; border-width: 2\">";
	playerForm +="<tr bgcolor=\"#94CCED\"><td width=\"298\" height=\"25\" colspan=\"4\"><img border=\"0\" src=\"/portal/music/image/mmlogo.jpg\" width=\"127\" height=\"18\"></td><td width=\"20%\" align=\"center\"><span align=\"right\"><input type=\"button\" name=\"but\" value=\"Close\" onClick=\"closePopup()\" style=\"border:1 solid #94CCED;font-size:10px;\"></span></td></tr>";

	playerForm +="<tr><td colspan=5 bgcolor=\"#5EB1E3\" border=0 background=\"/portal/music/image/background.jpg\" width=\"300\" heigth=\"25\"><span id=\"newMusicPlayer\"></span></td></tr>";

	playerForm +="</table>";
	playerForm +="</div>";
	document.writeln(playerForm);
function fnPlayMusic(thisObj,musicFile,e){
	try{
		divPlayer_Pop = document.getElementById("divPlayer_Pop");		
		 element = document.getElementById("newMusicPlayer");
		 var playerStr ="";
		 //classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" Windows Media Player 6.4
		 playerStr +='<object type=\"'+getMimeType()+'\" data=\"'+musicFile+'\" width=\"300\" height=\"25\"><param name=\"src\" value=\"'+musicFile+'\" /><param name=\"controller\" value=\"true\" /><param name=\"autoplay\" value=\"true\" /><param name=\"autostart\" value=\"1\" /><param name=\"pluginurl\" value=\"\" /><embed src=\"'+musicFile+'\" type=\"'+getMimeType()+'\" width=\"300\" height=\"25\" autostart=\"true\" controller=\"true\" enablejavascript=\"true\"></embed></object>';
		 element.innerHTML=playerStr;
		 try{
			divPlayer_Pop.style.visibility="visible";
			divPlayer_Pop.style.zIndex="2";
		}catch(error){}
		if( !divPlayer_Pop ) return ;
		try{
			offsetxPlay = e.clientX;
			offsetyPlay = e.clientY;
			if(offsetxPlay ==undefined){
				offsetxPlay =ie5? event.clientX : e.clientX;
				offsetyPlay =ie5? event.clientY : e.clientY;
			}
		}catch(error){}	
		divPlayer_Pop.style.left= (offsetxPlay ) +"px";
		divPlayer_Pop.style.top = offsetyPlay+window.document.body.scrollTop+1+"px";
	}catch(error){}	
	var play = false ;	
	if(thisObj){		
		var prevHtml = thisObj.innerHTML;
		var stopPlaying = "";
		play = true ;		
	}	
}
function closePopup(){
	divPlayer_Pop.style.visibility="hidden";
	if(element)	element.innerHTML="";		
}
function getMimeType(){
	var mimeType = "application/x-mplayer2"; //default
	var agt=navigator.userAgent.toLowerCase();
	if (navigator.mimeTypes && agt.indexOf("windows")==-1) {
		//non-IE, no-Windows
		var plugin=navigator.mimeTypes["audio/mpeg"].enabledPlugin;
		if (plugin) mimeType="audio/mpeg" //Mac/Safari & Linux/FFox
	}//end no-Windows
	return mimeType
}

function doNothing(){}	
function toggleText(val){
   var divMore = document.getElementById('divMore');
   var divTxt = document.getElementById('divTxt');
   if(divMore && divTxt){
		if(val == 1 ){ divMore.style.display='block'; divTxt.style.display='none'; }
	  else { divMore.style.display='none'; divTxt.style.display='block';}
      //if(divTxt.innerHTML.indexOf('more') > -1 ){ divMore.style.display='block'; divTxt.innerHTML="";}
	  //else { divMore.style.display='none';  divTxt.innerHTML="more Stories &raquo;";}
	 } 
}
