
function slideshow ( ){

	if(document.imageCurrentNumber == undefined)
	document.imageCurrentNumber = 1

	if( document.imageCurrentNumber >= document.imageCount)
	document.imageCurrentNumber=0

	document.imageRef.src = document.imageSrc.replace(/\d+\.jpg$/, document.imageCurrentNumber + '.jpg')

	document.imageRef.width= 382;
	document.imageRef.height =283;

	nr = parseInt(document.imageCurrentNumber)
	document.imageCurrentNumber = nr+1
}

function slideshow_init (imageId,imageCount){
	if (!imageId)return false ;
	document.imageRef = _gebi(imageId)

	if (!document.imageRef )return false ;
	if(document.imageRef && !document.imageSrc)
	document.imageSrc = document.imageRef.src

	document.imageRef.src= '/assets/startingslideshow.jpg'


	if (!imageCount || imageCount < 2)return false ;
	document.imageCount = imageCount;
	document.imageSlideshow =setInterval('slideshow()',3000);

}

function  slideshow_stop(){
	if(document.imageSlideshow){
		clearInterval(document.imageSlideshow)
		document.imageSlideshow = false
		return true;
	}
	return false;
}






if(document.cookie.indexOf('cbp_style=0')>=0){

	document.write('<link rel="stylesheet" type="text/css" href="assets/cbp_size0.css">\n');

}else if (document.cookie.indexOf('cbp_style=1')>=0){

	document.write('<link rel="stylesheet" type="text/css" href="assets/cbp_size1.css">\n');

}else if (document.cookie.indexOf('cbp_style=2')>=0){

	document.write('<link rel="stylesheet" type="text/css" href="assets/cbp_size2.css">\n');

}else{

	document.write('<link rel="stylesheet" type="text/css" href="assets/cbp_size0.css">\n');

}


function chooseStyle (newstyle){
	var expdate = new Date();
	expdate.setTime(expdate.getTime() + (1000*3600*24*365));
	document.cookie = 'cbp_style=' + newstyle + '; expires=' + expdate.toGMTString() + '; path=/';
	self.location = self.location;
}


btnFind = new Image ();
btnFind.src = "/images/btn_findahome.gif";
btnFindOn = new Image ();
btnFindOn.src = "/images/btn_findahome_on.gif";

btnAgents = new Image ();
btnAgents.src = "/images/btn_agents.gif";
btnAgentsOn = new Image ();
btnAgentsOn.src = "/images/btn_agents_on.gif";

btnNews = new Image ();
btnNews.src = "/images/btn_news.gif";
btnNewsOn = new Image ();
btnNewsOn.src = "/images/btn_news_on.gif";

btnRelocation = new Image ();
btnRelocation.src = "/images/btn_relocation.gif";
btnRelocationOn = new Image ();
btnRelocationOn.src = "/images/btn_relocation_on.gif";

btnResources = new Image ();
btnResources.src = "/images/btn_resources.gif";
btnResourcesOn = new Image ();
btnResourcesOn.src = "/images/btn_resources_on.gif";

btnConcierge = new Image ();
btnConcierge.src = "/images/btn_concierge.gif";
btnConciergeOn = new Image ();
btnConciergeOn.src = "/images/btn_concierge_on.gif";

btnCareers = new Image ();
btnCareers.src = "/images/btn_careers.gif";
btnCareersOn = new Image ();
btnCareersOn.src = "/images/btn_careers_on.gif";

btnAbout = new Image ();
btnAbout.src = "/images/btn_about.gif";
btnAboutOn = new Image ();
btnAboutOn.src = "/images/btn_about_on.gif";

btnContact = new Image ();
btnContact.src = "/images/btn_contact.gif";
btnContactOn = new Image ();
btnContactOn.src = "/images/btn_contact_on.gif";

btnmarket = new Image ();
btnmarket.src = "/images/btn_market.png";
btnmarketOn = new Image ();
btnmarketOn.src = "/images/btn_market_on.png";



function btnRoll(rollName,imgName){
	eval ('document.Find.src=btnFind.src');
	eval ('document.Agents.src=btnAgents.src');
	eval ('document.News.src=btnNews.src');
	eval ('document.Relocation.src=btnRelocation.src');
	eval ('document.Resources.src=btnResources.src');
	eval ('document.Careers.src=btnCareers.src');
	eval ('document.About.src=btnAbout.src');
	eval ('document.Contact.src=btnContact.src');
		eval ('document.market.src=btnmarket.src');
	eval ('document.'+rollName+'.src='+imgName+'.src');
}

