//////////////////////////////////// Ieteikt

http://www.linkedin.com/shareArticle?mini=true&url={articleUrl}&title={articleTitle}&summary={articleSummary}&source={articleSource}


function LinkedInSay(title, url, source){
 window.open(
  'http://www.linkedin.com/shareArticle?mini=true&url=' + encodeURIComponent( url ) +
  '&title=' + encodeURIComponent( title ) +
  '&summary=&source=' + encodeURIComponent( source ),
  '',
  'location=1,status=1,scrollbars=0,resizable=0,width=550,height=450'
 );
 return false;
}

function TwitterSay(text, url, via){
 window.open(
  'http://twitter.com/share?text=' + encodeURIComponent( text ) +
  '&url=' + encodeURIComponent( url ) +
  ( via ? '&via=' + encodeURIComponent( via ) : '' ),
  '',
  'location=1,status=1,scrollbars=0,resizable=0,width=550,height=450'
 );
 return false;
}

function FacebookSay(t, u){
 window.open(
  'http://www.facebook.com/sharer.php?t=' + encodeURIComponent( t ) +
  '&u=' + encodeURIComponent( u ),
  '',
  'location=1,status=1,scrollbars=0,resizable=0,width=550,height=450'
 );
 return false;
}

function DraugiemSay(title, url, titlePrefix){
 window.open(
  'http://www.draugiem.lv/say/ext/add.php?title=' + encodeURIComponent( title ) +
  '&link=' + encodeURIComponent( url ) +
  ( titlePrefix ? '&titlePrefix=' + encodeURIComponent( titlePrefix ) : '' ),
  '',
  'location=1,status=1,scrollbars=0,resizable=0,width=550,height=450'
 );
 return false;
}

function DeliciousSay(title, url){
 window.open(
  'http://www.delicious.com/save?v=5&noui&jump=close&title=' + encodeURIComponent( title ) +
  '&url=' + encodeURIComponent( url ),'',
  'location=1,status=1,scrollbars=0,resizable=0,width=550,height=450'
 );
 return false;
}

function re(cels) {
	document.location.href=cels;	
}

function chkRegFrm(){
	if(isEmpty(document.getElementById("fname"), "Please enter family name!")){	
		if(isEmpty(document.getElementById("lname"), "Please enter last name!")){
			if(isEmpty(document.getElementById("jobtitle"), "Please enter job title!")){
				if(getRadioSelVal(document.getElementById("jobother"), 'job', "Please specify job description!")){	
					if(isEmpty(document.getElementById("comp"), "Please enter company!")){
						if(isEmpty(document.getElementById("reg"), "Please enter company reg / VAT nr.!")){
							if(isEmpty(document.getElementById("adr"), "Please enter office adress!")){
								if(isEmpty(document.getElementById("zip"), "Please enter post code!")){
									if(isEmpty(document.getElementById("country"), "Please enter country!")){
										if(isEmpty(document.getElementById("tel"), "Please enter telephone!")){
											if(isEmpty(document.getElementById("email"), "Please enter email!")){
												if(isEmail(document.getElementById("email"), "Please enter VALID email!")){
													if(getRadioSelVal(document.getElementById("actother"), 'act', "Please specify type of activity!")){	
														if(getRadioSelVal(document.getElementById("cactother"), 'cact', "Please specify country of activity!")){
															if(isChecked(document.getElementById("toc"), "You have not agreed on terms & conditions!")){
																if(isEmpty(document.getElementById("code"), "You have to enter security code before submitting the form!")){
																	document.getElementById('regfrm').submit();
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}							
						}
					}
				}
			}
		}
	}
	return false;	
}

function chkOther(name, nr){
	if(nr == 1) show(name);
	else hide(name);
}


//////////////////////////////////// Focus

function setfocus(focuswhat){
	focusobject = document.getElementById(focuswhat);
	focusobject.focus();
}

//////////////////////////////////// Show / Hide

function showhide(hidewhat){
	hideobject = document.getElementById(hidewhat);
	hideobject.style.display = hideobject.style.display == "none" ? "" : "none";
}

function show(showwhat){
	showobject = document.getElementById(showwhat);
	showobject.style.display = "";
}

function hide(hidewhat){
	hideobject = document.getElementById(hidewhat);
	hideobject.style.display = "none";
}

////////////////////////////////////////////////////// FORM VALIDATION GLOBAL

function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function isEmptyInner(elem, helperMsg){
	if(elem.innerHTML.length == 0){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function isEmail(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isEqual(elem, elem2, helperMsg){
	if(elem.value != elem2.value){
		alert(helperMsg);
		elem.value = '';
		elem2.value = '';
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function isLength(elem, len, helperMsg){
	if(elem.value.length < len){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function isChecked(elem, helperMsg){
	if(elem.checked == false){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function getRadioSelVal(elem, name, helperMsg){
	var rb = document.getElementsByName(name);
	var val = '';
	for (i=0; i < rb.length; i++) {
		if (rb[i].checked) val = rb[i].value;
	}
	if(val == 'other'){
		if(elem.value.length == 0){
			alert(helperMsg);
			elem.focus();
			return false;
		} else return true;
	} else return true;
}


