/*
+--------------------------------------------------------------------+
|                                                                    |
|  Website     : F1 Study Website                                    |
|  File Name   : content.js                                          |
|  Type        : JavaScript Script File                              |
|  Description : Content Generating JavaScript Functions             |
|  Author      : Srinivasan A. Paul Joseph                           |
|  Created On  : January 15, 2005                                    |
|  Updated On  : June 8, 2005                                        |
|  Version     : 1.0.2                                               |
|                                                                    |
|  Copyright © 2004, MiPS Web Services Pvt. Ltd.                     |
|  All Rights Reserved.                                              |
|                                                                    |
|  Version History                                                   |
|  ^^^^^^^^^^^^^^^                                                   |
|  1.0.0 - Initial Write up of the Functions.                        |
|  1.0.1 - Modifications of Existing Functions and Variables         |
|  1.0.2 - SelectCopy() function.                                    |
|                                                                    |
+--------------------------------------------------------------------+
*/

/*********************************************************************
 * Description : Global Variables                                    *
 *********************************************************************/
var tipCnt=0,tipX=0,tipY=0;
var dirCLoc = "";

/*********************************************************************
 * Description : Date Variable Arrays                                *
 *********************************************************************/
var arrMons = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var arrDays = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

/*********************************************************************
 * Description : Pre-Loadable Image Variables                        *
 *********************************************************************/
var imgSpace,imgArwNext,imgHelp;

/*********************************************************************
 * Function    : LoadImages()                                        *
 * Description : Pre-Loads Necessary Images for Faster Viewing       *
 *********************************************************************/
function LoadImages()
{
	//Load the Images into Memory
	imgSpace=new Image();
	imgArwNext=new Image();
	imgHelp=new Image();
	//Set Source Paths for Images
	imgSpace.src = dirCLoc+"images/space.gif";
	imgArwNext.src = dirCLoc+"images/arwNext.gif";
	imgHelp.src = dirCLoc+"images/icoHelp.gif";
}
 					   
/*********************************************************************
 * Function    : LoadURL(urlPath,[urlTarget])                        *
 * Description : Loads a given URL into the Browser                  *
 * Arguments   : urlPath   - Path of the URL to be Loaded            *
 *               urlTarget - Optional. Specifies Target of URL       *
 *********************************************************************/
function LoadURL(urlPath)
{
	if(arguments.length==1)
		document.location=urlPath;
	else
	{
		window.open(urlPath,arguments[1]);
	}
}

/*********************************************************************
 * Function    : PlaceMe(lngL,lngT,lngW,lngH)                        *
 * Description : Places a Form on the given Co-ordinates             *
 * Arguments   : lngL - Left (X1) Co-ordinate Value                  *
 *               lngT - Top (Y1) Co-ordinate Value                   *
 *               lngW - Width (X2) Co-ordinate Value                 *
 *               lngH - Height (Y2) Co-ordinate Value                *
 *********************************************************************/
function PlaceMe(lngL,lngT,lngW,lngH)
{
	window.moveTo(lngL,lngT);
	window.resizeTo(lngW,lngH);
	window.focus();
}

/*********************************************************************
 * Function    : WriteFooter(pgURL)                                  *
 * Description : Writes the Page Footer                              *
 * Arguments   : pgURL - URL of the Page that is being Forwarded     *
 *********************************************************************/
function WriteFooter(pgURL)
{
	var curDT=new Date();
	if(pgURL!="")
		document.write("<img src='"+dirCLoc+"images/emailed.gif' border=0 align=middle> <a href='"+dirCLoc+"asp/fwd.asp?pgURL="+pgURL+"' class=medLnk>Forward this Page to a Friend</a><br>");
	document.write("<hr width=80% size=1><div align=center style={font-family:Tahoma;font-size:8pt;}>");
	document.write("<a href='"+dirCLoc+"html/terms_of_use.html' target='_blank' class=smlLnk>Terms of Use</a> | <a href='"+dirCLoc+"html/privacy_policy.html' target='_blank' class=smlLnk>Privacy Policy</a> | <a href='"+dirCLoc+"site_map.asp' class=smlLnk>Site Map</a><img src='"+dirCLoc+"images/space.gif' height=5><BR>");
	document.write("Copyright &copy; 2004-"+curDT.getFullYear()+" <b>F1study Inc</b>. All Rights Reserved.<Br>Designed and Maintained By:<B> MiPS Web Services Pvt.Ltd.</b><img src='"+dirCLoc+"images/space.gif' height=5><br>");
	document.write("</div>");
}