function allOff(){
	eval ('document.Find.src=btnFind.src');
//	eval ('document.Agents.src=btnAgents.src');
	eval ('document.News.src=btnNews.src');
//	eval ('document.Relocation.src=btnRelocation.src');
	eval ('document.Resources.src=btnResources.src');
	eval ('document.Careers.src=btnCareers.src');
	eval ('document.About.src=btnAbout.src');
//	eval ('document.Contact.src=btnContact.src');
}

function changeFact(area){
		_gebi('cf_content').innerHTML = _gebi('cf_'+area).innerHTML;
}



function MM_preloadImages () //v3.0
{	var d = document;

	if (d.images)
	{
		if (!d.MM_p)
			d.MM_p = new Array();

		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;

		for (i = 0; i < a.length; i++)
			if (a[i].indexOf("#") != 0)
			{
				d.MM_p[j] = new Image;
				d.MM_p[j++].src = a[i];
			}
	}
}





function _gebi (H)
{
	try { return document.getElementById(H); }
	catch (e)
	{
	}
	return false
}



////// _Cookie


Array.prototype.mapKeys = function() {
    var c = new Array();
    for (var i = 0; i < this.length; i++) {
        var p = this[i].split(":");
        if (typeof p[0] != "undefined") c[p[0]] = p[1];
    };
    return c
};

Array.prototype.unmapKeys = function() {
    var c = new Array();
    var i = 0;
    for (attr in this) {
        var t = typeof this[attr];
        if (t != "string" && t != "number") continue;
        c[i] = attr + ":" + this[attr];
        i++;
    };
    return c
};



var __js_Cookie = {
    // Data for the highlevel functions
    base : "CBPSEARCH",
    days : 1,
    splitter : "|",
    path : "/",
    secure : false,
    // Official specs allows 4000 Bytes/Cookie and 20 Cookies/Page
    maxstr : 4000,
    maxarr : 10,
    maxarrhard : 20,

    set : function(name, value) {
        if (name == null || typeof name == "undefined" || value==null || typeof value == "undefined") return;

        var c = this.get_sub().split(this.splitter)
        var n = [];

        // copy other values
        for (var i = 0; i < c.length; i++) {
            if (c[i] == "") continue;
            var d = c[i].split(":");
            if (d[0] != name) n.push(c[i]);
        };

        // add new value pair
        n.unshift(name + ":" + value);
        // copy to destination array
        d = n;

        // Neue Daten optimiert abspeichern
        var s = "";
        var j = 0;

        for (var i = 0; i < d.length; i++) {
            // ignore some erroneous values
            if (d[i] == null || typeof d[i] == "undefined") continue;

            // Too big
            if ((s.length + d[i].length) > this.maxstr) {
                this.create(this.base + this.norm_sub(j), s, this.days);
                s = d[i];
                j++;

                if (j>this.maxarr) break;
            } else {
                if(s != "") s+= this.splitter;
                s += d[i];
            };
        };

        // Save remaining values
        if (s!="" && j <= this.maxarr) {
            this.create(this.base + this.norm_sub(j), s, this.days);
            j++;
        };

        for (var i = j; i < this.maxarrhard; i++) this.erase(this.base + this.norm_sub(i));

        return true
    },

    get : function(name) {
        var c = this.prep_sub()[name];
        if (c && typeof c != "undefined") return c;
        return null
    },

    norm_sub : function(i) {
        return String(i < 10 ? "0" + i : i)
    },

    get_sub : function() {
        var s = "";

        for (var i = 0; i < this.maxarrhard; i++) {
            var r = this.read(this.base + this.norm_sub(i))
                if (r) s += r;
        };

        return s
    },

    prep_sub : function() {
        return this.get_sub().split(this.splitter).mapKeys();
    },

    // Low Level Internal Functions
  create : function(name, value, days, spath ) {
         if (days) {
             var date = new Date();
             date.setTime(date.getTime() + (days * 86400 * 1000));
             var expires = "; expires=" + date.toGMTString();
         } else {
             var expires = "";
         };

            if(spath)
              var setpath ="; path=" + this.path;


         if(self.location.protocol && self.location.protocol =='https:')
         	this.secure = true;


         if(!setpath && this.path)
         var setpath ="; path=" + this.path;

	if(this.secure)
		var _secure = "; secure";
	else
		var _secure ="";

         document.cookie = name + "=" + value + expires +   setpath + _secure;

    },
    read : function(name) {
        var ne = name + "=";
        var ca = document.cookie.split(";");

        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];

            while (c.charAt(0) == " ")
                c = c.substring(1, c.length);

            if (c.indexOf(ne) == 0)
                return c.substring(ne.length, c.length)
        };

        return null
    },

    erase : function(name) {
    	if (this.read(name) != null)
	    this.create(name, "", -1);
	     this.create(name, "", -1);
    }
};





