/* Insiders: News Subscription EN
 * User: said.ibarbachane@nasdaqomx.com
 * Updated: 2010-04-16 11:38:40.07
 */
var randomNumber = parseInt(Math.random()*10000);

try{
	var newParam1 = "";
	if( newParam1.match(/configuration.getParameter/ig) != null || newParam1 == "" ){
		newParam1 = null;
	}
	
	var newParam2 = "";
	if( newParam2.match(/configuration.getParameter/ig) != null || newParam2 == "" ){
		newParam2 = null;
	}
}catch( Error ){
		
}

try{
	var removeBalticsLang = "${configuration.getParameter('removeBalticsLang')}";
	
	if (removeBalticsLang == 'false'){
		var newLang1 = "Lithuanian";
		if( newLang1.match(/configuration.getParameter/ig) != null || newLang1 == "" ){
			newLang1 = null;
		}
		
		var newLang2 = "Latvian";
		if( newLang2.match(/configuration.getParameter/ig) != null || newLang2 == "" ){
			newLang2 = null;
		}
		
		var newLang3 = "Estonian";
		if( newLang3.match(/configuration.getParameter/ig) != null || newLang3 == "" ){
			newLang3 = null;
		}
		
		var newLang4 = "Russian";
		if( newLang4.match(/configuration.getParameter/ig) != null || newLang4 == "" ){
			newLang4 = null;
		}
	}
}catch( Error ){
		
}

try{
	var newParam3 = "";
	if( newParam3.match(/configuration.getParameter/ig) != null || newParam3 == "" ){
		newParam3 = null;
	}
}catch( Error ){
		
}


function checkFieldsAndSubmit() {
	var firstName = "First name*";
	var firstNameRequire = -1;
	var lastName = "Last name*";
	var lastNameRequire = -1;
	var title = "";
	var titleRequire = -1;
	var phone = "Phone";
	var phoneRequire = -1;
	var company = "Company";
	var countryRequire = -1;
	var country = "";
	var countryRequire = -1;
	var profile = "Profile";
	var profileRequire = -1;
	var infoTypeRequire = 0;
        var filter = /^.+@.+\..{2,4}$/;
	
	var required = /\*/;
	if( firstName != "" )
		firstNameRequire = firstName.search(required);
		
	if( lastName != "" )
		lastNameRequire = lastName.search(required);
	
	if( title != "" )
		titleRequire = title.search(required);
		
	if( phone != "" )
		phoneRequire = phone.search(required);
	
	if( company != "" )
		companyRequire = company.search(required);
		
	if( country != "" )
		countryRequire = country.search(required);
		
	if( profile != "" )
		profileRequire = profile.search(required);
	
	if(document.getElementsByName('infoTypes').length > 0){
		var x = document.getElementsByName('infoTypes').length;
		do{
			document.getElementsByName('infoTypes')[x-1].name = 'infoTypes_'+randomNumber;
			x--;
		}while(x > 0)
	}
	
	if( document.getElementsByName('infoTypes_'+randomNumber).length != 0 ){
		for (i = 0; i < document.getElementsByName('infoTypes_'+randomNumber).length; i++){
			if (document.getElementsByName('infoTypes_'+randomNumber)[i].checked){
				infoTypeRequire = -1;
			}
		}
	}
	
	if( document.getElementsByName('selectedEmail').selectedEmail.value == '' || !filter.test(document.getElementsByName('selectedEmail').selectedEmail.value) ) {
		alert( 'A valid e-mail address must be entered.' );
	}
	else if( infoTypeRequire != -1 ) {
		alert( 'Please choose a message type to recieve.' );
	}
		else if ( document.addSubscriptionForm.selectedFirstName.value == '' && firstNameRequire != -1 ) {
		alert( 'Please enter your first name.' );
	}
			else if ( document.getElementsByName('selectedLastName').value == '' && lastNameRequire != -1 ) {
		alert( 'Please enter your last name.' );
	}
				else if ( document.addSubscriptionForm.selectedPhoneNumber.value == '' && phoneRequire != -1 ) {
		alert( 'Please enter your phone number.' );
	}
			else if ( document.addSubscriptionForm.selectedCompany.value == '' && companyRequire != -1 ) {
		alert( 'Please enter your company name.' );
	}
				else if ( document.addSubscriptionForm.selectedProfile.value == -1 && profileRequire != -1 ) {
		alert( 'Please select your profile.' );
	}
		else {
		
		var x = document.getElementsByName('infoTypes_'+randomNumber).length;
		do{
			document.getElementsByName('infoTypes_'+randomNumber)[x-1].name = 'infoTypes';
			x--;
		}while(x > 0)
		
		if(document.getElementsByName('preferredLanguage_'+randomNumber).length == 1){
			document.getElementsByName('preferredLanguage_'+randomNumber)[0].name = 'preferredLanguage';
		}
		
				
									if( document.addSubscriptionForm.selectedProfile.value == -1 ){
					document.getElementById("profile_id").innerHTML = "";
				}
									document.getElementById('addSubscriptionForm').submit();
			}
}

