/*********************************************************************************************************************
.js file for the DispPage.asp, containing the following functions.
	
	1.  HighLightELement			- For highlighting Articles,Ads - on mouseover.
	2.  loadPage					- Verifying the browser version, if < 5.5, redirect to error.asp with download option.
	3.  HighLightElementPhoto		- For highlighting Photos - on mouseover.
	4.  ClearElementPhoto			- For clearing the Highlight elements for a photo.
	5.  ClearElement				- For clearing the Highlight elements for articles,Ads.
	8.  glowArticle					- When queried from search results, while showing the page, highlight the article that has been returned.
**********************************************************************************************************************/

var browser=navigator.appName;
//var oPopup = window.createPopup();
var divWidth=2;
var divColor='solid red';

function loadPage() {
	version=0
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		temp=navigator.appVersion.split("MSIE")
		version=parseFloat(temp[1])
		if (version<5.5) 
			parent.window.location.href = "error.asp?errNumb=20"
	}
}

//******************************* START FOR CORNER FLIPS ******************************* 
//RAVI KUMAR
function showFlipXB(id) 
{
	disableFlip();
	if (id == "lftFlip") {
		if (document.getElementById("lftFlip")) {
			document.getElementById("lftFlip").innerHTML = "<img src='images/yellow/leftCorner.gif' border=0 width=50 height=50>";
		}
	} 
	if (id == "lftdwnFlip") {
		if (document.getElementById("lftdwnFlip")) {
			document.getElementById("lftdwnFlip").innerHTML = "<img src='images/yellow/leftdownCorner.gif' border=0 width=50 height=50>";
		}
	} 
	if (id == "rtFlip") {
		if (document.getElementById("rtFlip")) {
			document.getElementById("rtFlip").innerHTML = "<img src='images/yellow/rightCorner.gif' border=0 width=50 height=50>";
		}
	}
	if (id == "rtdwnFlip") {
		if (document.getElementById("rtdwnFlip")) {
			document.getElementById("rtdwnFlip").innerHTML = "<img src='images/yellow/rightdownCorner.gif' border=0 width=50 height=50>";
		}
	}
}

function showFlip(id) 
//function showFlip(id,skins) 
{
	if (document.getElementById(id).children[0].src.indexOf("spacer.gif") >= 0 ) //!= -1) 
	{
		if (id == "lftFlip") {
			if (document.getElementById("lftFlip")) {
				document.getElementById("lftFlip").innerHTML = "<img src='images/yellow/leftCorner.gif' border=0 width=50 height=50>";
			}
		} 
		if (id == "lftdwnFlip") {
			if (document.getElementById("lftdwnFlip")) {
				document.getElementById("lftdwnFlip").innerHTML = "<img src='images/yellow/leftdownCorner.gif' border=0 width=50 height=50>";
			}
		} 
		if (id == "rtFlip") {
			if (document.getElementById("rtFlip")) {
				document.getElementById("rtFlip").innerHTML = "<img src='images/yellow/rightCorner.gif' border=0 width=50 height=50>";
			}
		}
		if (id == "rtdwnFlip") {
			if (document.getElementById("rtdwnFlip")) {
				document.getElementById("rtdwnFlip").innerHTML = "<img src='images/yellow/rightdownCorner.gif' border=0 width=50 height=50>";
			}
		}
	}
}

function disableFlip() 
{
	if (document.getElementById('lftFlip')) {
		document.getElementById('lftFlip').innerHTML = "<img src='images/yellow/spacer.gif' border=0 width=50 height=50>";
	}
	if (document.getElementById('lftdwnFlip')) {
		document.getElementById('lftdwnFlip').innerHTML = "<img src='images/yellow/spacer.gif' border=0 width=50 height=50>";
	}
	if (document.getElementById('rtFlip')) {
		document.getElementById('rtFlip').innerHTML = "<img src='images/yellow/spacer.gif' border=0 width=50 height=50>";
	}
	if (document.getElementById('rtdwnFlip')) {
		document.getElementById('rtdwnFlip').innerHTML = "<img src='images/yellow/spacer.gif' border=0 width=50 height=50>";
	}
}
//******************************* END FOR CORNER FLIPS ******************************* 