function __basename (s)
{
	if (!s)
		return ''

	pos = s.lastIndexOf('/')

	if (pos != -1)
		return s.substr(pos + 1)

	else
		return s
}

function __extension (s)
{
	if (!s)
		return ''

	pos = s.lastIndexOf('.')
	pos2 = s.lastIndexOf('/')

	if (pos2 && pos2 > pos)
		return '';

	if (pos != -1)
		return s.substr(pos + 1)

	else
		return ''
}

function __dirname (s)
{
	if (!s)
		return ''

	pos = s.lastIndexOf('/')

	if (pos != -1)
		return s.substr(0, pos)

	else
		return '.'
}

function __pathinfo (s)
{
	if (!s)
		return '';

	var pos = s.lastIndexOf('/')

	var dirinfo = new Array();

	if (pos != -1)
	{
		dirinfo[1] = s.substr(pos + 1);
		dirinfo[0] = s.substr(0, pos);
	}else
	{
		dirinfo[1] = s
		dirinfo[0] = "."
	};

	if (dirinfo[1])
	{
		var pos2 = dirinfo[1].lastIndexOf('.')

		if (pos2 != -1)
			dirinfo[2] = dirinfo[1].substr(pos2 + 1);
	}

	return dirinfo;
}



function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function cleanNum(checkString,unsigned,asint,comma_not_dot){

	if(checkString==undefined)return 0;
	checkString=String(checkString)

	if(checkString.indexOf('[object')!=-1)return 0;

	unsigned = (unsigned==undefined ? false : unsigned);
	asint= (asint==undefined ? false : (asint ? true : false))
	//comma_not_dot =
	if(comma_not_dot == undefined)comma_not_dot= false;

	var decsep = '.'
	//comma_not_dot = (comma_not_dot==undefined? false : comma_not_dot)
	if(comma_not_dot)decsep = ',';

	var newString = '';
	var dot = 0;

	for (i = 0; i < checkString.length; i++) {
			ch = checkString.charAt(i);
			if ( ch == decsep ){
				if(newString=="")
					newString += 0

				if(dot >0)
					continue;

				newString += '.';
				dot = newString.length;
			}
			else if ((!unsigned) && ch == "-" && newString==''){
					newString += ch;
			}
			else if (ch >= "0" && ch <= "9"){
				if(newString==""&& ch ==0)
					continue;
				else
					newString += ch;
			}
	 };

    if(asint && dot>0) return newString.substr(0,dot-1)

    return newString;
}