document.write('<style type="text/css">');
document.write('#subscribeContainer { width:300px; border:1px Solid #f0efef; margin-left:0px; font-family:arial; font-size:11px; }');
document.write('#subscribeContainer .moduleTitle { height:28px; background-color: transparent; }');
document.write('#subscribeContainer .moduleTitle h2 { margin:0;	padding:4px; font-weight:bold; color:#fff; }');
document.write('#subscribeContainer .moduleHeader {	height:26px; background-color: transparent;	border-bottom:1px Solid #dedddd; }');
document.write('#subscribeContainer .moduleHeader h3 { margin:0; padding:5px; color:#222222; font-weight:normal; }');
document.write('#subscribeContainer .labelDiv {	padding:5px; padding-left: 10px; padding-right: 10px; background-color: transparent; }');
document.write('#subscribeContainer .labelDiv label { width: 100px;	float: left; color: #333333; }');
document.write('#subscribeContainer .infoTypes_table td { padding: 3px 5px; padding: 5px; font-size: 11px;color: #333333; }');
document.write('#subscribeContainer .labelDivCheck { padding:5px; background-color: transparent; }');
document.write('#subscribeContainer input { background-color: #fff; }');
document.write('#subscribeContainer #sendButton { margin-right: 8px; margin-left: 8px; margin-bottom: 5px; }');
document.write('#subscribeContainer .noBorder { border: none; }');
document.write('#subscribeContainer .formItem {	margin-top:4px;	font-size:11px; }');
document.write('#subscribeContainer .btnContainer {	text-align:right; margin-top:5px; }');
document.write('</style>');
document.write('<form id="addSubscriptionForm" name="addSubscriptionForm" target=NasdaqOmxPop onSubmit="customOnsubmit(); return true;" action="https://cns.omxgroup.com/cdsPublic/addDynamicSubscription.action?" method="GET" enctype="application/x-ww-form-urlencoded">');
document.write('<table id="subscribeContainer" style="border-collapse: collapse;font-family: Tahoma; font-size: 11px; width: 400px; border:1px solid #f0efef;">');
document.write('		<tr><td class="moduleTitle" style="background-color:#FFFFFF;display:none">');
document.write('				<h2 style="font-family: Tahoma Bold;font-size:13px; color: #000000"></h2>');
document.write('		</td></tr>');
document.write('		<tr><td class="moduleHeader" style="background-color:#FFFFFF;border-bottom:none">');
document.write('			<h3 style="font-family: Tahoma;font-size:11px; color: #333333;">FILL IN YOUR CONTACT INFORMATION</h3>');
document.write('		</td></tr>');
document.write('		<tr><td style="line-height: 5px; background-color:#FFFFFF;">&nbsp;</td></tr>');
document.write('		<tr><td class="labelDiv" style="background-color:#FFFFFF;padding-left: 10px;padding-right: 10px;">');
document.write('			<label class="required">First name*</label>');
document.write('			<input type="text" name="selectedFirstName" style="width:378px;color: #333333;" value="" id="addSubscription_selectedFirstName" style="width:200px;" class="formItem"/>');
document.write('		</td></tr>');
document.write('		<tr><td class="labelDiv" style="background-color:#FFFFFF;padding-left: 10px;padding-right: 10px;">');
document.write('			<label class="required">Last name*</label>');
document.write('			<input type="text" name="selectedLastName" style="width:378px;color: #333333;" value="" id="addSubscription_selectedLastName" style="width:200px;" class="formItem"/>');
document.write('		</td></tr>');
document.write('		<tr><td class="labelDiv" style="background-color:#FFFFFF;padding-left: 10px;padding-right: 10px;">');
document.write('			<label class="required">Phone</label>');
document.write('			<input type="text" name="selectedPhoneNumber" style="width:378px;color: #333333;" value="" id="addSubscription_selectedPhoneNumber" style="width:200px;" class="formItem"/>');
document.write('		</td></tr>');
document.write('		<tr><td class="labelDiv" style="background-color:#FFFFFF;padding-left: 10px;padding-right: 10px;">');
document.write('			<label class="required">Company</label>');
document.write('			<input type="text" name="selectedCompany" style="width:378px;color: #333333;" value="" id="addSubscription_selectedCompany" class="formItem"/>');
document.write('		</td></tr>');
document.write('		<tr><td class="labelDiv" id="profile_id" style="background-color:#FFFFFF;padding-left: 10px;padding-right: 10px;">');
document.write('			<label class="required">Profile</label>');
document.write('			<select name="selectedProfile" size="1" style="width:100%;font-family: Tahoma; font-size: 11px;" id="selectedProfile" style="margin-right:5px;" title="Please select your profile.">');
document.write('				<option value="-1">Select profile</option>');
document.write('				<option value="1">Analyst</option>');
document.write('				<option value="2">Customer</option>');
document.write('				<option value="3">Employee</option>');
document.write('				<option value="4">Investor</option>');
document.write('				<option value="5">Media</option>');
document.write('				<option value="6">Shareholder</option>');
document.write('				<option value="7">Student</option>');
document.write('				<option value="8">Other</option>');
document.write('			</select>');
document.write('		</td></tr>');
document.write('			<tr><td id="languageSelect_'+randomNumber+'" class="labelDiv" style="background-color:#FFFFFF;padding-left: 10px;padding-right: 10px;">');
document.write('				<label class="required lblDiv">Languages:</label>');
document.write('				<select name="preferredLanguage_'+randomNumber+'" style="width:100%;font-family: Tahoma; font-size: 11px;" id="addSubscription_preferredLanguage">');
/* Default language check */
document.write('					<option name="preferredLanguageOption" value="en">English</option>');

