/***********************************************************************************************************
Domain : www.medcoretech.com
Name   : pageClock()
Param  : None
Purpose: Display live date and time on each page within the site
Created: 10/13/2006
***********************************************************************************************************/
function pageClock()
{
	var oHolder = document.getElementById("spnDateTime");
	var sDteTme = new String("Loading Date/Time..");		
	var aDay    = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	var aMonth  = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");						
	var aDayTle = new Array("", "st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "st");
	var now		= new Date();
	var hours	= now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	var year	= (now.getYear() < 1000) ? (now.getYear() + 1900) : now.getYear();

	sDteTme = aDay[now.getDay()] + ', ' + aMonth[now.getMonth()] + ' ' + now.getDate() + '<sup>' + aDayTle[now.getDate()] + '</sup> ' + year;
	sDteTme += " " + ((hours > 12) ? hours - 12 : hours);
	sDteTme += ((minutes < 10) ? ":0" : ":") + minutes;
	//sDteTme += ((seconds < 10) ? ":0" : ":") + seconds;
	sDteTme += (hours >= 12) ? " PM" : " AM";			
	
	oHolder.innerHTML = sDteTme;		
}

var maxsteps   = 30; // number of steps to take to change from start color to endcolor
var stepdelay  = 40; // time in miliseconds of a single step
var startcolor = new Array(255,255,255); // start color (red, green, blue)
var endcolor   = new Array(100,99,99); // end color (red, green, blue)

//MT News
var newsContent=new Array();
begintag='';
newsContent[0] = "January 2006 - MedCore's Vscript<sup>&reg;</sup> version 2 now available.";
newsContent[1] = "The new Vscript<sup>&reg;</sup> v2 application showcases the .NET engine at its finest.<br><br>With fully integrated Medical Transcription Platform, Physician Interface, and full featured administrative interface allows hospitals or MTSOs full reporting and oversight into the interworkings of their business 24x7.";
newsContent[2] = "President & CEO, stated:<br><br>\"The new version of our superior application will make any organization focused on transcription and document management as a core component will be amazed at what features and capabilites are at their fingertips with our application.\"";
newsContent[3] = "January 2004 - Vscript<sup>&reg;</sup> is proven in the transcription market!!";
newsContent[4] = "Surgical Notes, a successful transcription organization with over 7000 physicians encompassing over 150 surgery centers are seeing their business increase and their labor cost reduced as a direct result of MedCore's Vscript<sup>&reg;</sup> software."
newsContent[5] = "2003 - The Vscript<sup>&reg;</sup> engine is on the move.";		
newsContent[6] = "MedCore Technologies Inc. finishes Vscript<sup>&reg;</sup>, a state-of-the-art transcription management system.<br><br>\"This system is not only going to increase efficiencies of the transcription service organization but aide in helping the entire industry.\""
closetag='';

//MT Comments
var commentContent=new Array();
begintag='';		
//commentContent[0] = "<i>\"The best transcription application service provider in the industry!\"</i> - Anonymous CTO <a href='http://www.mdnetwork.com' target='_newWin'>MDnetwork, Inc.</a>";
commentContent[0] = "<i>\"The platform that I work on is vscript and I also love it. Very user friendly.</i>\" - Anonymous MT, <a href='http://www.mtstars.com' target='_newWin'>www.mtstars.com</a>";
commentContent[1] = "<i>\"I absolutely LOVE it. This is the BEST ever. I can produce 2000 lines a day. Tech support is great. I can't say enough good things...\"</i> - Anonymous MT, <a href='http://www.mtstars.com' target='_newWin'>www.mtstars.com</a>";
closetag='';

var fwidth        = '100%'; //set scroller width
var fheight       = '100%'; //set scroller height
var fadelinks     = 1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.		
var faderdelay    = 0;
var indexNews     = 0;
var indexComments = 0;
var fadecounter   = null;

function changecontent()
{	
	//News Scroller
	if ((indexNews >= newsContent.length) && (document.getElementById("spnMTNews") != null))
		indexNews=0
		if ((document.getElementById) && (document.getElementById("spnMTNews") != null))
		{
			document.getElementById("spnMTNews").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
			document.getElementById("spnMTNews").innerHTML=begintag+newsContent[indexNews]+closetag
			if (fadelinks)
				linkcolorchange(1);
				colorfade(1, 15);
		}
	else if ((document.all && !document.getElementById) && (document.getElementById("spnMTNews") != null))
		document.all.spnMTNews.innerHTML=begintag+newsContent[indexNews]+closetag;
	indexNews++
	
	//Comments Scroller
	if (indexComments>=commentContent.length && (document.getElementById("spnMTComment") != null))
		indexComments=0
		if ((document.getElementById) && (document.getElementById("spnMTComment") != null))
		{
			document.getElementById("spnMTComment").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
			document.getElementById("spnMTComment").innerHTML=begintag+commentContent[indexComments]+closetag
			if (fadelinks)
				linkcolorchange(1);
				colorfade(1, 15);
		}
	else if ((document.all&&!document.getElementById) && (document.getElementById("spnMTComment") != null))
		document.all.spnMTComment.innerHTML=begintag+commentContent[indexComments]+closetag;
	indexComments++			
}
function linkcolorchange(step)
{
	var obj=document.getElementById("spnMTNews").getElementsByTagName("A");
	var obj=document.getElementById("spnMTComment").getElementsByTagName("A");
	if (obj.length>0)
	{
		//for (i=0;i<obj.length;i++)
			//obj[i].style.color=getstepcolor(step);
	}
}		
function colorfade(step) 
{
	if(step<=maxsteps) 
	{	
		document.getElementById("spnMTNews").style.color=getstepcolor(step);
		document.getElementById("spnMTComment").style.color=getstepcolor(step);
		if (fadelinks)
			linkcolorchange(step);
		step++;
		fadecounter=setTimeout("colorfade("+step+")",stepdelay);
	}else{
		clearTimeout(fadecounter);
		document.getElementById("spnMTNews").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
		document.getElementById("spnMTComment").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";	
	}   
}
function getstepcolor(step) 
{
	var diff
	var newcolor=new Array(3);
	for(var i=0;i<3;i++) 
	{
		diff = (startcolor[i]-endcolor[i]);
		if(diff > 0) 
		{
			newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
		}else{
			newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
		}
	}
	return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}			
function initPage()
{
	pageClock();							//Call it one to show time and date
	changecontent();						//Call it one to show news messages
	setInterval('pageClock()',60000);		//Time and Date - timer to refresh every minute
	setInterval('changecontent()', 12000);	//News Scroller and Comments scroller
	
	if(document.getElementById("txtUsername") != null)
	{
		document.getElementById("txtUsername").focus();
	}
}

function FormatDate(DateToFormat,FormatAs)
{
	if(DateToFormat==""){return"";}
	if(!FormatAs){FormatAs="mm/dd/yyyy";}

	var strReturnDate;
	FormatAs = FormatAs.toLowerCase();
	DateToFormat = DateToFormat.toLowerCase();
	var arrDate
	var arrMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var strMONTH;
	var Separator;

	while(DateToFormat.indexOf("st")>-1){DateToFormat = DateToFormat.replace("st","");}
	while(DateToFormat.indexOf("nd")>-1){DateToFormat = DateToFormat.replace("nd","");}
	while(DateToFormat.indexOf("rd")>-1){DateToFormat = DateToFormat.replace("rd","");}
	while(DateToFormat.indexOf("th")>-1){DateToFormat = DateToFormat.replace("th","");}
	if(DateToFormat.indexOf(".")>-1){Separator = ".";}
	if(DateToFormat.indexOf("-")>-1){Separator = "-";}
	if(DateToFormat.indexOf("/")>-1){Separator = "/";}
	if(DateToFormat.indexOf(" ")>-1){Separator = " ";}
	arrDate = DateToFormat.split(Separator);
	DateToFormat = "";
	for(var iSD = 0;iSD < arrDate.length;iSD++)
	{
		if(arrDate[iSD]!=""){DateToFormat += arrDate[iSD] + Separator;}
	}
	DateToFormat = DateToFormat.substring(0,DateToFormat.length-1);
	arrDate = DateToFormat.split(Separator);

	if(arrDate.length < 3){return ""}

	var DAY = arrDate[1];
	var MONTH = arrDate[0];
	var YEAR = arrDate[2];

	if(parseFloat(arrDate[1]) > 12)
	{
		DAY = arrDate[1];
		MONTH = arrDate[0];
	}
	if(parseFloat(DAY) && DAY.toString().length==4)
	{
		YEAR = arrDate[0];
		DAY = arrDate[2];
		MONTH = arrDate[1];
	}
	for(var iSD = 0;iSD < arrMonths.length;iSD++){
		var ShortMonth = arrMonths[iSD].substring(0,3).toLowerCase();
		var MonthPosition = DateToFormat.indexOf(ShortMonth);
		if(MonthPosition > -1)
		{
			MONTH = iSD + 1;
			if(MonthPosition == 0)
			{
				DAY = arrDate[1];
				YEAR = arrDate[2];
			}
			break;
		}
	}
	var strTemp = YEAR.toString();
	if(strTemp.length==2)
	{

		if(parseFloat(YEAR)>40)
		{
			YEAR = "19" + YEAR;
		}else{
			YEAR = "20" + YEAR;
		}
	}
	if(parseInt(MONTH)< 10 && MONTH.toString().length < 2){MONTH = "0" + MONTH;}
	if(parseInt(DAY)< 10 && DAY.toString().length < 2){DAY = "0" + DAY;}
	
	switch (FormatAs)
	{
		case "dd/mm/yyyy":
			return DAY + "/" + MONTH + "/" + YEAR;
			break;
		case "mm/dd/yyyy":
			return MONTH + "/" + DAY + "/" + YEAR;
			break;
		case "dd/mmm/yyyy":
			return DAY + " " + arrMonths[MONTH -1].substring(0,3) + " " + YEAR;
			break;
		case "mmm/dd/yyyy":
			return arrMonths[MONTH -1].substring(0,3) + " " + DAY + " " + YEAR;
			break;
		case "dd/mmmm/yyyy":
			return DAY + " " + arrMonths[MONTH -1] + " " + YEAR;	
			break;
		case "mmmm/dd/yyyy":
			return arrMonths[MONTH -1] + " " + DAY + " " + YEAR;
			break;
	}
}

/******************************************************************
Name  : checkContactUs()
Param : Form Object
Pages : contactus.aspx
Reason: 
		Validate that the required fields have data in them prior
		to submiting the page
/*****************************************************************/
function checkContactUs(oForm)
{
	var bQues1  = false;
	var bQues2  = false;
	var bReturn = true;
	var oName   = oForm.txtName;
	var oPhone  = oForm.txtPhone;
	var oEmail  = oForm.txtEmail;
	var oPVPro  = oForm.chkVSPro;
	var oPVPre  = oForm.chkVSPremier;
	var oPVEnt  = oForm.chkVSEnterprise;
	var oPVDem  = oForm.chkVSDemo;
	var sError1 = "<table width=100% height=5 cellpadding=2 cellspacing=1 border=0 bgcolor=#cccccc><tr height=1><td bgcolor=#cccccc></td></tr><tr bgcolor=#ffffe0><td><span style='color:red;'>";
	var sError2 = "<table width=100% height=5 cellpadding=2 cellspacing=1 border=0 bgcolor=#cccccc><tr height=1><td bgcolor=#cccccc></td></tr><tr bgcolor=#ffffe0><td><span style='color:red;'>";
	
	oName.value = jsTrim(oName.value)
	if(oName.value.length == 0)
	{	
		sError1 += "&nbsp;- Please give us your name<br>";
		bQues1  = true; 
		bReturn = false;
	}

	oPhone.value = jsTrim(oPhone.value)
	if(oPhone.value.length == 0)
	{
		sError1 += "&nbsp;- Please give us your phone number<br>";
		bQues1  = true;
		bReturn = false;
	}
	
	oEmail.value = jsTrim(oEmail.value)
	if(oEmail.value.length == 0)
	{
		sError1 += "&nbsp;- Please give us your email address<br>";
		bQues1  = true;
		bReturn = false;
	}		
	sError1 += "</span></td></tr></table>";
	
	if(bQues1 && !bReturn){document.getElementById("spnContatUsQuestion_one").innerHTML = sError1;}	
	if(!bQues1 && bReturn){document.getElementById("spnContatUsQuestion_one").innerHTML = "1) Tell Us About You!"}

	//Make sure that at least one value is checked for Product selection
	if(!oPVPro.checked && !oPVPre.checked && !oPVEnt.checked && !oPVDem.checked)
	{
		sError2 += "&nbsp;- Please select at least one product<br>";
		bQues2  = true;
		bReturn = false;
	}		
	sError2 += "</span></td></tr></table>";

	if(bQues2 && !bReturn){document.getElementById("spnContatUsQuestion_two").innerHTML = sError2;}	
	if(!bQues2 && bReturn){document.getElementById("spnContatUsQuestion_two").innerHTML = "2) What Product are you Interested In?"}
	
	return bReturn;
}

/******************************************************************
Name  : jsTrim()
Param : String value to Trim
Pages : All*
Reason: 
		Trim null and empty spaces from passed string
/*****************************************************************/
function jsTrim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
} 
 