function popWin(winurl,wintarget,ww,wh,windowStyle)
	{

	// popWin(windowUrl,windowTarget,winWidth,winHeight,{'ww':"winWidth",'wh':"winHeight",'posleft':null,'postop':null,'wscrollbars':null,'wtoolbar':null,'wstatus':null,'wresizeable':null,'wmenubar':null,'wlocation':null,'wfullscreen':0,'wdirectories':0,'personalbar':0,'wdependent':0,'wallwaysraised':0})


		if(parseInt(navigator.appVersion)>=4){

			if(windowStyle== undefined || !windowStyle )
					windowStyle= new Object();

			if(!document.oldPopupWindowTarget)
				document.oldPopupWindowTarget='';


			if(windowStyle['postop'] && windowStyle['postop'] != 'center')
				windowStyle['postop'] =Math.round( parseFloat(windowStyle['postop']), 4)


			if(windowStyle['centered']) {
				if(!windowStyle['postop'])
					windowStyle['postop']='center' ;

				windowStyle['posleft']  = 'center'
			}


			var parmsno = new Array('toolbar','status','menubar','location')
			var parmsyes = new Array('resizeable','scrollbars')

			for(var i=0;i<parmsno.length;i++){
				if(windowStyle[parmsno[i]]  == undefined ||windowStyle[parmsno[i]]  == null)
					windowStyle[parmsno[i]] = 'no'
			}
			for(var i=0;i<parmsyes.length;i++){
				if(windowStyle[parmsyes[i]] == undefined ||windowStyle[parmsyes[i]] == null)
					windowStyle[parmsyes[i]] = 'yes'
			}



			ww = parseFloat(ww ? ww : windowStyle['ww'] || 0 ) || 620;
			wh = parseFloat(wh ? wh : windowStyle['wh'] || 0 ) || 440;

			var screenW = parseInt(screen.width)||800
			var screenH = parseInt(screen.height)||600;

			if(0 < wh && wh < 1 ){
					wh = Math.round(screenH * wh, 0);
			};
			if(0 < ww && ww < 1 ){
					ww = Math.round(screenW * ww, 0);
			};


			if(windowStyle['postop']  == 'center' ){
				if(screenH - wh > 0) {
					windowStyle['postop'] = Math.round( (screenH - wh) * 0.5, 0)
					if(windowStyle['postop']<=0)
							windowStyle['postop']=1
					} else {
						windowStyle['postop'] = 20
						wh = screenH - windowStyle['postop']*2;
				}
			}

			else if ( parseFloat(windowStyle['postop'])>0&& parseFloat(windowStyle['postop'])< 1){

				var var_postop = parseFloat(windowStyle['postop'])
				if(var_postop <=0.001)
					var_postop =0.5

				if(screenH - wh > 0) {
					windowStyle['postop'] = Math.round( (screenH - wh) * var_postop , 0)
					if(windowStyle['postop']<=0)
						windowStyle['postop']=11
				} else {
					windowStyle['postop'] = 20
					wh = screenH - windowStyle['postop']*2;
				}
			}

			if(windowStyle['posleft']  == 'center' ) {
				if(screenW - ww > 0){
					windowStyle['posleft'] =  Math.round( (screenW -ww) * 0.5 ,0)
					if(windowStyle['posleft']<=0)
						windowStyle['posleft']=1
				} else {
					windowStyle['posleft'] = 20
					ww = screenW - windowStyle['posleft']*2;
				}

			};


			if(windowStyle['posleft'] == undefined ||windowStyle['posleft'] == null||!windowStyle['posleft']){windowStyle['posleft'] = 20;}
			if(windowStyle['postop'] == undefined ||windowStyle['postop'] == null||!windowStyle['postop']){windowStyle['postop'] = 20;}


			if( wintarget == undefined || wintarget == null|| !wintarget )
				wintarget = "popup" + parseInt(Math.random()*1000000)


			windowStyle['ww'] = Math.round(ww, 0).toString();
			windowStyle['wh'] = Math.round(wh, 0).toString();


			var	winstyle =	'width='		+ windowStyle['ww']			+
						', height='		+ windowStyle['wh']			+
						', left='		+ windowStyle['posleft']		+
						', top='			+ windowStyle['postop']		+
						', screenX='		+ windowStyle['posleft']		+
						', screenY='		+ windowStyle['postop']		;



		for (var ikey in windowStyle){
			if(ikey=='ww'||ikey=='wh'||ikey=='posleft'||ikey=='postop'||ikey== 'centered')
				continue;

			if(windowStyle[ikey] == undefined)windowStyle[ikey]='no';

			winstyle +=   ', ' + ikey + '=' +  windowStyle[ikey]
		}


//alert(winstyle)

		if(!document.newPopupWindow || document.newPopupWindow.closed || document.oldPopupWindowTarget != wintarget)
		{
			document.newPopupWindow = window.open(winurl,wintarget,winstyle);
		}
/*
		else if (document.newPopupWindow && document.oldPopupWindowTarget == wintarget
 		    && !document.newPopupWindow.closed &&  document.newPopupWindow.location){

			document.newPopupWindow = window.open(winurl,wintarget,winstyle, true);


 			document.newPopupWindow.resizeTo(ww,wh)
 			document.newPopupWindow.moveTo(windowStyle['posleft'],windowStyle['postop'])
 			document.newPopupWindow.location.target  = wintarget
 			document.newPopupWindow.location.href  = winurl

 		}
*/
		else{
			document.newPopupWindow.close();
			document.newPopupWindow = null;
			document.newPopupWindow = window.open(winurl,wintarget,winstyle);
		}
		//document.newPopupWindow.focus();
		if(window.focus) document.newPopupWindow.focus();
			document.oldPopupWindowTarget = wintarget;

	} else {
		if(!wintarget )
			wintarget = "popup" + parseInt(Math.random()*1000000);
		if(!ww)ww=615
		if(!wh)wh=455

		window.open(winurl,wintarget,'width='+ww+',height='+wh+',left=5,top=5,scrollbars=yes,status=no,toolbar=no,resizable=yes,menubar=yes,location=no');
	}


	return false;
}
function  targetNew(myURL, myTarget){
	return popWin(myURL,myTarget,null,null,{'ww':0.75,'wh':0.63,'posleft':'center','postop':0.15,'toolbar':0,'status':1,'menubar':0,'location':0,'directories':0,'scrollbars':1,'resizeable':1})
}