//puts the image glow
function HighLightElement(ob,type,brwsr) {
    var total2Highlight;var divID;
    divID=ob.id;
	total2Highlight=(document.getElementsByName(ob.id).length);
	if (total2Highlight > 1) {
		if (brwsr == 'ie') {
			for(var mycount=0;mycount<total2Highlight;mycount++) {
				oldackgroung=document.getElementsByName(divID).item(mycount).style.background;
				oldfilter=document.getElementsByName(divID).item(mycount).style.filter;
				if (type == "art") {
					document.getElementsByName(divID).item(mycount).style.background="#7cfc00";
				} else {
					document.getElementsByName(divID).item(mycount).style.background="blue";
				}
				document.getElementsByName(divID).item(mycount).style.filter="progid:DXImageTransform.Microsoft.Alpha( Opacity=25 ,FinishOpacity=0, Style=0)";
			}
		} else {
			for(var mycount=0;mycount<total2Highlight;mycount++)
				document.getElementsByName(divID).item(mycount).style.border="solid violet 2px";
		}
	} else {
		if (brwsr == 'ie') {
			oldackgroung=document.getElementsByName(divID).item(mycount).style.background;
			oldfilter=document.getElementsByName(divID).item(mycount).style.filter;
			if (type =="art") 
				ob.style.background='#7cfc00';
			else
				ob.style.background='blue';
			ob.style.filter="progid:DXImageTransform.Microsoft.Alpha( Opacity=25 ,FinishOpacity=0, Style=0)";
		} else {
				var mycount=0;
				if (type == "art") 
					document.getElementsByName(divID).item(mycount).style.border="solid violet 2px";
				else 
					document.getElementsByName(divID).item(mycount).style.border="solid blue 2px";
		}	
	}
		disableFlip();
}
function HighLightElementPhoto(ob) {
	//if (oPopup) {
	//	if (oPopup.isOpen) oPopup.hide();
	//}
	var total2Highlight;var divID
	divID=ob;
	total2Highlight=(document.getElementsByName(ob).length);
	if (total2Highlight > 1) {
		for(var mycount=0;mycount<total2Highlight;mycount++) {
			oldackgroung=document.getElementsByName(divID).item(mycount).style.background;
			oldfilter=document.getElementsByName(divID).item(mycount).style.filter;
			document.getElementsByName(divID).item(mycount).style.background="#7cfc00";
			document.getElementsByName(divID).item(mycount).style.filter="progid:DXImageTransform.Microsoft.Alpha( Opacity=25 ,FinishOpacity=0, Style=0)";
		}
	} else {
		oldackgroung=document.getElementsByName(divID).item(mycount).style.background;
		oldfilter=document.getElementsByName(divID).item(mycount).style.filter;
		document.getElementsByName(divID).item(mycount).style.background='#7cfc00';
		document.getElementsByName(divID).item(mycount).style.filter="progid:DXImageTransform.Microsoft.Alpha( Opacity=25 ,FinishOpacity=0, Style=0)";
	}
		disableFlip();
}

function ClearElementPhoto(ob) {
	var total2Highlight;var divID;
	divID=ob;
	total2Highlight=(document.getElementsByName(ob).length);
	if (total2Highlight > 1) {
		for(var mycount=0;mycount<total2Highlight;mycount++) {
			document.getElementsByName(divID).item(mycount).style.background=oldackgroung;
			document.getElementsByName(divID).item(mycount).style.filter=oldfilter;
		}
	} else {
		document.getElementsByName(divID).item(mycount).style.background=oldackgroung;
		document.getElementsByName(divID).item(mycount).style.filter=oldfilter;
	}
}

function ClearElement(ob,brwsr) {
	var total2Highlight
	var divID
	divID=ob.id;
	total2Highlight=(document.getElementsByName(ob.id).length);
	if (total2Highlight > 1) {
		if (brwsr == 'ie') {
			for(var mycount=0;mycount<total2Highlight;mycount++) {
				document.getElementsByName(divID).item(mycount).style.background=oldackgroung;
				document.getElementsByName(divID).item(mycount).style.filter=oldfilter;
			}
		} else {
			for(var mycount=0;mycount<total2Highlight;mycount++) 
				document.getElementsByName(divID).item(mycount).style.border="solid white 0px";	
		}
	} else {
		if (brwsr == 'ie') {
			ob.style.background=oldackgroung;
			ob.style.filter=oldfilter;
		} else {
			document.getElementsByName(divID).item(mycount).style.border="solid white 0px";
		}
	}
}
function glowArticle(art1,brwsr) {
	var totalDivs;
	totalDivs=(document.getElementsByName(art1).length);
	if (totalDivs > 1) {
		if (brwsr == 'ie') {
			for(var mycount=0;mycount<totalDivs;mycount++) {
				document.getElementsByName(art1).item(mycount).style.background='rgb(255,125,255)';
				document.getElementsByName(art1).item(mycount).style.filter="progid:DXImageTransform.Microsoft.Alpha( Opacity=25 ,FinishOpacity=0, Style=0)";
			}
		} else {
			for(var mycount=0;mycount<totalDivs;mycount++)
				document.getElementsByName(art1).item(mycount).style.border="solid pink 2px";
		}
	} else {
		if (brwsr == 'ie') {
			eval("document.getElementById('"+ art1 +"').style.background ='rgb(255,125,255)'");
			document.getElementById(art1).style.filter="progid:DXImageTransform.Microsoft.Alpha( Opacity=25 ,FinishOpacity=0, Style=0)";
		} else {
			var mycount = 0;
			document.getElementsByName(art1).item(mycount).style.border="solid pink 2px";
		}	
	}
}


