function cb(field_data,field_default_value){

        if($(field_data).val() == '' || $(field_data).val() == field_default_value){
            $(field_data).css({fontStyle:'normal', color:'#000000'}).val(field_default_value); 
        }else{
            $(field_data).css({fontStyle:'normal', color:'#000000'}); 
        }
    }
    
    function cf(field_data,field_default_value){
        
        if($(field_data).val() == field_default_value){
            $(field_data).css({fontStyle:'normal', color:'#000000'}).val(''); 
        }else if($(field_data).val() == field_default_value && $(field_data).css('fontStyle') == 'normal'){
            $(field_data).css({fontStyle:'normal', color:'#000000'}); 
        }
    }

    function popWindow(object){
    /**
    * Popup Window Class
    * Handles popup open/close/center and of course creation.
    * It depends on jquery and jquery circle plugin .
    **/
        var _defaults={
            ajaxUrl:'',
            ajaxParams:{},
            iframeUrl:'',
            iframeWidth:400,
            iframeHeight:300,
            selector:'',
            messageContent:'',
            messageType:'success',
            boxWidth:'',
            modalOverlay:true,
            animationTime:500,
            overlayOpacity:0.85,
            cornerSize:'5',
            cssStyle:'',
            beforeOpen:'',
            afterOpen:'',
            beforeAjaxCall:'',
            afterAjaxCall:'',
            beforeClose:'',//not ready for use
            afterClose:'',//not ready for use
            beforeCenter:'',//not ready for use
            afterCenter:''//not ready for use
        };

        // cover object defaults
        if(typeof(object)=='object'){
            for(var d in _defaults){
                if(object.hasOwnProperty(d)==false){
                    object[d]=_defaults[d];
                }
            } 
        }else{
            object=_defaults;
        }
        this.object=object;
        // triggers the popup open event.
        this.open = function(){
            // in case it is already open, remove it.
            this.ifOpenCloseIt();
            // start building the start of the box.
            var html='<div id="popupWindow">';
            html+='<div id="innerPopupWindow">';
            html+='<a id="popupWindowCloseBtn" href="javascript:;" onclick="(new popWindow()).close();"><img src="images/x-close2.png" border="0" /></a>';
        
            if(this.object.modalOverlay){
                if($('#popupWindowOverlay').length==0){
                    $('body').append('<div id="popupWindowOverlay"></div>');
                }
                if($.browser.msie && $.browser.version.substr(0,1)=="6"){
                    $('#popupWindowOverlay').css({height:$(document).height()+'px'});
                }
                $('#popupWindowOverlay').css({opacity:this.object.overlayOpacity});
                if(this.object.animationTime > 0){
                    $('#popupWindowOverlay').fadeIn(this.object.animationTime);
                }else{
                    $('#popupWindowOverlay').show();
                } 
            }
            var rtPx=0+'px';
            if($.browser.msie && ($.browser.version.substr(0,1)=="6")){
                $("#backgroundPopup").css({"height":$(document).height()+'px'});
                var rtPx=12+'px';
            }
            $('.findDealer').css({position:'absolute',zIndex:999999,right:rtPx});
            $('.logo img').css({position:'absolute',zIndex:999999});

            if(typeof(this.object.beforeOpen)=='function'){
                this.object.beforeOpen();
            }
            
            // if it is an ajax url call:
            if(this.object.ajaxUrl.length > 0){
                if(typeof(this.object.beforeAjaxCall)=='function'){
                    this.object.beforeAjaxCall();
                }
                $.ajax({
                	url: this.object.ajaxUrl,
                	type:'POST',
                    data:this.object.ajaxParams,
                	dataType:'html',
                	success:function(_html){
                        html+=_html;
                        html+='<div></div>';
                        $('body').append(html);
                        if(this.object.boxWidth.length > 0){
                            $('#popupWindow').css({width:this.object.boxWidth+'px'});
                        }
                        (new popWindow()).center();  
                        if(this.object.cssStyle.length > 0){
                            $('#popupWindow').css(this.object.cssStyle);
                        }
                        if(this.object.cornerSize.length > 0){
                            if($.browser.msie){
                                if($.browser.version.substr(0,1)!="9"){
                                    $('#popupWindow').corner({antiAlias:true});    
                                }
                            }else if($.browser.opera){
                                $('#popupWindow').corner({antiAlias:true});   
                            }else{
                                $('#popupWindow').corner({
                                        tl:{radius:this.object.cornerSize},
                                        tr:{radius:this.object.cornerSize},
                                        bl:{radius:this.object.cornerSize},
                                        br:{radius:this.object.cornerSize},
                                        antiAlias:true
                                });    
                            }
                        }
                        if(this.object.animationTime > 0){
                            $('#popupWindow').fadeIn(this.object.animationTime);
                        }else{
                            $('#popupWindow').show();
                        }
                        if(typeof(this.object.afterAjaxCall)=='function'){
                            this.object.afterAjaxCall();
                        }
                	}
                });    
            // if it is a iframe url call:
            }else if(this.object.iframeUrl.length > 0){
                html+='<iframe src="'+this.object.iframeUrl+'" width="'+this.object.iframeWidth+'" height="'+this.object.iframeHeight+'" frameborder="0"></iframe>';
                html+='<div></div>';
                $('body').append(html);
                this.center();  
                if(this.object.cssStyle.length > 0){
                    $('#popupWindow').css(this.object.cssStyle);
                }
                if(this.object.cornerSize.length > 0){
                    if($.browser.msie){
                        if($.browser.version.substr(0,1)!="9"){
                            $('#popupWindow').corner({antiAlias:true});    
                        }
                    }else if($.browser.opera){
                        $('#popupWindow').corner({antiAlias:true});   
                    }else{
                        $('#popupWindow').corner({
                                tl:{radius:this.object.cornerSize},
                                tr:{radius:this.object.cornerSize},
                                bl:{radius:this.object.cornerSize},
                                br:{radius:this.object.cornerSize},
                                antiAlias:true
                        });    
                    }
                }
                if(this.object.animationTime > 0){
                    $('#popupWindow').fadeIn(this.object.animationTime);
                }else{
                    $('#popupWindow').show();
                }
            // if it is a selector call:
            }else if(this.object.selector.length > 0){
                html+=$(this.object.selector).html();
                html+='<div></div>';
                $('body').append(html);
                if(this.object.boxWidth.length > 0){
                    $('#popupWindow').css({width:this.object.boxWidth+'px'});
                }
                this.center();  
                if(this.object.cornerSize.length > 0){
                    if($.browser.msie){
                        if($.browser.version.substr(0,1)!="9"){
                            $('#popupWindow').corner({antiAlias:true});    
                        }
                    }else if($.browser.opera){
                        $('#popupWindow').corner({antiAlias:true});   
                    }else{
                        $('#popupWindow').corner({
                                tl:{radius:this.object.cornerSize},
                                tr:{radius:this.object.cornerSize},
                                bl:{radius:this.object.cornerSize},
                                br:{radius:this.object.cornerSize},
                                antiAlias:true
                        });    
                    }  
                }
                if(this.object.animationTime > 0){
                    $('#popupWindow').fadeIn(this.object.animationTime);
                }else{
                    $('#popupWindow').show();
                }
            // if it is a internal message call:
            }else if(this.object.messageContent.length > 0){
                html+='<div class="popupMessage '+this.object.messageType+'">'+this.object.messageContent+'</div>';
                html+='</div></div>';
                $('body').append(html);
                if(this.object.boxWidth.length > 0){
                    $('#popupWindow').css({width:this.object.boxWidth+'px'});
                }
                this.center();  
                if(this.object.cssStyle.length > 0){
                    $('#popupWindow').css(this.object.cssStyle);
                }
                if(this.object.cornerSize.length > 0){
                    if($.browser.msie){
                        if($.browser.version.substr(0,1)!="9"){
                            $('#popupWindow').corner({antiAlias:true});    
                        }
                    }else if($.browser.opera){
                        $('#popupWindow').corner({antiAlias:true});   
                    }else{
                        $('#popupWindow').corner({
                                tl:{radius:this.object.cornerSize},
                                tr:{radius:this.object.cornerSize},
                                bl:{radius:this.object.cornerSize},
                                br:{radius:this.object.cornerSize},
                                antiAlias:true
                        });    
                    }
                }
                if(this.object.animationTime > 0){
                    $('#popupWindow').fadeIn(this.object.animationTime);
                }else{
                    $('#popupWindow').show();
                }
            }
            if($.browser.msie && ($.browser.version.substr(0,1)=="7"||$.browser.version.substr(0,1)=="6")){
                $('body').css({position:'relative'});
            }
            // do the last popup centering.
            this.center();
            
            if(typeof(this.object.afterOpen)=='function'){
                this.object.afterOpen();
            }  
        }
        
        // triggers the popup close event.
        this.close = function(){
            if(this.object.modalOverlay){
                if(this.object.animationTime > 0){
                    $('#popupWindowOverlay').fadeOut(this.object.animationTime,function(){
                       $('#popupWindowOverlay').remove();                   
                    });
                }else{
                  $('#popupWindowOverlay').remove();  
                }
            }     
            if(this.object.animationTime > 0){
                $('#popupWindow').fadeOut(this.object.animationTime,function(){
                   $('#popupWindow').remove(); 
                });
            }else{
                $('#popupWindow').remove();
            }
        }
        
        // triggers the popup center event.
        this.center = function(){
            var windowWidth = document.documentElement.clientWidth;
        	var windowHeight = document.documentElement.clientHeight;
            var scrollTop=$(window).scrollTop();
            var popupHeight = $("#popupWindow").height() + 20;
        	var popupWidth = $("#popupWindow").width() + 20 ;
            var fromTop=Math.floor((windowHeight/2-popupHeight/2) + scrollTop);
            var fromLeft=Math.floor(windowWidth/2-popupWidth/2);
            $("#popupWindow").css({
        		"top": fromTop + 'px',
        		"left":fromLeft + 'px'
        	});
            
        }
        
        this.ifOpenCloseIt=function(){
            //this is in case the scooters popup is open.
            if($('#popupScooterMenu').is(':hidden')==false){
                $("#backgroundPopup").fadeOut("slow");
                $("#popupScooterMenu").fadeOut("slow");
            }
            //
            if($('#popupWindow').length > 0){
        	   this.close();
        	}
        }
        
        this.resizeAt = function(width,height){
            $("#popupWindow").css({
        		"width": width+'px',
        		"height": height+'px'
        	});
            this.center();
        }
        
        this.moveTo=function(top, left){
            $("#popupWindow").css({
        		"top": top+'px',
        		"left": left+'px'
        	});
        }
        
    }   
$(function(){
    $(window).resize(function(){
        if($('#popupWindow').is(':hidden')==false){
            (new popWindow().center());
        }
    });
    $('#popupWindowOverlay').live('click',function(){
        (new popWindow().close());
    });
});
