
/* ----- globalJs.js ----- */
// http://www.savingtrust.dk/portal_javascripts/globalJs.js?original=1
function link_open(linkval){var lStr=linkval.split('!');if(lStr[1]=='1'){window.open(lStr[0])}
else if(lStr[1]=='0'){link_arr=lStr[0].split('');if(link_arr[0]=="/")
link_loc=lStr[0];else if(link_arr[0]!="/")
link_loc="/"+lStr[0];window.location=lStr[2]+link_loc}
else{return false}}
function getQueryVariable(variable){var query=window.location.search.substring(1);var vars=query.split("&");for(var i=0;i<vars.length;i++){var pair=vars[i].split("=");var pairs=vars[i];if(pair[0]==variable){return pairs}}}
function readUrl(){var openr=window.opener;var UrlEle=openr.document.getElementById("sendToFrndURL");document.getElementById("urlToSend").value=UrlEle.value;lnkEle=document.getElementById("sendLnk");lnkEle.innerHTML=UrlEle.value}
function validateSendto(){var send_to_name=document.getElementById("send_to_name");var send_to_address=document.getElementById("send_to_address");var send_from_name=document.getElementById("send_from_name");var send_from_address=document.getElementById("send_from_address");var emailFilter=/^.+@.+\..{2,3}$/;var illegalChars=/[\(\)\<\>\,\;\:\\\/\"\[\]]/;if((send_to_name.value=="")||(send_to_name.value=="Angiv modtagers navn")){alert("Please insert reciever's name.");send_to_name.focus();return false}
if(!(emailFilter.test(send_to_address.value))){alert("Plsease insert reciever's valid e-mail address.");send_to_address.focus();return false}
else{if(send_to_address.value.match(illegalChars)){alert("The reciever email address contains illegal characters.");send_to_address.focus();return false}}
if((send_from_name.value=="")||(send_from_name.value=="Indtast dit fornavn og efternavn")){alert("Please insert sender's name.");send_from_name.focus();return false}
if(!(emailFilter.test(send_from_address.value))){alert("Please insert sender's valid e-mail address.");send_from_address.focus();return false}
else{if(send_from_address.value.match(illegalChars)){alert("The sender email address contains illegal characters.");send_from_address.focus();return false}}
return true}
function resize_iframe(){if(document.body.clientHeight){height=document.body.clientHeight;alert(height)}
document.getElementById("windowZ").style.height=parseInt(height-document.getElementById("windowZ").offsetTop-8)+"px"}
function calcHeight(){var the_height=document.getElementById('windowZ').contentWindow.
document.body.scrollHeight;document.getElementById('windowZ').height=the_height}
function validateSubsctribeNL(frm){count=0;for(i=0;i<frm.elements.length;i++){if(frm.elements[i].type=="checkbox")
if(frm.elements[i].checked==true)
count++}
var email_address=document.getElementById("email");var emailFilter=/^.+@.+\..{2,3}$/;var illegalChars=/[\(\)\<\>\,\;\:\\\/\"\[\]]/;if(count==0){alert("Please select atleast one category.");email_address.focus();return false}
if(email_address.value=="Indtast e-mailadresse"){alert("Please enter your e-mail address.");email_address.focus();return false}
if(!(emailFilter.test(email_address.value))){alert("Invalid e-mail address.");email_address.focus();return false}
else{if(email_address.value.match(illegalChars)){alert("Your e-mail address contains illegal characters.");email_address.focus();return false}}}
function validateNewsArchive(frm){count=0;for(i=0;i<frm.elements.length;i++){if(frm.elements[i].type=="checkbox")
if(frm.elements[i].checked==true)
count++}
if(count==0){alert("Please select atleast one category.");return false}}
function validateJoinForm(frm){var user_fullname=frm.fullname.value;var user_email=frm.email.value;var user_password=frm.password.value;var user_password_confirm=frm.password_confirm.value;var emailFilter=/^.+@.+\..{2,3}$/;var illegalChars=/[\(\)\<\>\,\;\:\\\/\"\[\]]/;if(user_fullname==''){alert("Enter full name.");frm.fullname.focus();return false}
if(user_email==''){alert("Enter e-mail address.");frm.email.focus();return false}
if(user_password==''){alert("Enter password.");frm.password.focus();return false}
if(user_password.length<5){alert("password should be minimum of 5 characters long.");frm.password.focus();return false}
if(user_password_confirm==''){alert("Confirm password.");frm.password_confirm.focus();return false}
if(user_password!=user_password_confirm){alert("confirm password does not match with the password.");frm.password_confirm.focus();return false}
if(!(emailFilter.test(user_email))){alert("Invalid e-mail address.");frm.email.focus();return false}
else{if(user_email.match(illegalChars)){alert("invalid character in e-mail address.");frm.email.focus();return false}}}
function validateLoginForm(frm){var username=frm.__ac_name.value;var password=frm.__ac_password.value;if(username==''){alert("Enter user name.");frm.__ac_name.focus();return false}
if(password==''){alert("Enter password.");frm.__ac_password.focus();return false}}
function validateForgetPasswordForm(frm){var emailFilter=/^.+@.+\..{2,3}$/;var illegalChars=/[\(\)\<\>\,\;\:\\\/\"\[\]]/;var username=frm.userid.value;if(username==''){alert("Enter your E-mail address.");frm.userid.focus();return false}
if(!(emailFilter.test(username))){alert("Invalid e-mail address.");frm.userid.focus();return false}
else{if(username.match(illegalChars)){alert("invalid character in e-mail address.");frm.userid.focus();return false}}}
function validateEditSettingForm(frm){var user_fullname=frm.fullname.value;var user_email=frm.email.value;var emailFilter=/^.+@.+\..{2,3}$/;var illegalChars=/[\(\)\<\>\,\;\:\\\/\"\[\]]/;if(user_fullname==''){alert("Enter your full name.");frm.fullname.focus();return false}
if(user_email==''){alert("Enter your e-mail address.");frm.email.focus();return false}
if(!(emailFilter.test(user_email))){alert("Invalid e-mail address.");frm.email.focus();return false}
else{if(user_email.match(illegalChars)){alert("invalid character in e-mail address.");frm.email.focus();return false}}}
function validateChangePasswordForm(frm){var curr_pwd=frm.current.value;var new_password=frm.password.value;var confirm_password=frm.password_confirm.value;if(curr_pwd==''){alert("Enter current password.");frm.current.focus();return false}
if(new_password==''){alert("Enter new password.");frm.password.focus();return false}
if(new_password.length<5){alert("password should be minimum of 5 characters long.");frm.password.focus();return false}
if(confirm_password==''){alert("confirm new password.");frm.password_confirm.focus();return false}
if(new_password!=confirm_password){alert("confirm password does not match with the password.");frm.password_confirm.focus();return false}}
function validateSetNewPasswordForm(frm){var uid=frm.userid.value;var new_password=frm.password.value;var confirm_password=frm.password2.value;if(uid==''){alert("Enter username/E-mail.");frm.userid.focus();return false}
if(new_password==''){alert("Enter new password.");frm.password.focus();return false}
if(new_password.length<5){alert("password should be minimum of 5 characters long.");frm.password.focus();return false}
if(confirm_password==''){alert("confirm new password.");frm.password2.focus();return false}
if(new_password!=confirm_password){alert("confirm password does not match with the password.");frm.password2.focus();return false}}
function setUsernameAsEmail(form,email){form.username.value=email}
function validateCommentThisPageForm(frm){var user_fullname=frm.name.value;var user_email=frm.email.value;var user_comment1=frm.comment.value;user_comment=user_comment1.replace(/^[\s]+/g,"")
var emailFilter=/^.+@.+\..{2,3}$/;var illegalChars=/[\(\)\<\>\,\;\:\\\/\"\[\]]/;if(user_fullname==''){alert("Insert Name.");frm.name.focus();return false}
if(user_email==''){alert("Insert e-mail.");frm.email.focus();return false}
if(!(emailFilter.test(user_email))){alert("Invalid e-mail.");frm.email.focus();return false}
else{if(user_email.match(illegalChars)){alert("Invalid character in e-mail address.");frm.email.focus();return false}}
if(user_comment==''){alert("Insert Comments.");frm.comment.focus();return false}}
function toggleLayer(whichLayer){var elem,vis;if(document.getElementById)
elem=document.getElementById(whichLayer);else if(document.all)
elem=document.all[whichLayer];else if(document.layers)
elem=document.layers[whichLayer];vis=elem.style;if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
vis.display=(elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';vis.display=(vis.display==''||vis.display=='block')?'none':'block'}
function CloseWindow(){window.close()}
function pagePopUp(){openUrl='sendMailPageToEditors';newwin=window.open(openUrl,'sendMailPageToEditors','left=50,top=50,width=850,height=500,menu=no,scrollbars=yes,resizable=yes,status=no');newwin.focus()}
function checkIfComment(){var frm=document.sendMailPageForm;var comnt=document.getElementById('text_comment').value;var sel_editor=document.getElementById('sel_editor').value
var sel_editor_flag=0;for(i=0;i<frm.sel_editor.length;i++){if(frm.sel_editor[i].type=="checkbox"){if(frm.sel_editor[i].checked){sel_editor_flag=1}}}
if(sel_editor_flag==0){alert('Please select Atleast one Editor !!');return false}
if(!comnt){alert('Please add comment');return false}
else{frm.action="sendMailPageToEditorsScript";frm.submit();return true}}

