var home_headline = false;
var singleHeadline = false;

$(document).ready(function(){ 
/*doc.ready for home_demo-showcase*/
  $("#DIV2").hide();
  
  $('#watch-demo').bind('click', function() {
    $("#DIV1").hide();
    $("#DIV2").show();
    if (!singleHeadline)
        stopRotating();
  });
  
  $('#close-demo').bind('click', function() {
    $("#DIV2").hide();
    $("#DIV1").show();
    var clone = $("#demo").clone(true);
    $("#demo").remove();
    $("#Flash2").html(clone);
    if (!singleHeadline)
        restartRotating();
  });
/*end home_demo-showcase*/

/*doc.ready for home_featuresbox*/
$(".checks").fadeIn(150);

$("div.scrollable").scrollable({
	speed: 700,	circular: true,
	onBeforeSeek: function()  {
			$(".checks").hide();
			},
	onSeek: function()  {
			$(".checks").fadeIn(150);
			}
	});
	
/*end home_featuresbox*/

/*doc.ready for home_headline*/
singleHeadline =($("#headline li").length == 1);
if(home_headline){

    $("#headline li").hide();
            
    if (singleHeadline){
        $("#headline li:first").show();
        $(".news-next").hide();
        $(".news-prev").hide();
    }
    else {       
        showItem($("#headline li:first")); 
        $(".news-next").bind('click', nextHeadline);
        $(".news-prev").bind('click', prevHeadline);
    }
}
/*end home_headline*/

/*remove pipes in footer nav*/
    $(".footer-links-left a:last").css({"border-right":"none"});
    $(".footer-links-right a:first").css({"border-left":"none"});
/*end footer nav style changes*/

    vardocspeed = 1;
    if($.browser.safari){
        wrapmaindiv("saf",vardocspeed);
    }
    if($.browser.mozilla){
        wrapmaindiv("firefox",vardocspeed);
    }
    if($.browser.msie && $.browser.version == 6){
        wrapmaindiv("ie6",vardocspeed);
    }
    if($.browser.msie && $.browser.version == "7.0"){
        wrapmaindiv("ie7",vardocspeed);
    }   
    if($.browser.msie){
        InitIEPrintActions();
    } 
    if($.browser.msie && $.browser.version == 6) {
        $( function() {NavCSS()} ); 
    }
     
    try{

            $("a.fancyimg").fancybox({
    			'centerOnScroll':false,
    			'imageScale':true,
    			'hideOnContentClick':false,
    			'overlayOpacity':.9,
				'overlayShow': false,
				'zoomSpeedIn': 600,
				'zoomSpeedOut': 500,
				'easingIn': 'easeOutBack',
				'easingOut': 'easeInBack'
    		});
    		 
    		$("a.fancywithbg").fancybox({
    			'overlayOpacity':.6,
    			'padding':0,
    			'overlayColor':'#000'
    		});

            $("a.fancypop").fancybox({
                'autoDimensions':false
            });
            
            $("a.fancyswf").fancybox({
                'width' : 737,
	            'height' : 353,
	            'type' : 'swf',
	            'padding' : 0
            });
            
    }catch(err){
     $("a.fancypop").hide();
     $("a.fancyimg").hide();
    }
    
    prettyhr();
   
   equalizecolhieghts();    
   
   var hpShowcase = $(".welcome-showcase").length;
   if(hpShowcase > 0)
   {    
        var fobjFlashPlayer1 = new SWFObject("kwwmedia/HomeFlash/hp-initial-image_preloadr.swf", "", "361", "353", "8", "#fff");
        fobjFlashPlayer1.addParam("wmode", "transparent");
        fobjFlashPlayer1.addParam("quality", "high");
        fobjFlashPlayer1.write("Flash1");
        //document.title = "flash";
   }
   
});
/*jscrollpane for Partners section*/
function initjscroll(){
    $('.db-scrollcontainer').jScrollPane(
        {
            verticalDragMinHeight: 20,
            verticalDragMaxHeight: 80	           
        });
    }
/*end jscrollpane for Partners section*/

function wrapmaindiv(strclass,speed){

  setTimeout(function(){
        $(".maindiv").wrap("<div class=\""+strclass+"\"></div>");
        },speed);
}

/*since IE has trouble with the HTC Behavior during a print we call
into the IE specific print events and disable the htc definition prior to the print */

var roundedboxes; // <-- our array of all our rounded elements

function InitIEPrintActions(){
    roundedboxes = $(".box,.hidden-corners,.welcome-showcase,#homefeaturebox .scrollable");
    window.onbeforeprint = removeRoundedboxes;
    window.onafterprint = addRoundedboxes;
}

function removeRoundedboxes(){
     $(roundedboxes).css("behavior","none");
    }
    
    function addRoundedboxes(){
     $(roundedboxes).css("behavior","url(inc/PIE.htc)");
    }

function equalizecolhieghts(){

    maincontent_H = $(".maincontent").height();
    right_content_H = $("#right_content").height();
    var myarray=[maincontent_H, right_content_H]
    
    //alert(myarray);
    myarray.sort(function(a,b){return a - b});
    var useval = myarray[myarray.length-1];
    

     $("#centercontent").height(useval);
     $("#right_content").height(useval-5);
    
    //alert(useval);
    //alert(leftcol_H +":"+maincontent_H+":"+right_content_H);
    //alert('leftcol is '+leftcol_H +' and main is '+maincontent_H);
}

function prettyhr(){
$("hr").wrap('<div class="hr">').append('</div>');
}

function NavCSS(){
$("div.topnav").wrap('<div class="ie6nav">').append('</div>');
}
//c being our param denoting whether or not to use alpha
// c = alpha || c = ""
//function roundcorners(c){

//$("div.boxGreyHead") .wrap('<div class="'+ c +'bxGreyHead">'+ 
//'<div class="bd">'+ 
//'<div class="c">'+ 
//'<div class="s">'+ 
//'</div>'+ 
//'</div>'+ 
//'</div>'+ 
//'</div>');
//$('div.'+ c +'bxGreyHead').prepend('<div class="hd">'+
//'<div class="c"></div>'+
//'</div>')
//.append('<div class="ft">'+
//'<div class="c"></div>'+
//'</div>');

//}
// Equalize cols
eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--)d[c.toString(a)]=k[c]||c.toString(a);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.w.v=6(3){9 1=u(0);4(3)1=3.s(",");9 5=0;2.e(6(i){4(2.8>5)5=2.8}).d("c","r").e(6(i){9 7=5-2.8;4(7>0){t=q.p(\'o\');$(t).n("m","l").d("c",7+"k");4(1.j>i){$(2).h(1[i]).3(\':b-1\').a(t)}g{$(2).3(\':b-1\').a(t)}}})}})(f);',33,33,'|child|this|children|if|maxH|function|gap|offsetHeight|var|after|last|height|css|each|jQuery|else|find||length|px|fill|class|attr|div|createElement|document|auto|split||Array|equalizeCols|fn'.split('|'),0,{}))
