function wipe(component, toWipe, duration) {
var node = document.getElementById(toWipe);
if (node) {
if (component.className.indexOf('wiper-open') != -1) {
dojo.lfx.html.wipeOut(node.id, duration, null, function(){node.style.height='auto';}).play();
component.className = component.className.replace('wiper-open', 'wiper-closed');
} else { 
dojo.lfx.html.wipeIn(node.id, duration, null, function(){node.style.height='auto';}).play();
component.className = component.className.replace('wiper-closed', 'wiper-open');
}
}
}
function calcRemaining(allowed,threshold,textarea,warningSpan,pluralText,singularText) {
if (!warningSpan) return;
var remaining = allowed - textarea.value.length;
if (remaining <= threshold) {
warningSpan.innerHTML = remaining + " " + ((remaining == 1 || remaining == -1) ? singularText : pluralText);
warningSpan.style.display = 'inline';
} else {
warningSpan.style.display = 'none';
}
}
function getWarningSpan(node) {
var warningSpan = node.nextSibling;
while (warningSpan && (warningSpan.nodeType != 1 || !warningSpan.className || warningSpan.className.indexOf('remainingCharacters') < 0)) {
warningSpan = warningSpan.nextSibling;
}
if (!warningSpan && node.parentNode) {
return getWarningSpan(node.parentNode);
}
return warningSpan;
}
function moveImgWipe() {
var source = document.getElementById("moved-img-wipe");
if (source) {
source.parentNode.removeChild(source);
var target = document.getElementById("content-positioned-div");
target.appendChild(source);
target.style.top = (document.getElementsByName("pic")[0].clientHeight + 35 + 165)+"px";
}
}
function addUserIdToField(choice, fieldId) {
var field = document.getElementById(fieldId); 
var userId = choice.options[choice.selectedIndex].value; 
var str = field.value.replace(/^\s+/, '').replace (/\s+$/, '');;
if (str.length > 0 && str.charAt(str.length-1) != ',') {
userId = ', ' + userId;
}
field.value += userId; 
}

function trackLinkClickPageview(evt){
_trackLinkClick(evt, function(link){_gaq.push(['_trackPageview', '/outgoing/'+link])});
}
function trackLinkClickEvent(evt) {
_trackLinkClick(evt, function(link){trackEvent("outgoing", link)})
}
function trackLinkClickDebug(evt) {
_trackLinkClick(evt, function(link){console.debug("tracking: "+link)})
}
function _trackLinkClick(e, tracker) {
var link;
var label;
if (!e) var e = window.event;
if (e.target) link = e.target;
else if (e.srcElement) link = e.srcElement;
if (link.nodeType == 3)  link = link.parentNode;
while (link && link.nodeName != 'A') {
 if (link.className && link.className.indexOf("trackLabel") > -1) {
label = link.innerHTML;
}
link = link.parentNode;
}
if(!link || link.href.indexOf(location.host) > -1 || link.href.indexOf('javascript:') > -1) return
if (link.className && link.className.indexOf("trackLabel") > -1) {
label = link.innerHTML;
}
var toTrack = link.href.replace(/http:\/\//g, "").replace(/\/$/g, "");
if (toTrack.indexOf('/') < 0) {
 toTrack = toTrack + '/'
}
if (label) {
toTrack = toTrack + (toTrack.indexOf('?') > 0 ? '&' : '?') + "trackLabel=" + encodeURIComponent(label);
}
try{
tracker(toTrack);
} catch(err){
if (window.console) window.console.debug("error: " + err)
}
}
function buildCustomPath(path, params) {
if (!params && !path) return;
var cp = !path ? window.location.pathname : path;
var search = window.location.search;
if (search) cp = cp + search;
if (params) cp = cp + (search ? '&' : '?') + params;

return cp;
}
function trackEvent(category, action, label, value) {
_gaq.push(['_trackEvent', category, action, label, value]);
}

function search(query) {
var f = document.forms['searchBox']
if (f) {
if (f.elements['q']) {
f.elements['q'].value = query
} else if (f.elements['query']) {
f.elements['query'].value = query
} else {
f.elements[0].value = query
}
f.submit();
return null;
} else return query
}

var szm_mccookie = "szm_mc";
var szm_prefix='http://mclient2.ivwbox.de/cgi-bin/ivw/CP/';
var szm_prefixssl='https://mclientssl2.ivwbox.de/cgi-bin/ivw/CP/';
function szm_client(szm_site, szm_hcode, szm_isssl) {
if (szm_getcookie() != szm_hcode)
{ szm_getmclient(szm_site,szm_isssl,szm_hcode); szm_setcookie(szm_hcode);
}
}
function szm_clear() {
szm_setcookie("spring.de");
}
function szm_getcookie() {
var split = new Array();
split = document.cookie.split(";");
for(var i=0; i<split.length;i++) {
if(split[i].match(".*"+szm_mccookie+".*")) {
return (split[i].split("="))[1];
}
} return "";
}
function szm_getmclient(szm_site,szm_isssl,szm_hcode) {
var img = new Image();
if(szm_isssl) img.src = szm_prefixssl+szm_site+'/'+szm_hcode;
else img.src = szm_prefix+szm_site+'/'+szm_hcode;
}
function szm_setcookie(code) {
document.cookie = szm_mccookie+"="+code;
}
