function clickclear(thisfield, defaulttext) {
    $(thisfield).parent().removeClass('searchOn').removeClass('searchOff').addClass('searchOn');
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "" || thisfield.value.length == 0) {
        $(thisfield).parent().removeClass('searchOn').removeClass('searchOff').addClass('searchOff');
	} else {
        $(thisfield).parent().removeClass('searchOn').removeClass('searchOff').addClass('searchOn');
    }
}

/*
 *

function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

 *
 */

function slideSwitch() {
	//alert('hello');
    var $active = $('#slideshow span.rotatebanner.active');
	
	current_slideshow ++;
	
	if(current_slideshow>total_slideshow){
		current_slideshow = 1;
	}
	
	$('#slideshow_btt_holder > div').removeClass('selected');
	$('#slideshow_btt_holder > div:eq('+(current_slideshow-1)+')').addClass('selected');
	

    if ( $active.length == 0 ) $active = $('#slideshow a:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow span.rotatebanner:first');

    $active.addClass('last-active');

    //Kent added counter, 2012-02-09
    if ($next.attr('id') == 'ProtonRotateBanner') {
        $('#slideshow_counter_holder').show();
    } else {
        $('#slideshow_counter_holder').hide();
    }

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function slidechange(param){
	if(param!=current_slideshow){
		clearInterval(timer);
		current_slideshow = param;
		
		$('#slideshow_btt_holder > div').removeClass('selected');
		$('#slideshow_btt_holder > div:eq('+(current_slideshow-1)+')').addClass('selected');
		
		var $active = $('#slideshow span.rotatebanner.active');
		var $next = $('#slideshow span.rotatebanner:eq('+(current_slideshow-1)+')');
		$active.addClass('last-active');

        //Kent added counter, 2012-02-09
        if ($next.attr('id') == 'ProtonRotateBanner') {
            $('#slideshow_counter_holder').show();
        } else {
            $('#slideshow_counter_holder').hide();
        }
		
		$next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
		
		timer = setInterval( "slideSwitch()", 10000 );
	}
}

/* Kent added, 2011-04-07 */
function popupWindow(url, name, width, height) {
    var _width = width;
    if (isNaN(_width)) {
        _width = 480;
    }
    var _height = height;
    if (isNaN(_height)) {
        _height = 600;
    }

    var l = ( $(window).width() - _width ) * 0.5;
	var t = 150;

    window.open(url, name, 'width='+_width+',height='+_height+',toolbar=no,menubar=no,location=no,status=no,scrollbars=no,resizable=no,left=' + l + ',top=' + t);
}

// Kent added, 2012-02-09
var target=""
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function countdown(yr,m,d,hr,min,sec) {
    theyear=yr;
    themonth=m;
    theday=d;
    thehour=hr;
    themin=min;
    thesec=sec;
    var today=new Date();

    // Begin Calculate UTC
    localTime = today.getTime();

    // obtain local UTC offset and convert to msec
    localOffset = today.getTimezoneOffset() * 60000;

    // obtain UTC time in msec
    utc = localTime + localOffset;

    // obtain and add destination's UTC time offset
    // for example, Malaysia
    // which is UTC + 8 hours
    offset = 8;
    malaysiatime = utc + (3600000*offset);

    // convert msec value to date string
    today = new Date(malaysiatime);
    // End of Calculate UTC

    var todayy=today.getYear();
    if (todayy < 1000)
        todayy+=1900;

    var todaym=today.getMonth();
    var todayd=today.getDate();
    var todayh=today.getHours();
    var todaymin=today.getMinutes();
    var todaysec=today.getSeconds();
    var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;

    futurestring=montharray[m-1]+" "+d+", "+yr+" "+hr+":"+min+":"+sec;
    
    dd=Date.parse(futurestring)-Date.parse(todaystring);
    dday=Math.floor(dd/(60*60*1000*24)*1);
    dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
    dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
    dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);

    if (dday==0&&dhour==0&&dmin==0&&dsec==1) {
        //document.forms.count.count2.value=target;
        $('#slideshow_counter_holder').html(target);
        return;
    } else {
        //document.forms.count.count2.value="Only "+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+before;
        //$('#counterDay').html(dday);
        //$('#counterHour').html(dhour);
        //$('#counterMinute').html(dmin);

        if (dday > 1) {
        	$('#counterDay').html(dday + " Days");
        } else {
        	$('#counterDay').html(dday + " Day");
        }

        if (dhour > 1) {
        	$('#counterHour').html(dhour + " Hours");
        } else {
        	$('#counterHour').html(dhour + " Hour");
        }

        if (dmin > 1) {
        	$('#counterMinute').html(dmin + " Minutes");
        } else {
        	$('#counterMinute').html(dmin + " Minute");
        }
    }

    setTimeout("countdown(theyear,themonth,theday,thehour,themin,thesec)",(1000*60));
}

