/*
 * Copyright 2006 Servelots Infotech Pvt. Ltd.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License. You may
 * obtain a copy of the License at:
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
/* Function adds <br> tag to the long notes. */
 
function breakString(notes)
{

        var str="";
        var i=0;
        var j=20;
        while (i < notes.length)
        {
                if (notes.length < j)
                        //str = str + notes.substring(i, notes.length) + "<br>";
                        str = str + notes.substring(i, notes.length) + "&#013;";
                else
                        str = str + notes.substring(i, j) + "&#013;";
 
                i = i + 20;
                j = j + 20;
 
        }
        return str;
}                                                                       
	
/* To check the Browser  */
	
function checkbrowser(choice)
 {
	if(parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion)<5)
	{
	
		if(navigator.appName == "Microsoft Internet Explorer")
			{
				checkIE(choice)
			}
		else	
		if(navigator.appName == "Netscape")
			{
			checkNN(choice)
			}
	}	
 }


function reopen()
{

if(parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion)<5)
        {
 
                if(navigator.appName == "Microsoft Internet Explorer")
                        {
                                checkIE()
                        }
                else
                if(navigator.appName == "Netscape")
                        {
                        checkNN()
                        }
        }
 }      



	
/* This Is for IE  Browser to check theb mapping functionality */
//This is commented for not displaying "My Notes"	
function checkIE(choice)
	{
	/*	if (choice == 1) //cliked 1st map from left
		{
			document.all.img1.visibility="hidden";
			document.all.dwn.visibility="hidden";
		}
	else
		if (choice == 2) //2nd map from left
		{
			if (document.all.img1.src.indexOf("/p/images/geo4.gif") >=0)
			{
			document.all.img1.src = "../p/images/geo6.gif";
			document.all.dwn.style.visibility = "visible";
			document.all.main.style.visibility="visible";

			document.all.main11.style.visibility="hidden";

			}
			else		
			if (document.img1.src.indexOf("/p/images/geo6.gif") >=0)
			{
				document.all.img1.src="../p/images/geo4.gif";
				document.all.dwn.style.visibility ="hidden";
				document.all.main.style.visibility="visible";

				document.all.main11.style.visibility="visible";			

			}		
		}
		else
			{	
				document.all.img1.src = "../p/images/geo4.gif";
				document.all.dwn.style.visibility="hidden";
				document.all.main.style.visibility="visible";

				document.all.main11.style.visibility="visible";
				
			 }*/
}


	
	 
function cllsIE(cho)  //close-ad-square  (hide)
	{
		hideAdsq()
	}
	
	
	
/*  this for net scape */

//This is commented for not displaying "My Notes"	
	
function checkNN(choice)
	{
	/*	if (choice == 1) //if choice is 1, close
		{
			document.main1.down1.visibility = "hidden";
			document.main1.img1.visibility="hidden";

			document.main11.visibility="hidden";

		}
	else
		if (choice == 2) //if choice is 2, up-arrow and drop-down
		{
			if (document.img1.src.indexOf("/p/images/geo4.gif") >=0)
			{
			document.img1.src = "../p/images/geo6.gif";
			document.down1.visibility = "visible";
			document.main1.visibility="visible";

			document.main11.visibility="hidden";		
		
			}
			else // else down-arrow and pull-up
			if (document.img1.src.indexOf("/p/images/geo6.gif") >=0)
			{
				document.img1.src="../p/images/geo4.gif";
				document.down1.visibility = "hidden";
				document.main1.visibility="visible";

				document.main11.visibility="visible";

			}
		}
	else //place down-arrow, pull-up
		{
			document.img1.src = "../p/images/geo4.gif";
			document.down1.visibility = "hidden";
			document.main1.visibility="visible";

			document.main11.visibility="visible";
		}*/
	} 

	
function cllsNN(cho)
	{
	hideAdsq()
	}
	
// To close the AD-SQUARE //

function ClsAdsq(cho)
{
hideAdsq()
}


// click on mynotes to get adsquare //
		
function clsAd()
{
	if(parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion)<5)
	{
		if(navigator.appName == "Microsoft Internet Explorer")
			{
				document.all.main.style.visibility="visible";
				document.all.dwn.style.visibility="hidden";

				document.all.main11.style.visibility="hidden";
			}
		else	
		if(navigator.appName == "Netscape")
			{
			document.main1.visibility="visible";
			document.main11.visibility="visible";
			document.down1.visibility="hidden";
			}
	}		
}

function popup()
	{
	 var text=window.open("textarea.htm","text", "width=300, height=200, scrollbars=0,,status=0,menubar=0");  
	}

	
