// *******************************************************************************
// Filename     : fileadmin/dev/scripts|all.js

// Created      : 16.05.2007 15:49
// Created by   : Clemens Riccabona, Riccabona eSolutions, <clemens@riccabona.biz>

// Last Updated : 21.02.2008 17:09:40
// Updated by   : Clemens Riccabona, Riccabona eSolutions, <clemens@riccabona.biz>

// Version      : 1.5

// Comment      : Some basic settings, including all the CSS stuff and some other functions
// *******************************************************************************


// Very quick, very dirty!
function makeRicSpecialCheatNow() {
  window.document.getElementById('angebot').value = window.cheaterTop;
}

// Variables for slimbox
var pmkslimbox_page='<span style=\'font-size:0.8em;\'>&copy; 2007 by MountainStar</span><br />Bild<strong>';
var pmkslimbox_of='</strong>von<strong>';

//ric onload all
function ric_onload_all(funcCall){
  if(document.body) {
    if(document.body.innerHTML) {
      var ihLength=Number(document.body.innerHTML.length);
      if(window.ihOldLength) { var ihOldLength=Number(window.ihOldLength);}else{var ihOldLength=0; }
      if(ihLength>ihOldLength) {
        window.ihOldLength=ihLength;
        window.setTimeout("ric_onload('"+funcCall+"');",1500);
      } else { eval(funcCall); }
    } else { window.setTimeout("ric_onload('"+funcCall+"');",1500); }
  } else { window.setTimeout("ric_onload('"+funcCall+"');",1500); }
}

// Function for superchallenging password (kb_feusersmd5)
function superchallenge_pass(form) {
  var pass = form.pass.value;
  if (pass) {
    var enc_pass = MD5(pass);
    var str = form.user.value+":"+enc_pass+":"+form.challenge.value;
    form.pass.value = MD5(str);
    return true;
  } else {
    return false;
  }
}

// Typo3 hook for rggoogle
function openPic(url,winName,winParams) {
  var theWindow = window.open(url,winName,winParams);
  if (theWindow) {theWindow.focus();}
}

// Inclusion of X-Browser CSS Files
var cL_IE7CssFileName='/fileadmin/dev/css/ie7.css';
var cL_CssFileName='';
var cL_OperaCssFileName='/fileadmin/dev/css/op.css';
var cL_IECssFileName='/fileadmin/dev/css/ie4-6.css';
var cL_IEMacCssFileName='/fileadmin/dev/css/ie4-6.css';
var cL_GeckoCssFileName='/fileadmin/dev/css/ge.css';
var cL_GeckoMacCssFileName='/fileadmin/dev/css/ge.css';
var cL_SafariCssFileName='/fileadmin/dev/css/ge.css';
var cL_OtherCssFileName='/fileadmin/dev/css/ge.css';

// var def in browserVars; add new ones in there; init setting: false
var browserVars='isIE5up,isIE55up,isIE6,isIE6up,isIE7,isIE7up,isOpr,isOpr7up,isGecko,isSafari,isKhtml,isLinux,isMac'.split(',');for(var i=0;i<browserVars.length;i++){eval('var '+browserVars[i]+'=false;');}
var isDOM=document.getElementById ? true:false;
var isNN4=document.layers ? true:false;
var isIE4=document.all ? true:false;
var OprVersion=''; var GeckoVersion='';
if (isDOM&&isIE4){isIE5up=true; isIE4=false; isDOM=false;} else {isIE5up=false;}
if ((isIE5up)&&(navigator.appVersion.indexOf('MSIE 5.0')==-1)){isIE55up=true;}
if ((isIE55up)&&(navigator.appVersion.indexOf('MSIE 5.5')==-1)){isIE6up=true;}
if ((isIE6up)&&(navigator.appVersion.indexOf('MSIE 6')==-1)){isIE7up=true;}
if (isIE6up&&!isIE7up){isIE6=true;}
if (isIE7up){isIE7=true;}
if (navigator.userAgent.indexOf('Opera')!=-1){isOpr=true;isDOM=false;isNN4=false;isIE4=false;isIE5up=false;isIE55up=false;isIE6=false;isIE6up=false;isIE7=false;isIE7up=false;}
if (navigator.userAgent.indexOf('Linux')!=-1) {isLinux=true;}
if (isOpr&&navigator.userAgent.indexOf('Opera 2')==-1&&navigator.userAgent.indexOf('Opera 3')==-1&&navigator.userAgent.indexOf('Opera 4')==-1&&navigator.userAgent.indexOf('Opera 5')==-1&&navigator.userAgent.indexOf('Opera 6')==-1){isOpr7up=true;}
if(isOpr&&(navigator.userAgent.indexOf('Opera/0')!=-1||navigator.userAgent.indexOf('Opera/1')!=-1||navigator.userAgent.indexOf('Opera/2')!=-1||navigator.userAgent.indexOf('Opera/3')!=-1||navigator.userAgent.indexOf('Opera/4')!=-1||navigator.userAgent.indexOf('Opera/5')!=-1||navigator.userAgent.indexOf('Opera/6')!=-1)){isOpr7up=false;}
if (navigator.userAgent.indexOf('Mac')!=-1){isMac=true;}
if (navigator.userAgent.indexOf('Gecko')!=-1){isGecko=true;isNN4=false;isIE4=false;isIE5up=false;isIE55up=false;isIE6=false;isIE6up=false;isIE7=false;isIE7up=false;}
if(navigator.userAgent.indexOf('Safari')!=-1){isSafari=true;isGecko=false;isNN4=false;isIE4=false;isIE5up=false;isIE55up=false;isIE6=false;isIE6up=false;isIE7=false;isIE7up=false;}
if(navigator.userAgent.indexOf('KHTML')!=-1||navigator.userAgent.indexOf('khtml')!=-1){isKhtml=true;isGecko=false;isNN4=false;isIE4=false;isIE5up=false;isIE55up=false;isIE6=false;isIE6up=false;isIE7=false;isIE7up=false;}
if (isGecko){GeckoVersion=navigator.userAgent.substring(navigator.userAgent.indexOf('rv:')+3,navigator.userAgent.indexOf('rv:')+6);}
if (isOpr){OprVersion=navigator.userAgent.substring(navigator.userAgent.indexOf('Opera')+6,navigator.userAgent.indexOf('Opera')+10);}
if(isIE5up&&!isIE55up){var undefined='undefined';} // define undefined on IE5.0