/*********************************************************************
 * Function    : WriteTips(tipText,[tipPos])                         *
 * Description : Writes the Tip of a Field in Form                   *
 * Arguments   : tipText = The text that should be shown in Tip      *
 *               tipPos  = (Optional) Provides the position of Tip   *
 *               Refer ShowTips() for tipPos descriptions            *
 *********************************************************************/
function WriteTips(tipText)
{
	document.write(" <img id='imgTips"+tipCnt+"' src='"+dirCLoc+"images/icoHelp.gif' border=0 width=16 height=16 align=top onMouseMove='ShowTips("+tipCnt+",event);' onMouseOut='HideTips("+tipCnt+");' style={cursor:help;}>");
	document.write("<div id='divTips"+tipCnt+"' value='"+((arguments.length>1)?arguments[1]:0)+"' class=txtTips style={position:absolute;left:0px;top:0px;width:200px;display:none;z-index:20;}>"+tipText+"</div>");
	tipCnt++;
}

/*********************************************************************
 * Function    : ShowTips(tipID,myEvt)                               *
 * Description : Shows the Tip of a Field in Form                    *
 * Arguments   : tipID = Unique ID for showing the related Tip       *
 *               myEvt = The Event Object that fired this Event      *
 *********************************************************************/
function ShowTips(tipID,myEvt)
{
	var curX,curY,objDiv,objImg;
	
	objDiv=document.getElementById("divTips"+tipID)
	curX=document.body.scrollLeft+myEvt.clientX;
	curY=document.body.scrollTop+myEvt.clientY;
	switch(parseInt(objDiv.value))
	{
		case 0: // Bottom-Right of the Cursor
			curY+=18;
			break;
		case 1: // Bottom-Center of the Cursor
			curY+=18;
			curX-=90;
			break;
		case 2:	// Bottom-Left of the Cursor
			curX-=200;
			curY+=18;
			break;
		case 3: // Middle-Left of the Cursor
			curY-=2;
			curX-=210;
			break;
		case 4: // Middle-Left-Center of the Cursor
			curY-=20;
			curX-=210;
			break;
		case 5: // Top-Left of the Cursor
			curY-=60;
			curX-=200;
			break;
		case 6: // Top-Center of the Cursor
			curY-=60;
			curX-=90;
			break;
		case 7: // Top-Right of the Cursor
			curY-=60;
			curX+=20;
			break;
		case 8: // Middle-Right-Center of the Cursor
			curY-=20;
			curX+=20;
			break;
		case 9: // Middle-Right of the Cursor
			curY-=2;
			curX+=20;
			break;
		default:
			curY+=18;
	}
	objDiv.style.left=curX+"px";
	objDiv.style.top=curY+"px";
	if(objDiv.style.display=="none")
		objDiv.style.display="";
}

/*********************************************************************
 * Function    : HideTips(tipID)                                     *
 * Description : Hides the Tip of a Field in Form                    *
 * Arguments   : tipID = Unique ID for hiding the related Tip        *
 *********************************************************************/
function HideTips(tipID)
{
	var objDiv;
	
	objDiv=document.getElementById("divTips"+tipID)
	if(objDiv.style.display!="none")
		objDiv.style.display="none";
}

/*********************************************************************
 * Function    : SelectCopy(objText)                                 *
 * Description : Selects a Text in a Textbox and Copies it to Clip   *
 * Arguments   : objText = Textbox Object to do the functionality    *
 *********************************************************************/
function SelectCopy(objText)
{
	objText.select();
	if(window.clipboardData && clipboardData.setData)
		clipboardData.setData("text",objText.value);
	else
		window.alert("Copying to Clipboard Automatically option will work on Internet Explorer Only!\n\nPlease copy the Text Manually by pressing Ctrl+C as it is already selected!");
}