ispopup=1 ; //ispopup is true or 1 by default. if adsquare is enabled then false or 0.


function AdorPop()  //click on my notes to see the  AD-SQUARE  or pop depending on browser version
{
	if(ispopup==1)
		{
		popup() 
		}
	else
		{
		clsAd() 
		}
}		
	

// TO Hide ADSQUARE ONLOAD //

		
function hideAdsq()
{
	if(parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion)<5)
	{
		if(navigator.appName == "Netscape")
		{
			document.main1.visibility="hidden";
			document.down1.visibility="hidden";

			document.main11.visibility="hidden";
	
		}
	else
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			document.all.main.style.visibility="hidden";
			document.all.dwn.style.visibility = "hidden";	

			document.all.main11.style.visibility="hidden";
		}
	}		
}





//This is commented for not displaying "My Notes"	
function adsq(notetext,lef,topp,position,mess){
/*
if(parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion)<5 )
{
var pict="";
if(position=="open")
	{ pict="../p/images/geo6.gif";}
else if(position=="close")
	{ pict="../p/images/geo4.gif"; }

		if(navigator.appName == "Netscape")
		{

			ispopup=0 ; //no popup, use adsqaure instead		
	
document.write('<MAP name="mapp"><AREA shape="rect" alt="help-file-to-explain-adsq" coords="3,2,17,14"><AREA shape="rect" alt="Up-Down" coords="20,2,34,14" href="javascript:checkbrowser(2);"><AREA shape="rect" alt="Close"  coords="38,2,52,14" href="javascript:ClsAdsq();"></MAP><layer name="main1" left="80%" top="0" width="160" bgcolor="Yellow" align="right" valign="top"><table width="100%" border="1" cellspacing="0" cellpadding="0"><tr><td align="center"><font face="Arial" size="2">'+mess+'</font></td><td align="right" valign="top" bgcolor="Silver"><img src='+pict+' width="54" height="17" alt="" border="0" name="img1" usemap="#mapp" ></td></TR></table></layer><layer name="main11" width="160" left="80%" top="20" bgcolor="Yellow" align="right" valign="top"><table width="100%" border="1" cellspacing="0" cellpadding="0"><tr align="center"><td align="center"><font face="Arial" size="2">'+breakString(notetext)+'</font></td></tr></table></layer>');

var toppp = topp+20;

if(position=="open")
{ 
document.write('<layer name="down1" width=138 left="80%" top="20" bgcolor="Yellow" align="right" valign="top" id="down1"><table width="100%" border="1" cellspacing="0" cellpadding="0"><form name="noteform"><tr><td align="center"><textarea cols="14" rows="6" name="notes" wrap="virtual" onChange=parent.document.personaform.mynotes.value=document.noteform.notes.value;parent.document.personaform.notes.value=document.noteform.notes.value;>'+notetext+'</textarea></td></tr><tr><td align="center"><font face="arial" size="1"></font></td></tr></form></table></layer>');
}
else
{
document.write('<layer name="down1" width=138  left="80%" top="20" bgcolor="Yellow" align="right" valign="top" id="down1"><table width="100%" border="1" cellspacing="0" cellpadding="0"><form name="noteform" action="PersonaProfile?req=111"><tr><td align="center"><textarea cols="14" rows="6" name="notes" wrap="virtual">'+notetext+'</textarea></td></tr><tr><td align="center"><font face="arial" size="1"><input type="button" name="update" value="Update" onClick=parent.document.personaform.mynotes.value=document.noteform.notes.value;parent.document.personaform.notes.value=document.noteform.notes.value;parent.document.personaform.submit();></font></td></tr></form></table></layer>');  
}


		}
 		else
		if(navigator.appName == "Microsoft Internet Explorer")
		
		{
			ispopup=0 ; //no popup, use adsqaure instead		
		
document.write('<MAP name="mapp"><AREA shape="rect" alt="help-file-to-explain-adsq" coords="3,2,17,14"><AREA shape="rect" alt="Up-Down" coords="20,2,34,14" href="javascript:checkbrowser(2);"><AREA shape="rect" alt="Close"  coords="38,2,52,14" href="javascript:ClsAdsq();"></MAP><div align="right" id="main" style="visibility:hidden; position: absolute; top:'+topp+'px;  left:'+lef+'px;"><table align="right" border="1" cellspacing="0" cellpadding="0" bgcolor="#C0C0C0" width="150"><TR ><td align="center" bgcolor="Yellow"><font face="Arial" size="2">'+mess+'</font></td><td align="center"><img src='+pict+' width="54" height="17" alt="" border="0" name="img1" usemap="#mapp" ></td></TR></table></div><div align="right" id="main11" style="visibility:visible; position: absolute; top:'+(topp+17)+'px;  left:'+lef+'px;"><table align="right" border="1" cellspacing="0" cellpadding="0" bgcolor="#C0C0C0" width="150"><tr bgcolor="#FFFF00"><td colspan="2" align="center"><font face="Arial,Arial" size="2">'+breakString(notetext)+'</font></td></tr></table></div>');

var toppp = topp+20;

if(position=="open")
{ 
document.write('<div id="dwn" align="right" style="visibility:hidden; position: absolute; top:'+toppp+'px; left:'+lef+'px;;"><table border="1" align="right" cellspacing="0" cellpadding="0" bgcolor="yellow" width="150"><form name="noteform"><tr><td align="center"><textarea cols="15" rows="6" name="notes" style="text-decoration: none;" wrap="virtual" onChange=document.personaform.mynotes.value=document.noteform.notes.value;document.personaform.notes.value=document.noteform.notes.value;>'+notetext+'</textarea></td></tr><tr><td align="center"><font face="arial" size="1">&nbsp;</font></td></tr></form></table></div>');
}
else
{
document.write('<div id="dwn" align="right" style="visibility:hidden; position: absolute; top:'+toppp+'px; left:'+lef+'px;;"><table border="1" align="right" cellspacing="0" cellpadding="0" bgcolor="yellow" width="150"><form name="noteform"><tr><td align="center"><textarea cols="15" rows="6" name="notes" style="text-decoration: none;" wrap="virtual">'+notetext+'</textarea></td></tr><tr><td align="center"><font face="arial" size="1"><input type="button" name="update" value="Update" onClick=document.personaform.notes.value=document.noteform.notes.value;document.personaform.mynotes.value=document.noteform.notes.value;document.personaform.submit();></font></td></tr></form></table></div>');
}

		}//outer else
   
 }//outer if 
*/ 
}//function end

