//Check/Uncheck all checkboxes	
function checkAll(field) {
		var len = 0;
		for (i = 0; i < field.length; i++) {
			if (field[i].checked == false) {
				field[i].checked = true ;				
			} else {
				field[i].checked = false ;
			}
			len++;
		}
			
		if (len == 0)
			if (field.checked == false)
				field.checked = true;
			else
				field.checked = false;
	}
	
// Pop up mwp in handset image
function showIt(outFile, base) {

	var url = base + outFile;
	preview_window = open("","displayWindow","width=300,height=500,left=10,top=10");
	preview_window.document.open();	
	preview_window.document.write('	<head>');
	preview_window.document.write('	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />');
	preview_window.document.write('<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">');
	preview_window.document.write('<META HTTP-EQUIV="EXPIRES" CONTENT="01 Jan 1970 00:00:00 GMT">');
	preview_window.document.write('<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">');
	preview_window.document.write('	</head>'); 		
	preview_window.document.write('	<body style="margin: 5px;">');
	preview_window.document.write('		<table width="250" border="0" cellspacing="0" cellpadding="0" align="center">');
	preview_window.document.write('			<tr><td colspan="3"><img src="images/handset_large_top.gif" width="250" height="92" alt="" /></td></tr>');
	preview_window.document.write('			<tr>');
	preview_window.document.write('				<td><img src="images/handset_large_left.gif" width="32" height="242" alt="" /></td>');
	preview_window.document.write('				<td valign="top">');
	preview_window.document.write('					<iframe src=' + url + ' id="handset-screen" width="185" height="242" frameborder="0" align="top" border="0"></iframe>');
	preview_window.document.write('				</td>				');
	preview_window.document.write('				<td><img src="images/handset_large_right.gif" width="33" height="242" alt="" /></td>');
	preview_window.document.write('			</tr>');
	preview_window.document.write('			<tr><td colspan="3"><img src="images/handset_large_bottom.gif" width="250" height="66" alt="" /></td></tr>');
	preview_window.document.write('		</table>');
	preview_window.document.write('	</body>	');	

	preview_window.document.write('<p><div align="center"><a href="javascript:self.close()">Close</a> this window.</div></p>');		
	preview_window.document.close();
}
	
// Toggle and position the display of definition box
function showDefinition(e, strTerm) {
	if ($("#definition-holder").size() == 0) $("#wrapper").append('<div id="definition-holder" style="display: none;"><div id="definition"></div></div>');
	$("#definition-holder").show();
	$("#definition").empty();
	$("#definition").append("<h1>" + strTerm + "</h1><p>" + arrDefinitions[strTerm] + "</p>");
	if (!e) var e = window.onmouseover;
	if (e.pageX || e.pageY) {
		$("#definition-holder").css("left", (e.pageX + 10) + "px");
		$("#definition-holder").css("top", (e.pageY + 10) + "px");
	} else if (e.clientX || e.clientY) {
		$("#definition-holder").css("left", (e.clientX + document.documentElement.scrollLeft + 10) + "px");
		$("#definition-holder").css("top", (e.clientY + document.documentElement.scrollTop + 10) + "px");
	}
}
function hideDefinition() {
	$("#definition-holder").hide();
}
function initDefinitions() {
	$(".definition-link").bind("mouseout", function() { hideDefinition(); });
	$(".definition-link").bind("click", function() { return false; });
}

$(document).ready(function() { initDefinitions(); });

var arrDefinitions = new Array();
arrDefinitions["Campaign Name:"] = "Please give this campaign a name. Hint: Adding the date to the name can be helpful.";
arrDefinitions["Start Date (mm/dd/yyyy):"] = "If your campaign has multiple deliveries then you can choose the start and end date. If it is to be sent just once then enter today’s date in both the Start and End date.";
arrDefinitions["End Date (mm/dd/yyyy):"] = "If your campaign has multiple deliveries then you can choose the begin and end date. If it is to be sent just once then enter today’s date in both the Start and End date.";
arrDefinitions["Now (Send the message right away):"] = "Check this box if you want to send this message immediately upon completion.";
arrDefinitions["Frequency (Number of times per day):"] = "Schedule the number of times you want the message delivered daily. Minimum value must be 1";
arrDefinitions["Offer Text Message:"] = "This is the actual text message that is sent out. There is a maximum limit of 160 characters."; 
arrDefinitions["Offer Code:"] = "If your campaign has an associated offer, you can specify the offer code here. You can alternatively generate one using the Generate button"; 
arrDefinitions["Upload Mailing List:"] = "This is a file of the mobile numbers of all customers that you want to deliver the message to. This file needs to be a text file (.txt). The system will not accept any other formats. The number must be in the international format i.e starting with the country code. e.g in the US, a sample number would be 16505559999."; 