if( newLang1 != null ){
	}

if( newLang2 != null ){
	}

if( newLang3 != null ){
	}

if( newLang4 != null ){
	}


/* Not default languages */
document.write('					<option name="preferredLanguageOption" value="fi">Finnish</option>');
if( newLang1 != null ){
			document.write('					<option name="preferredLanguageOption" value="lt">'+newLang1+'</option>');
	}

if( newLang2 != null ){
			document.write('					<option name="preferredLanguageOption" value="lt">'+newLang2+'</option>');
	}

if( newLang3 != null ){
		document.write('					<option name="preferredLanguageOption" value="ee">'+newLang3+'</option>');
	}

if( newLang4 != null ){
		document.write('					<option name="preferredLanguageOption" value="ru">'+newLang4+'</option>');
	}

document.write('				</select>');
document.write('			</td></tr>');
document.write('			<tr><td id="infoTypesLabel_'+randomNumber+'" class="labelDiv" style="background-color:#FFFFFF;padding-left: 10px;padding-right: 10px;">');
document.write('				<label class="required" style="width:100%">Select the message types you wish to receive:*</label>');
document.write('			</td></tr>');
document.write('			<tr><td style="background-color:#FFFFFF;padding-left: 10px;padding-right: 10px;">');
document.write('			<table class="infoTypes_table" name="infoTypes_table" id="infoTypes_table_'+randomNumber+'" style="border-collapse: collapse;">');
document.write('				<tr>');
document.write('					<td>');
document.write('						<input type="checkbox" name="infoTypes_'+randomNumber+'" value="6" id="addSubscription_selectedInfoTypes" class="noBorder"/>');
document.write('					</td>');
document.write('					<td><label class="infoTypes">All Company Announcements</label></td>');
document.write('				</tr>');
document.write('				<tr>');
document.write('					<td>');
document.write('						<input type="checkbox" name="infoTypes_'+randomNumber+'" value="7" id="addSubscription_selectedInfoTypes" class="noBorder"/>');
document.write('					</td>');
document.write('					<td><label class="infoTypes">Company Releases</label></td>');
document.write('				</tr>');
if ( newParam1 != null ){
document.write('				<tr>');
document.write('					<td>');
document.write('						<input type="checkbox" name="infoTypes_'+randomNumber+'" value="15" id="addSubscription_selectedInfoTypes" class="noBorder"/>');
document.write('					</td>');
document.write('					<td><label class="infoTypes" id="newParam1"></label></td>');
document.write('				</tr>');
}
if ( newParam2 != null ){
document.write('				<tr>');
document.write('					<td>');
document.write('						<input type="checkbox" name="infoTypes_'+randomNumber+'" value="16" id="addSubscription_selectedInfoTypes" class="noBorder"/>');
document.write('					</td>');
document.write('					<td><label class="infoTypes" id="newParam2"></label></td>');
document.write('				</tr>');
}
document.write('			</table>');
document.write('			</td></tr>');
document.write('			<tr><td class="labelDiv" style="background-color:#FFFFFF;padding-left: 10px;padding-right: 10px;">');
document.write('				<label class="required">E-mail*</label>');
document.write('				<input type="text" name="selectedEmail" id="selectedEmail" value="" id="addSubscription_selectedEmail" style="width:378px;color: #333333;" class="formItem"/>');
document.write('			</td></tr>');
document.write('			<tr><td class="btnContainer" style="background-color:#FFFFFF;">');
document.write('				<button id="sendButton" style="float: right; margin-right: 5px; margin-bottom: 5px;background-color: #333333;color: #FFFFFF;font-family: Tahoma; font-size: 11px;" type="button" class="discButton" onClick="javascript: checkFieldsAndSubmit();">SEND</button>');
document.write('			</td></tr>');
if ( newParam3 != null ){
document.write('			<tr>');
document.write('			<td class="labelDiv" style="background-color:#FFFFFF;padding-left: 10px;padding-right: 10px;">');
document.write('				<label id="bottomText"></label>');
document.write('			</td></tr>');
}
document.write('	</table>');
document.write('	<input type="hidden" name="disclosingPartyId" value="852" id="addSubscription_disclosingPartyId"/>');
document.write('</form>');


if( newParam1 != null ){
	document.getElementById("newParam1").innerHTML = newParam1;
}

if( newParam2 != null ){
	document.getElementById("newParam2").innerHTML = newParam2;
}

if( newParam3 != null ){
	document.getElementById("bottomText").innerHTML = newParam3;
}

if( document.getElementsByName('preferredLanguage_'+randomNumber).length == 1 ){
}
if( document.getElementsByName('infoTypes_'+randomNumber).length == 1 ){
	var table = document.getElementById('infoTypes_table_'+randomNumber);
	document.getElementById('addSubscription_selectedInfoTypes').checked = true;
	table.style.visibility='hidden';
	table.style.position='absolute';
	var tableLabel = document.getElementById('infoTypesLabel_'+randomNumber);
	tableLabel.style.visibility='hidden';
	tableLabel.style.position='absolute';
}
