
//<!--
	if(document.getElementById("TextContent")!=null){
		var initialTextValue = document.getElementById("TextContent").value;
	}
	var type = 0;
	var whitespace = " \t\n\r";
	var BASE_RADIX = 10;
	var adPresent = false;
	var isLocal = false;

	function stripInitialWhitespace (s)
	{   
		var i = 0;
		while ((i < s.length) && (whitespace.indexOf(s.charAt(i)) != -1))
		   i++;
		
		return s.substring (i, s.length);
	}

	function stripTrailingWhitespace (s)
	{  
		var len = s.length;
		var i = len-1;

		while ((i >= 0) && (whitespace.indexOf(s.charAt(i)) != -1))
		   i--;
		return s.substring (0, i+1);
	}

	function isEmpty(s){
		s = stripInitialWhitespace(s);
		s = stripTrailingWhitespace (s);
		if(s.length==0){
			return true;
		}else{
			return false;
		}
	}
	
	if(document.getElementById("mediaContent")!=null){
		document.getElementById("mediaContent").bgColor = document.getElementById("backC").value;
	}
	if(document.getElementById("TextContent")!=null){
		document.getElementById("TextContent").style.backgroundColor = document.getElementById("backC").value;
		document.getElementById("textItem").style.backgroundColor = document.getElementById("backC").value;
	}
	if(document.getElementById("TextContent")!=null){
		document.getElementById("TextContent").style.color = document.getElementById("foreC").value;
	}
	
	function showSlide(slideNo) {
		document.getElementById("slideNo").value = slideNo;
		document.getElementById("userAction").value = "showSlide";
		document.forms[0].submit();
	}

	/* This function checks whether the passed the character is a digit or not */
	function isDigit (c)
	{   
		return ((c >= "0") && (c <= "9"))
	}

	/* Function to check whether the input string is an empty string or not */

	function isEmpty(s)
	{   
		return ((s == null) || (s.length == 0))
	}

	function trim(s)
	{
		return (stripInitialWhitespace(stripTrailingWhitespace(s)));
	}
	/* Function to remove the initial whilespaces in a string */

	function stripInitialWhitespace (s)
	{   
		var i = 0;
		while ((i < s.length) && (whitespace.indexOf(s.charAt(i)) != -1))
		   i++;
		
		return s.substring (i, s.length);
	}

	/* Function to remove the trailing whitespaces in a string */

	function stripTrailingWhitespace (s)
	{  
		var len = s.length;
		var i = len-1;

		while ((i >= 0) && (whitespace.indexOf(s.charAt(i)) != -1))
		   i--;
		return s.substring (0, i+1);
	}


	function isMobileNum(entry)
	{
		var i = 1,len = 0;
		entry = trim(entry);
		len = entry.length;
		if( (entry.charAt(0) == '+') || (entry.charAt(0) >= '0' && entry.charAt(0) <= '9') )
		{
			for(i = 1 ; i < len ; i++)
			{
				if(entry.charAt(i) < '0' || entry.charAt(i) > '9')
					return false;
			}
		}
		else
		{
			return false;
		}
		return true;
	}

	function isValidEmail(email)
	{
		// a very simple email validation checking.
		// you can add more complex email checking if it helps
			if(email.length <= 0)
				{
				  return true;
				}
			var splitted = email.match("^(.+)@(.+)$");
			if(splitted == null) return false;
			if(splitted[1] != null )
			{
			  var regexp_user=/^\"?[\w-_\.]*\"?$/;
			  if(splitted[1].match(regexp_user) == null) return false;
			}
			if(splitted[2] != null)
			{
			  var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
			  if(splitted[2].match(regexp_domain) == null)
			  {
					var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
					if(splitted[2].match(regexp_ip) == null) return false;
			  }// if
			  return true;
			}
			return false;
		}

	/* Function to check whether the input string is an integer or not */

	function isInteger (s)
	{   
		var i = null;
		var c = "";
		if (isEmpty(s)) 
		   if (isInteger.arguments.length == 1) return false;
		   else return (isInteger.arguments[1] == true);
		for (i = 0; i < s.length; i++)
		{   
			c = s.charAt(i);

			if (!isDigit(c)) return false;
		}
		return true;
	}


	/* Function to check whether the input string is in the range specified or not.*/

	function isIntegerInRange (s, min, max)
	{   
		if (isEmpty(s)) 
		   if (isIntegerInRange.arguments.length == 1) return false;
		   else return (isIntegerInRange.arguments[1] == true);
	  
		if (!isInteger(s, false)) return false;
		var num = parseInt (s,BASE_RADIX);
		return (!(num < min) && (num <= max));
	}

	function showMediaFromGallery(fileName , contentType, url, galleryType, msgId ) {
		if(popupHandler && !popupHandler.closed){
			popupHandler.close();
			popupHandler = null;
		}
		if (galleryType == "PUBLIC"){
			if (contentType == "images"){
				if (isVideoAttached){
					//resetFileControl();
					resetImgFile();
				}
				addImage (null, gal_public , fileName+"|"+url, (serverPath+url),null);
			}else if(contentType == "audio"){
				if (isVideoAttached){
					alert(document.getElementById("deleteVideo").getAttribute("val"));
				}else{
					addAudio (null , gal_public , fileName+"|"+url , (serverPath+url),null);
				}
			}else if(contentType == "video") {
				if(isAudioAttached){
					alert(document.getElementById("deleteAudio").getAttribute("val"));
				}else{
					//resetFileControl();
					resetImgFile();
					addVideo (null , gal_public , fileName+"|"+url , (serverPath+url),null);
				}
			}
		}else if (galleryType == "PRIVATE"){
			var extension = "s";
			if(fileName.lastIndexOf(".")!=-1){
				extension = fileName.substring(fileName.lastIndexOf(".")+1).toLowerCase();
			}
			if(isRealPlayerSupport(extension)==false && isMediaPlayerSupport(extension)){
				extension = "s";
			}
			/*
			if(isMediaPlayerExist==false){
				if(fileName != ""){
					if(fileName.lastIndexOf(".")!=-1){
						extension = fileName.substring(fileName.lastIndexOf(".")+1).toLowerCase();
					}
				}
			}*/
			if (contentType == "images"){
				if (isVideoAttached){
					//resetFileControl();
					resetImgFile();
				}
				addImage (null, gal_private , msgId , (serverPath+"S.s?m="+msgId),fileName);
			}else if (contentType == "audio"){
				if (isVideoAttached){
					alert(document.getElementById("deleteVideo").getAttribute("val"));
				}else{
					addAudio (null , gal_private , msgId , (serverPath+"Stream/file."+extension+"?m="+msgId),fileName);
				}
			}else if (contentType == "video"){
				if(isAudioAttached){
					alert(document.getElementById("deleteAudio").getAttribute("val"));
				}else{
					//resetFileControl();
					resetImgFile();
					addVideo (null , gal_private , msgId , (serverPath+"Stream/file."+extension+"?m="+msgId),fileName);
				}
			}
		}
	}
	
	//	Block for Loading of extensions in array variables	
	{
		if(audExt){
			if (audExt != "") {
				audioExt = audExt.split(",");
			}
		}
		if(vidExt){
			if (vidExt != "") {
				videoExt = vidExt.split(",");
			}
		}
		if(imgExt){
			if (imgExt != "") {
				imageExt = imgExt.split(",");
			}
		}
		if(mediaPlayerExt){
			if (mediaPlayerExt != "") {
				mediaExt = mediaPlayerExt.split(",");
			}
		}
		if(realPlayerExt){
			if (realPlayerExt != "") {
				realExt = realPlayerExt.split(",");
			}
		}
	}

	function isSlideItemPresent(){
		if(	document.getElementById("imageIcon").style.display == "inline" ||
			document.getElementById("videoIcon").style.display=="inline" ||
			document.getElementById("audioIcon").style.display=="inline" ||
			document.getElementById("TextContent").value != ""  ){

			return true;
		}else{
			return false;
		}
	}
	

	function submitForm(value,val) {
		submit = false;
		//closeOpenedWindow();
		document.getElementById("mode").value = val;
		if (value=="add") {
			if(isSlideItemPresent()){
			
				if (!isInteger(document.getElementById("duration").value)) {
					alert(document.getElementById("slideNoInvalid").getAttribute("val"));
				}else{
					if(trim(document.getElementById("duration").value)==0){	
						alert(document.getElementById("slideNoInvalid").getAttribute("val"));
					}else{
						submit = true;
						document.getElementById("userAction").value = "addSlide";
						document.getElementById("audioContent").innerHTML = "";
						document.getElementById("videoContent").innerHTML = "";
					}
				}
			}else {
				alert(document.getElementById("noItem").getAttribute("val"));
			}
			

		}else if(value=="update") {
			
			if(isSlideItemPresent()){
			
				if(initialTextValue != document.getElementById("TextContent").value){
					document.getElementById("txtMessageID").value = 0;
				}
				submit = true;
				document.getElementById("userAction").value = "updateSlide";
				document.getElementById("audioContent").innerHTML = "";
				document.getElementById("videoContent").innerHTML = "";
			}else {
				alert(document.getElementById("noItem").getAttribute("val"));
			}
			
		}else if(value=="delete") {
			submit = true;
			document.getElementById("userAction").value = "removeSlide";
			document.getElementById("audioContent").innerHTML = "";
			document.getElementById("videoContent").innerHTML = "";

		}else if(value=="send"){
			if(document.getElementById("canSend").value=="true"){
				//	Check for mandatory fields
				if(checkMandatoryFields()){
					submit = true;
					document.getElementById("userAction").value = "sendMMS";
				}
			}else{
				alert(document.getElementById("noSlides").getAttribute("val"));
			}

		}else if(value=="cancel"){
			submit = true;
			document.getElementById("userAction").value = "cancelSlide";
			document.getElementById("audioContent").innerHTML = "";
			document.getElementById("videoContent").innerHTML = "";

		}else if(value=="saveAsDraft"){
			if(document.getElementById("canSend").value=="true"){
				document.getElementById("userAction").value = "saveAsDraft";
				submit = true;
			}else{
				alert(document.getElementById("noSlides").getAttribute("val"));
			}
		}
		if (submit){
			document.forms[0].submit();
		}
	}

	function checkMandatoryFields(){
		var retVal = true;
		var addresses;
		var counter = 0;
		if((isEmpty(document.getElementById("to").value) && isEmpty(document.getElementById("cc").value) && isEmpty(document.getElementById("bcc").value))){
			alert (document.getElementById("toEmpty").getAttribute("val"));
			document.getElementById("to").blur();
			retVal = false;
		}else if(document.getElementById("dDate").checked==true && document.getElementById("deliveryDate").value==""){
			alert (document.getElementById("dateExpected").getAttribute("val"));
			retVal = false;
		}else{
			if(isEmpty(document.getElementById("to").value)==false){
				if(document.getElementById("to").value.indexOf(",")==-1){
					addresses = [document.getElementById("to").value];
				}else{
					addresses = document.getElementById("to").value.split(",");
				}
				for(counter=0;counter<addresses.length;counter++){
					if(isValidEmail(addresses[counter])==false && isMobileNum(addresses[counter])==false){
						alert(document.getElementById("invalidToAddress").getAttribute("val"));
						document.getElementById("to").focus();
						return false;
					}
				}
			}

			if(isEmpty(document.getElementById("cc").value)==false){
				if(document.getElementById("cc").value.indexOf(",")==-1){
					addresses = [document.getElementById("cc").value];
				}else{
					addresses = document.getElementById("cc").value.split(",");
				}
				for(counter=0;counter<addresses.length;counter++){
					if(isValidEmail(addresses[counter])==false && isMobileNum(addresses[counter])==false){
						alert(document.getElementById("invalidCcAddress").getAttribute("val"));
						document.getElementById("cc").focus();
						return false;
					}
				}
			}

			if(isEmpty(document.getElementById("bcc").value)==false){
				if(document.getElementById("bcc").value.indexOf(",")==-1){
					addresses = [document.getElementById("bcc").value];
				}else{
					addresses = document.getElementById("bcc").value.split(",");
				}
				for(counter=0;counter<addresses.length;counter++){
					if(isValidEmail(addresses[counter])==false && isMobileNum(addresses[counter])==false){
						alert(document.getElementById("invalidBccAddress").getAttribute("val"));
						document.getElementById("bcc").focus();
						return false;
					}
				}
			}
		}
		return retVal;
	}

	function getMediaPlayer(src,width,height){

		var agt=navigator.userAgent.toLowerCase();
		var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
		var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
		var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
		var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));
		var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt 1.")!=-1) || (agt.indexOf("windows nt 2.")!=-1) || (agt.indexOf("windows nt 3.")!=-1) || (agt.indexOf("windows nt 4.")!=-1));
		var element = "";
		if(is_win95==false && is_win98==false && is_winnt==false && is_winme==false && is_win2k==false){
			
			element += "<object classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'";
			element += " type='application/x-oleobject'";
			element += " width="+width;
			element += " height="+height;
			if(width==0 && height==0){
				element += " style=visibility:visible >";
			}else{
				element += " style=visibility:visible >";
			}
			element += " <param name='fileName' value='"+src+"'/>";
			element += " <param name='autoStart' value='true'/>";
			element += " <param name='showControls' value='false' />";
			element += " <param name='enableContextMenu' value='false' />";
			element += " <EMBED";
			element += " type='application/x-mplayer2'";
			element += " src='"+src+"' ";
			element += " ShowControls='0'";
			element += " width="+width;
			element += " height="+height;
			element += " autoStart='true'";
			element += " enableContextMenu='false'";
			if(width==0 && height==0){
				element += " style=visibility:visible>";
			}else{
				element += " style=visibility:visible>";
			}
			element += " </EMBED>";
			element += " </object>";

		}else{

			element += " <EMBED";
			element += " type='application/x-mplayer2'";
			element += " src='"+src+"' ";
			element += " ShowControls='0'";
			element += " width="+width;
			element += " height="+height;
			element += " autoStart='true'";
			element += " enableContextMenu='false'";
			if(width==0 && height==0){
				element += " style=visibility:visible>";
			}else{
				element += " style=visibility:visible>";
			}
			element += " </EMBED>";
		}

		return element;
	}

	function getRealPlayer(src,width,height){
		
		var element = "<object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' ";
		element += " width="+width;
		element += " height="+height;
		if(width==0 && height==0){
			element += " style=visibility:visible >";
		}else{
			element += " style=visibility:visible >";
		}
		element += " <param name='src' value=\""+src+"\"/>";
		element += " <param name=\"autostart\" value=\"true\"/>";
		element += " <param name='controls' value='ImageWindow' />";
		element += " <param name='enableContextMenu' value='false' />";

		element += "<EMBED";
		element += " type='audio/x-pn-realaudio-plugin'";
		element += " src='"+src+"'";
		element += " controls='ImageWindow'";
		element += " width="+width;
		element += " height="+height;
		element += " autoStart='true'";
		element += " enableContextMenu='false'";
		if(width==1 && height==1){
			element += " style=visibility:visible";
		}else{
			element += " style=visibility:visible";
		}
		element += "></EMBED>";
		element += " </object>";

		return element;
	}

	function getTime(){
		var h = new Date();
		return (""+h.getHours()+h.getMinutes()+h.getSeconds());
	}

	function playMedia() {
		if (document.getElementById("audioIcon").style.display == "inline" || document.getElementById("videoIcon").style.display == "inline") {
			try{
				if (isAudioAttached) {
					var playerSource = document.getElementById("audioTag").getAttribute("path");
					var fileExt = document.getElementById("audioTag").getAttribute("ext");
					if(isLocal==false){
						playerSource += "|"+getTime();
					}
					var playerString = "";
					if(isMediaPlayerExist && isMediaPlayerSupport(fileExt)){
						playerString = getMediaPlayer (playerSource, 0, 0);
					}else if (isRealPlayerSupport(fileExt) && isRealPlayerExist){
						playerString = getRealPlayer (playerSource, 0, 0);
					}else{
						alert(document.getElementById("cantPlayAudio").getAttribute("val"));
					}
					var lowerCasePath = playerSource.toLowerCase();
					document.getElementById("audioContent").innerHTML = playerString;
				}
				if (isVideoAttached){
					document.getElementById("imageContent").style.display = "none";
					document.getElementById("videoContent").style.display = "inline";
					var playerSource = document.getElementById("videoTag").getAttribute("path");
					var fileExt = document.getElementById("videoTag").getAttribute("ext");
					if(isLocal==false){
						playerSource += "|"+getTime();
					}
					var playerString = "";
					if(isMediaPlayerExist && isMediaPlayerSupport(fileExt)){
						playerString = getMediaPlayer (playerSource, displayScreenWidth, displayScreenHeight );
					}else if (isRealPlayerSupport(fileExt) && isRealPlayerExist){
						playerString = getRealPlayer (playerSource, displayScreenWidth, displayScreenHeight );
					}else{
						alert(document.getElementById("cantPlayVideo").getAttribute("val"));
					}
					document.getElementById("videoContent").innerHTML = playerString;
				}
			
			}catch(e){
				if (isVideoAttached){
					alert (document.getElementById("cantPlayVideo").getAttribute("val"));
				}else{
					alert (document.getElementById("cantPlayAudio").getAttribute("val"));
				}
				isPlaying = false;
			}
			
		}
	}
	
	function changeDisableProperties (ctrls) {
		for (index=0;index<ctrls.length;index++){
			document.getElementById(ctrls[index][0]).disabled = ctrls[index][1];
		}
	}
	
	function changeDisplayStyleToCtrl (ctrlID, style) {
		document.getElementById (ctrlID).style.display = style;
	}
	
	function changeDisplayStyleToCtrls (ctrlsID, style) {
		for(index=0;index<ctrlsID.length;index++){
			document.getElementById (ctrlsID[index]).style.display = style;
		}
	}
	
	function stopMedia() {
		if (document.getElementById("audioIcon").style.display == "inline" || document.getElementById("videoIcon").style.display == "inline") {
			document.getElementById("audioContent").innerHTML = "";
			document.getElementById("videoContent").innerHTML = "";
		}
	}
	
	function deleteImgVid() {

		if (document.getElementById("slideImg")!=null || isVideoAttached){
			if (document.getElementById("slideImg")!=null) {
				if(is_explorer){
					document.getElementById("slideImg").removeNode(true);
				}else{
					document.getElementById("imageContent").innerHTML = "";
				}
			}
			document.getElementById("imgMessageID").value="-1";
			if(document.getElementById("videoIcon").style.display == "inline" && isVideoAttached) {
				document.getElementById("videoContent").innerHTML = "";
			}
			isVideoAttached = false;
			isImageAttached = false;
			document.getElementById("imgGallery").value = gal_none;
			//document.getElementById("tmpImgVideo").value="";
			changeDisplayStyleToCtrls(new Array("videoIcon","imageIcon"),"none");

			//resetFileControl();
			resetImgFile();

			document.getElementById("AudioFile").disabled = false;
			document.getElementById("deleteAud").disabled = false;

		}else if(document.getElementsByName("imgVidFile")[0].value != "") {
			//resetFileControl();
			resetImgFile();
			document.getElementById("AudioFile").disabled = false;
			document.getElementById("deleteAud").disabled = false;
		}else{
			alert (document.getElementById("noImageItem").getAttribute("val"));
		}
	}

	function resetImgFile (){
		var imFileStrForIE = "<input type=file class=textBorder  name=imgVidFile  onclick=imgFileOnClick(this) onfocus=imgFileFocus(this) value='' id=ImageFile/>";
		var imFileStrForFirefox = "<input type=file class=textBorder  name=imgVidFile  onchange='updateImgVid(this)' value=\"\" id=ImageFile/>";
		var imFileStrForMozilla = "<input type=file class=textBorder  name=imgVidFile  onclick=updateImgVid(this) value='' id=ImageFile/>";

		if(isFireFox || is_opera || is_netscape8){
			document.getElementById("imFileCtrl").innerHTML = imFileStrForFirefox;
		}else if(isMozilla || is_netscape){
			document.getElementById("imFileCtrl").innerHTML = imFileStrForMozilla;
		}else{
			document.getElementById("imFileCtrl").innerHTML = imFileStrForIE;
		}
	}

	function resetAudFile(){
		var auFileStrForIE = "<input type=\"File\" name=\"audFile\" class=\"textBorder\" onclick=\"audFileOnClick(this)\" onfocus=\"audFileFocus(this)\" id=\"AudioFile\" value=\"\"/>";
		var auFileStrForFirefox = "<input type=\"File\" name=\"audFile\" class=\"textBorder\" onchange=\"updateAud(this)\" id=\"AudioFile\" value=\"\"/>";
		var auFileStrForMozilla = "<input type=\"File\" name=\"audFile\" class=\"textBorder\" onclick=\"updateAud(this)\" id=\"AudioFile\" value=\"\"/>";

		if(isFireFox || is_opera || is_netscape8){
			document.getElementById("auFileCtrl").innerHTML = auFileStrForFirefox;
		}else if(isMozilla || is_netscape){
			document.getElementById("auFileCtrl").innerHTML = auFileStrForMozilla;
		}else{
			document.getElementById("auFileCtrl").innerHTML = auFileStrForIE;
		}
	}
	
	function deleteAudio() {
		var i = 1;
		document.getElementById("audMessageID").value="-1";
		if (document.getElementById("audioIcon").style.display == "inline"){
			document.getElementById("audioContent").innerHTML = "";
			document.getElementById("audioTag").setAttribute("path","");
			isAudioAttached = false;
			document.getElementById("audGallery").value = gal_none;
			changeDisplayStyleToCtrl("audioIcon","none");
			resetAudFile();
		}else if(document.getElementsByName("audFile")[0].value != ""){
			resetAudFile();
			document.getElementById("ImageFile").disabled = false;
			document.getElementById("deleteImg").disabled = false;
		}else{
			alert (document.getElementById("noAudioItem").getAttribute("val"));
		}
		adPresent = false;
	}

	function updateImgVid(obj) {
		//	Update the Image/Video path text field visible to the user
		//document.getElementById('tmpImgVideo').value=obj.value;
		if (obj.value != "") {
			if (isImage(obj.value)) {
				//	Display image
				addImage (obj, gal_local , "0", null, null);


			}else if (isVideo(obj.value)) {
				//	Display Video.	
				if (isAudioAttached){
					alert(document.getElementById("deleteAudio").getAttribute("val"));
					resetImgFile();
				}else{
					addVideo (obj, gal_local, "0" , null,null);
					if (document.getElementById("userAction").value=="showSlide"){
						submitForm("update","1");
					}else {
						submitForm('add',"1");
					}
				}
			}else {
				alert(document.getElementById("imgNotSupported").getAttribute("val"));
				resetImgFile();
				//document.getElementById("AudioFile").disabled = true;
				//document.getElementById("deleteAud").disabled = true;
			}
		}
	}
	
	function isImage(filePath){
		var fileName = filePath.substring (eval (filePath.lastIndexOf("\\")+1) );
		var extension = fileName.substring (eval (fileName.lastIndexOf(".")+1) );
		for (index=0; index<imageExt.length; index++){
			if( extension.toLowerCase() == imageExt[index].toLowerCase() ){
				return true;
			}
		}
		return false;
	}
	
	function isVideo(filePath) {
		var fileName = filePath.substring (eval (filePath.lastIndexOf("\\")+1) );
		var extension = fileName.substring (eval (fileName.lastIndexOf(".")+1) );
		for (index=0; index<videoExt.length; index++){
			if( extension.toLowerCase() == videoExt[index].toLowerCase() ){
				return true;
			}
		}
		return false;
	}
	
	function updateAud(obj) {
		//	Update the audio path text field visible to the user
		if (obj.value != "") {
			if (isAudio(obj.value)) {
				if (isVideoAttached){
					alert(document.getElementById("deleteVideo").getAttribute("val"));
					resetAudFile();
					//adPresent = true;
				}else{
					addAudio (obj , gal_local , "0" , null, null);
					adPresent = true;
					if (document.getElementById("userAction").value=="showSlide"){
						submitForm("update","1");
					}else {
						submitForm('add',"1");
					}
				}
			}else{
				alert (document.getElementById("audNotSupported").getAttribute("val"));
				resetAudFile();
				//document.getElementById("ImageFile").disabled = true;
				//document.getElementById("deleteImg").disabled = true;
				//adPresent = true;
			}
		}
	}
	
	function isAudio(filePath) {
		var fileName = filePath.substring (eval (filePath.lastIndexOf("\\")+1) );
		var extension = fileName.substring (eval (fileName.lastIndexOf(".")+1) );
		for (index=0; index<audioExt.length; index++){
			if( extension.toLowerCase() == audioExt[index].toLowerCase() ){
				return true;
			}
		}
		return false;
	}
	
	function displayImage(obj){
		//	Remove if any image exist in the same id
		if(obj){
			if (document.getElementById("slideImg")!=null) {
				if (is_explorer == false){
					document.getElementById("imageContent").innerHTML = "";
				}else {
					document.getElementById("slideImg").removeNode(true);
				}
			}
			//	Adjust the image size to the preview window size

			if (document.getElementById("tmpImage").height > displayScreenHeight && document.getElementById("tmpImage").width > displayScreenWidth ) {
				document.getElementById("imageContent").innerHTML="<img src='" + obj.src + "' id='slideImg' border=0 style='width:"+displayScreenWidth+"px;MARGIN: 0px;height:"+displayScreenHeight+"px' />";
			}else if (document.getElementById("tmpImage").height > displayScreenHeight && document.getElementById("tmpImage").width < displayScreenWidth) {
				var width = document.getElementById("tmpImage").width;
				document.getElementById("imageContent").innerHTML="<img src='" + obj.src + "' id='slideImg' style='width:"+ width +"px;height:"+displayScreenHeight+"px' border=0/>";
			}else if (document.getElementById("tmpImage").height < displayScreenHeight && document.getElementById("tmpImage").width > displayScreenWidth) {
				var height = document.getElementById("tmpImage").height;
				document.getElementById("imageContent").innerHTML="<img src='" + obj.src + "' id='slideImg' style='height:"+ height +"px;MARGIN: 0px;width:"+displayScreenWidth+"px' border=0 />";
			}else {
				var height = document.getElementById("tmpImage").height;
				var width = document.getElementById("tmpImage").width;
				document.getElementById("imageContent").innerHTML="<img src='" + obj.src + "' id='slideImg' style='height:" + height +"px;width:" + width + "px' border=0 />";
			}
		}
		isImageAttached = true;
		isVideoAttached = false;
		
		document.getElementById("videoIcon").style.display="none";
		document.getElementById("imageIcon").style.display="inline";
	}


	function addImage (obj, gal, msgId, url, fileName){
		//	To display image in the preview area
		if (!obj){
			if(isVideoAttached){
				if(is_explorer == false){
					document.getElementById("videoContent").innerHTML = "";
				}else{
					if(document.getElementById("realPlayer")!=null){
						document.getElementById("realPlayer").removeNode(true);
					}
					if(document.getElementById("mediaPlayer")!=null){
						document.getElementById("mediaPlayer").removeNode(true);
					}
				}
			}
			document.getElementById("tmp").innerHTML="<img src='" + url + "' style='position:absolute;left:0px;top:0px;visibility:hidden;' onload='displayImage(this)' id='tmpImage' />";
		}else{
			displayImage(null);
		}
		document.getElementById("videoContent").style.display = "none";
		document.getElementById("imageContent").style.display = "inline";
		document.getElementById("ifImg").value="true";
		document.getElementById("imgGallery").value = gal;
		document.getElementById("imgMessageID").value= msgId;
		if (obj!=null){
			if (document.getElementById("userAction").value=="showSlide"){
				submitForm("update","1");
			}else {
				submitForm('add',"1");
			}
		}
	}
	
	function addAudio (obj, gal, msgId, url, fileName) {
		//	To add audio clip file to the thumbnail area
		var path = "";
		var extension = "";
		if (obj){
			path = obj.value;
			var fileName = path.substring (eval (obj.value.lastIndexOf("\\")+1) );
			extension = fileName.substring (eval (fileName.lastIndexOf(".")+1) );
			isLocal = true;
		}else if (gal == gal_public){
			path = url;
			extension = path.substring (eval (path.lastIndexOf(".")+1) );
			isLocal = true;
		}else {
			path = url;
			extension = fileName.substring (eval (fileName.lastIndexOf(".")+1) );
			isLocal = false;
		}
		removeAudVid();
		if (isMediaPlayerSupport(extension) && isMediaPlayerExist) {

			//	Embed media player for playing the video file
			var embedMediaPString;
			document.getElementById("audioTag").setAttribute("path",path);
			document.getElementById("audioTag").setAttribute("ext",extension);
			document.getElementById("player").value = MEDIA_PLAYER;
		}else if (isRealPlayerSupport(extension) && isRealPlayerExist) {

			if(obj){
				path = path.replace(/\\/gi,"/");
				path = "file:///" + path;
			}
			document.getElementById("audioTag").setAttribute("path",path);
			document.getElementById("audioTag").setAttribute("ext",extension);
			document.getElementById("player").value = REAL_PLAYER;
		}else{
			alert(document.getElementById("cantPlayAudio").getAttribute("val"));
		}
		isAudioAttached = true;
		if(isVideoAttached==true){
			document.getElementById("imgMessageID").value="-1";
			document.getElementById("imgGallery").value=gal_none;
			isVideoAttached = false;
		}
		document.getElementById("audGallery").value = gal;
		document.getElementById("audMessageID").value= msgId;
		document.getElementById("audioIcon").style.display="inline";
		document.getElementById("videoIcon").style.display="none";
	}

	function removeAudVid(){
		if (is_explorer == false){
			document.getElementById("audioContent").innerHTML = "";
			document.getElementById("videoContent").innerHTML = "";
		}
		if (document.getElementById("mediaPlayer")!=null) {
			document.getElementById("mediaPlayer").removeNode(true);
		}
		if (document.getElementById("realPlayer")!=null) {
			document.getElementById("realPlayer").removeNode(true);
		}
		document.getElementById("audioTag").setAttribute("path","");
		document.getElementById("videoTag").setAttribute("path","");
	}
	
	function addVideo (obj, gal, msgId, url, fileName) {
		//	To add video clip file to the preview area

		var path = "";
		var extension = "";
		var source = 1;
		if (obj){
			path = obj.value;
			source = 0;
			var fileName = path.substring (eval (obj.value.lastIndexOf("\\")+1) );
			extension = fileName.substring (eval (fileName.lastIndexOf(".")+1) );
			isLocal = true;
		}else if (gal == gal_public){
			path = url;
			extension = path.substring (eval (path.lastIndexOf(".")+1) );
			isLocal = true;
		}else{
			path = url;
			extension = fileName.substring (eval (fileName.lastIndexOf(".")+1) );
			isLocal = false;
		}

		removeAudVid();
		if (is_explorer == false){
			document.getElementById("imageContent").innerHTML = "";
		}else {
			if(document.getElementById("slideImg")!=null){
				document.getElementById("slideImg").removeNode(true);
			}
		}
		document.getElementById("videoContent").style.display = "inline";
		document.getElementById("imageContent").style.display = "none";
		if (isMediaPlayerSupport(extension) && isMediaPlayerExist) {
			document.getElementById("videoTag").setAttribute("path",path);
			document.getElementById("videoTag").setAttribute("ext",extension);
			document.getElementById("player").value = MEDIA_PLAYER;
			document.getElementById("ifImg").value="false";

		}else if (isRealPlayerSupport(extension) && isRealPlayerExist) {

			if(obj){
				path = path.replace(/\\/gi,"/");
				path = "file:///" + path;
			}
			document.getElementById("videoTag").setAttribute("path",path);
			document.getElementById("videoTag").setAttribute("ext",extension);
			document.getElementById("ifImg").value="false";
			document.getElementById("player").value = REAL_PLAYER;
			//alert(document.getElementById("videoContent").innerHTML);

		}else{
			alert(document.getElementById("cantPlayVideo").getAttribute("val"));
		}
		isVideoAttached = true;
		isImageAttached = false;
		document.getElementById("imgGallery").value = gal;
		document.getElementById("imgMessageID").value= msgId;
		if (isAudioAttached){
			isAudioAttached = false;
			document.getElementById("audMessageID").value="-1";
			document.getElementById("audGallery").value = gal_none;
		}
		document.getElementById("AudioFile").disabled = true;
		document.getElementById("deleteAud").disabled = true;
		document.getElementById("imageIcon").style.display="none";
		document.getElementById("videoIcon").style.display="inline";
		document.getElementById("audioIcon").style.display="none";
	}
	
	function isMediaPlayerSupport(extension) {
		for (index=0; index<mediaExt.length; index++){
			if( extension.toLowerCase() == mediaExt[index].toLowerCase() ){
				return true;
			}
		}
		return false;
	}
	
	function isRealPlayerSupport(extension) {
		for (index=0; index<realExt.length; index++){
			if( extension.toLowerCase() == realExt[index].toLowerCase() ){
				return true;
			}
		}
		return false;
	}
	
	function addText(obj) {
		document.getElementById("TextContent").value = obj.value;
	}

	function showPane(obj,ty){

		var pos = findPosition (obj);
		var left = pos[0];
		var top = pos[1];
		document.getElementById("colorPane").style.left = eval(left);
		document.getElementById("colorPane").style.top = eval(top+21);
		if(document.getElementById("colorPane").style.visibility == "visible" && type == ty){
			document.getElementById("colorPane").style.visibility = "hidden";
		}else if(document.getElementById("colorPane").style.visibility == "hidden"){
			document.getElementById("colorPane").style.visibility = "visible";
		}
		type = ty;
	}

	function resetColors(){
		document.getElementById("mediaContent").bgColor = "white";
		document.getElementById("TextContent").style.backgroundColor = "white";
		document.getElementById("textItem").style.backgroundColor = "white"
		document.getElementById("TextContent").style.color = "black";
		document.getElementById("backC").value = "white";
		document.getElementById("foreC").value = "black";
	}

	function fetchColor(obj,color){
		if (type==0){
			document.getElementById("mediaContent").bgColor = obj.getAttribute("bgcolor");
			document.getElementById("TextContent").style.backgroundColor = obj.getAttribute("bgcolor");
			document.getElementById("textItem").style.backgroundColor = obj.getAttribute("bgcolor");
			document.getElementById("colorPane").style.visibility = "hidden";
			document.getElementById("backC").value = color;
		}else{
			document.getElementById("TextContent").style.color = obj.getAttribute("bgcolor");
			document.getElementById("colorPane").style.visibility = "hidden";
			document.getElementById("foreC").value = color;
		}
	}
//-->