//Function used to close the opened div
function CloseElement(ob){
	document.all.ShowArt.style.visibility="hidden";
}

function openURL(strPageName){
	window.open(strPageName,"mywin")
}
function openMail(strTo) {
	var mUrl = "mailTo.aspx?toadd=" + strTo;
	window.open(mUrl,"myMail","width=580,height=350,toolbar=no,menubar=no,address=no,scrollbars=yes,resizable=yes");
}
function openMultiMedia(strFilePath){
	var vidPath = "showVideo.asp?file=" + strFilePath;
	window.open(vidPath,"myMedia","width=540,height=400,toolbar=no,menubar=no,address=no,scrollbars=yes,resizable=yes")
}
function checkflashinstalled() {

	var flshInstalled;
	for(var i=7; i>0; i--){
		flashVersion = 0;
		try{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
			flashVersion = i;
			flshInstalled = 0;
			return (0);
		}
		catch(e){
			flshInstalled = 1;
			//alert(e);
		}
			
	}
	return (flshInstalled);
}
//play flash on click
function openFlash(strFilePath){
	//alert(strFilePath);
	if (checkflashinstalled() == 0 ) {
		var xFlsh = (document.body.offsetWidth)/2 + document.body.scrollLeft;
		var yFlsh = (document.body.offsetHeight - 350)/2 + document.body.scrollTop;
		
		flshMovie.style.display='block';
		
		
		flshMovie.style.top = yFlsh ;
		flshMovie.style.left = document.getElementById("divPgSrc").offsetLeft
		
		myMovieName.width = "600px";
		flshMovie.width = 600;
		
		
		myMovieName.movie = strFilePath;
		myMovieName.stop();
		myMovieName.play();
		
		closeflash.style.display = 'block';
		closeflash.style.left = parseInt(flshMovie.style.left) + parseInt(flshMovie.width) -20;
		closeflash.style.top = parseInt(flshMovie.style.top) + 5 + 'px';
		if(strFilePath.indexOf("adnew.swf")== -1){
			checkPlay();
		}
	} else {
		alert("The application requires flash to be installed.");
	}	
}
function checkPlay() {
	if (myMovieName.IsPlaying()) {
		setTimeout('checkPlay()',2000);
	} else {
		myMovieName.Stop();
		moveflash();
	}
}

function moveflash() {
	if ((parseInt(flshMovie.style.top) + 100) >= document.body.offsetHeight) {
		CloseFlashFile();
	} else {
		flshMovie.style.left = parseInt(flshMovie.style.left) + 5 + 'px';
		flshMovie.style.top = parseInt(flshMovie.style.top) + 5 + 'px';
		if (flshMovie.width > 50) {
			myMovieName.width = parseInt(myMovieName.width) - 5;
			flshMovie.width = parseInt(flshMovie.width) - 5;
		}
		setTimeout('moveflash()',0);
	}
}
function playAudio(strFilePath){
	audPlayStp.style.display="block";
	//myMediaPlayer.stop();
	myMediaPlayer.filename = strFilePath;
}
function audioPlay() {
	var playStatus = myMediaPlayer.playState;
	if (playStatus == 0) myMediaPlayer.play();
	else if (playStatus == 1) myMediaPlayer.play();
}
function audioPause() {
	var playStatus = myMediaPlayer.playState;
	if (playStatus == 2) {
	  myMediaPlayer.pause();
	}

}
function CloseFlashFile() {
	myMovieName.stop();
	flshMovie.style.display = 'none';
	closeflash.style.display = 'none';
}
function myMovieName_DoFSCommand(command, args) { 
	if (command == "CloseFlashFile") { 
		//alert("Here's the Flash message: " + args[0]);
		CloseFlashFile();
	}
}
 
function sendFeedback() {
	var mFdback = "feedback.aspx";
	window.open(mFdback,"myFeedback","width=470,height=325,toolbar=no,menubar=no,address=no,scrollbars=yes,resizable=yes");
}