// output the inclusion link for the correct css file
var cssIncCode="<link rel=\"stylesheet\" type=\"text/css\" href=\"";
document.write(cssIncCode+cL_CssFileName+"\">");
if(!isMac) {
  if (isIE4||isIE5up)
    {
    if(!isIE7&&!isIE7up){document.write(cssIncCode+cL_IECssFileName+"\">");}
    try{if(isIE7||isIE7up){document.write(cssIncCode+cL_IE7CssFileName+"\">");}}catch(error)
      {
      document.write(cssIncCode+cL_IECssFileName+"\">");
      }
    }
  else if (isGecko) {document.write(cssIncCode+cL_GeckoCssFileName+"\">");}
  else if (isOpr) {document.write(cssIncCode+cL_OperaCssFileName+"\">");}
  else {document.write(cssIncCode+cL_OtherCssFileName+"\">");}
} else if (isMac) {
  if (isGecko) {document.write(cssIncCode+cL_GeckoMacCssFileName+"\">");}
  else if (isOpr) {document.write(cssIncCode+cL_OperaCssFileName+"\">");}
  else if (isSafari) {document.write(cssIncCode+cL_SafariCssFileName+"\">");}
  else if (isIEMac) {document.write(cssIncCode+cL_IEMacCssFileName+"\">");}
  else {document.write(cssIncCode+cL_OtherCssFileName+"\">");}
}

// Correct IE Flash Bug
function rewriteFlash() {
//  if(document.body&&document.body.innerHTML) {
//    var allEmb=document.getElementsByTagName('embed'); var nf=''; var html=''; eHtml='';
//    for(var i=0;i<allEmb.length;i++) {
//      window.ac_status++;
//      html='<iframe allowtransparency=true style="background-color:transparent;height:'+allEmb[i].offsetHeight+'px;width:'+allEmb[i].offsetWidth+'px;margin:0;padding:0;border:0;" id=ffr frameborder=0 framespacing=0 scrolling=no hspace=0 vspace=0 src=""></iframe>';
//      eHtml=allEmb[i].outerHTML; allEmb[i].outerHTML=html;
//      document.getElementById('ffr').contentWindow.document.write('<body style="background-color:transparent;border:0;margin:0;padding:0;">'+eHtml+'</body></html>');
//      document.getElementById('ffr').id=null;
//      }
//    } else {
//     window.setTimeout("rewriteFlash();",500);
//    }
}

// Re-render PNGs with filter on IE
window.pn_status=0;
function clib_rpng() {
  if(document.body) {
    if(document.body.innerHTML) {
      var imgColl=document.getElementsByTagName('img');
      var thisImg='';var thisSrc='';var thisW=0; var thisH=0;
      for (var i=0;i<imgColl.length;i++) {
        if(imgColl[i].src.toLowerCase().indexOf('.png')!=-1) {
          thisSrc=imgColl[i].src;
          thisW=imgColl[i].offsetWidth;
          thisH=imgColl[i].offsetHeight;
          thisImg=imgColl[i];
          thisImg.src='/s.gif'; // set dummy image
          thisImg.width=thisW; thisImg.height=thisH;
          thisImg.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+thisSrc+"',sizingMethod='scale')"; // put original src into the filter to redisplay the image
          window.pn_status++;
        }
      }
      window.pn_isActive=false;
    } else {
      window.setTimeout("clib_rpng();",1000);
    }
  } else {
    window.setTimeout("clib_rpng();",1000);
  }
}

// CookieHelpers
function getCookie(check_name) {
  var a_all_cookies = document.cookie.split( ';' );
  var a_temp_cookie = '';
  var cookie_name = '';
  var cookie_value = '';
  var b_cookie_found = false;
  for(i=0;i<a_all_cookies.length;i++) {
    a_temp_cookie = a_all_cookies[i].split( '=' );
    cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
    if(cookie_name==check_name) {
      b_cookie_found=true;
      if(a_temp_cookie.length > 1) {
        cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
      }
      return cookie_value;
      break;
    }
    a_temp_cookie = null;
    cookie_name = '';
  }
  if(!b_cookie_found) { return ""; }
}

function setCookie(name, value, expires, path, domain, secure) {
  var today = new Date();
  today.setTime(today.getTime());
  if(expires) { expires = expires * 1000 * 60 * 60 * 24; }
  var expires_date = new Date(today.getTime() + (expires));
  document.cookie = name + "=" +escape(value) +
    ((expires) ? ";expires=" + expires_date.toGMTString() : "") + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ((secure) ? ";secure" : "");
}

function delCookie(name, path, domain) {
  if(getCookie(name)) {
    document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
  }
}

function stripChar(words,character) {
  var spaces = words.length;
	for(var x = 1; x<spaces; ++x) {
    words = words.replace(character, "");   
  }
  return words;
}