function notesLink(di_p,urlid,from)
{
        document.write('<table width=100% border=0 cellspacing=0 cellpadding=2 align=right><tr><td align=right>');

	if(from=="posting"){
	document.write('<a href=javascript:onClick=window.open(\"Notes?di_p='+di_p+'&urlid='+urlid+'\",\"notebook\",\"toolbar=0,location=0,status=0,directories=0,menubar=0,resizable=1,scrollbars=1,width=320,height=300,left=100,top=70\").focus();><font face="arial" size="2">my notes</font></a>');
	}else if(from=="persona"){
	document.write('<a href=javascript:onClick=window.open(\"Notes?pid='+di_p+'&urlid='+urlid+'\",\"notebook\",\"toolbar=0,location=0,status=0,directories=0,menubar=0,resizable=1,scrollbars=1,width=320,height=300,left=100,top=70\").focus();><font face="arial" size="2">my notes</font></a>');
	}



        document.write('</td></tr>');
        document.write('</table>'); 
}

function visi()
  {
	if(parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion)<5)
        {
                if(navigator.appName == "Netscape")
                {
                        document.main1.visibility="visible";
                        document.down1.visibility="visible";

			document.main11.visibility="hidden";
                }
        else
                if(navigator.appName == "Microsoft Internet Explorer")
                {
                        document.all.main.style.visibility="visible";
                        document.all.dwn.style.visibility = "visible";

			document.all.main11.style.visibility="hidden";
                }
        }  

  }


function visi_minimize()
  {
/*
        if(parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion)<5)
        {
                if(navigator.appName == "Netscape")
                {
			document.main1.visibility="visible";
                        document.down1.visibility="hidden";
                }
        else
                if(navigator.appName == "Microsoft Internet Explorer")
                {
                        document.all.main.style.visibility="visible";
                        document.all.dwn.style.visibility = "hidden";
                }
        }
 */
  }
 
function check_security_id(security_id)
{
secure=prompt("Please enter your security id"," ");
}

/*
byte[] inputBytes=secure.Packages.java.lang.getBytes("UTF8");
MessageDigest md5=Packages.java.security.MessageDigest.getInstance("MD5");
md5.Packages.java.security.MessageDigest.update(inputBytes);
byte[] digest=md.Packages.java.security.MessageDigest.digest();
Packages.sun.misc.BASE64Encoder encoder=new BASE64Encoder();
Packages.java.lang.String base64=encoder.Packages.sun.misc.BASE64Encoder.encode(digest);


	
while(base64 != security_id)
	{
	alert("Enter the security id again");
	}

	
	}

*/



